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
Key Components
1. VersionInfo Trait
Generic interface for version information, implemented by VersionBuilder and LightyVersionBuilder.
Exports:
lighty_loaders::types::VersionInfolighty_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::LoaderExtensionslighty_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::Loaderlighty_launcher::loaders::Loaderlighty_launcher::Loader(root)
Data Flow
Metadata Fetching
Fabric Merging Example
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/ 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:
VersionInforequiresSend + SyncCache uses
Arc<RwLock<HashMap>>Query results are
Arc<Data>Async operations use
tokio
Feature Flags
Available:
vanilla- Vanilla Minecraftfabric- Fabric loaderquilt- Quilt loaderneoforge- NeoForge loaderforge- Forge loader (in progress)forge_legacy- Legacy Forge (in progress)lighty_updater- Custom updaterall-loaders- All of the above
Extension Points
Adding a New Loader
Create module in
src/loaders/your_loader/Implement
QuerytraitDefine query enum and data types
Add to
LoaderenumAdd feature flag
Implement
LoaderExtensionsdispatch
See Query System for implementation guide.
Related Documentation
How to Use - Practical examples
Traits - VersionInfo and LoaderExtensions
Query System - Implementing queries
Cache System - Caching details
Events - LoaderEvent types
Last updated