Architecture Overview

Design Philosophy

lighty-loaders provides a unified trait-based system for managing different Minecraft mod loaders with these principles:

  • Trait-based extensibility: Easy to add new loaders

  • Smart caching: Minimize network requests

  • Type safety: Strongly typed queries and metadata

  • Feature flags: Compile only what you need

Core Architecture

spinner

Key Components

1. VersionInfo Trait

Generic interface for version information, implemented by VersionBuilder and LightyVersionBuilder.

Exports:

  • lighty_loaders::types::VersionInfo

  • lighty_launcher::loaders::VersionInfo

Purpose: Provides version identity and directory information

2. LoaderExtensions Trait

Extension methods for fetching metadata, automatically implemented for any type implementing VersionInfo<LoaderType = Loader>.

Exports:

  • lighty_loaders::types::LoaderExtensions

  • lighty_launcher::loaders::LoaderExtensions

Purpose: Provides metadata fetching methods

3. Query Trait

Defines how to fetch and extract loader data.

Exports:

  • lighty_loaders::utils::query::Query

Purpose: Core trait for implementing new loaders

4. ManifestRepository

Generic repository for querying loader manifests with caching.

Exports:

  • lighty_loaders::utils::manifest::ManifestRepository

Purpose: Manages cache and dispatches queries

5. Loader Enum

Defines all supported loaders.

Exports:

  • lighty_loaders::types::Loader

  • lighty_launcher::loaders::Loader

  • lighty_launcher::Loader (root)

Data Flow

Metadata Fetching

spinner

Fabric Merging Example

spinner

Cache System

Two-Layer Architecture

Layer 1: Raw Version Cache

  • Stores complete JSON/data from APIs

  • Key: Version identifier (e.g., "vanilla-1.21.1")

  • TTL: 1 hour (configurable)

Layer 2: Query Cache

  • Stores extracted, processed data

  • Key: QueryKey<Q> (version + query type)

  • TTL: 1 hour (configurable)

Benefits

  • Avoid API calls: Raw cache prevents redundant network requests

  • Avoid re-parsing: Query cache prevents redundant extraction

  • Multiple queries: Different queries can share raw cache

See Cache System for details.

Loader Implementations

Vanilla

Query types: VanillaBuilder, Libraries, MainClass, Natives, JavaVersion, Assets API: Mojang official Caching: Single manifest for all queries

Fabric

Query types: FabricBuilder, Libraries API: FabricMC Merging: Combines with Vanilla metadata Caching: Separate caches for Vanilla and Fabric

Quilt

Query types: QuiltBuilder, Libraries API: QuiltMC Merging: Combines with Vanilla metadata (similar to Fabric) Caching: Separate caches for Vanilla and Quilt

NeoForge

Query types: NeoForgeBuilder API: NeoForged Maven Status: In progress Caching: Installer-based

Forge

Query types: ForgeBuilder API: MinecraftForge Status: In progress Caching: Installer-based

LightyUpdater

Query types: LightyBuilder API: Custom server (user-defined) Merging: Can merge with Vanilla Caching: Custom server manifest

See individual loader docs in loaders/arrow-up-right for details.

Directory Structure

Error Handling

All operations return Result<T, QueryError>:

Exports:

  • lighty_loaders::utils::error::QueryError

Thread Safety

All components are thread-safe:

  • VersionInfo requires Send + Sync

  • Cache uses Arc<RwLock<HashMap>>

  • Query results are Arc<Data>

  • Async operations use tokio

Feature Flags

Available:

  • vanilla - Vanilla Minecraft

  • fabric - Fabric loader

  • quilt - Quilt loader

  • neoforge - NeoForge loader

  • forge - Forge loader (in progress)

  • forge_legacy - Legacy Forge (in progress)

  • lighty_updater - Custom updater

  • all-loaders - All of the above

Extension Points

Adding a New Loader

  1. Create module in src/loaders/your_loader/

  2. Implement Query trait

  3. Define query enum and data types

  4. Add to Loader enum

  5. Add feature flag

  6. Implement LoaderExtensions dispatch

See Query System for implementation guide.

Last updated