Architecture

System Overview

┌─────────────────────────────────────────────────────────────────┐
│                         User Application                         │
└──────────────────────────────────┬──────────────────────────────┘

                    ┌──────────────┴──────────────┐
                    │  lighty-launcher (Facade)   │
                    │    - Prelude                │
                    │    - Re-exports             │
                    └──────────────┬──────────────┘

        ┌──────────────────────────┼──────────────────────────┐
        │                          │                          │
        ▼                          ▼                          ▼
┌───────────────┐          ┌───────────────┐         ┌───────────────┐
│  lighty-core  │          │ lighty-launch │         │ lighty-loaders│
│  - AppState   │          │  - Launch     │         │  - Vanilla    │
│  - Extract    │          │  - Installer  │         │  - Fabric     │
│  - Hash       │          │  - Arguments  │         │  - Quilt      │
│  - Download   │          │  - Instance   │         │  - Forge      │
└───────┬───────┘          └───────┬───────┘         └───────┬───────┘
        │                          │                         │
        │                          │                         │
┌───────▼───────┐          ┌───────▼───────┐         ┌───────▼────────┐
│  lighty-auth  │          │  lighty-java  │         │ lighty-version │
│  - Offline    │          │  - Temurin    │         │  - Builder     │
│  - Microsoft  │          │  - GraalVM    │         │  - Lighty      │
│  - Azuriom    │          │  - Zulu       │         │                │
└───────────────┘          └───────────────┘         └────────────────┘
        │                                                    │
        └────────────────────┬───────────────────────────────┘

                      ┌──────▼──────┐
                      │ lighty-event│
                      │  - EventBus │
                      │  - Events   │
                      └─────────────┘

Module Dependencies

spinner

Core Modules

lighty-core

Purpose: Foundation layer providing low-level utilities

Responsibilities:

  • Application state management (AppState)

  • File system operations

  • HTTP client management

  • Archive extraction (ZIP, TAR.GZ)

  • SHA1 hashing and verification

  • System detection (OS, architecture)

  • Cross-platform compatibility

Key Exports:

  • AppState::new() - Initialize project directories

  • extract::zip_extract() - Extract ZIP archives

  • hash::verify_file_sha1() - Verify file integrity

  • download::download_file() - HTTP downloads

Dependencies: None (foundation)

Documentation: lighty-core


lighty-auth

Purpose: User authentication and profile management

Responsibilities:

  • Offline authentication (UUID v5 generation)

  • Microsoft OAuth 2.0 flow

  • Azuriom CMS integration

  • Custom authentication providers (trait-based)

  • User profile management

Key Exports:

  • Authenticator trait - Authentication interface

  • OfflineAuth - No network required

  • MicrosoftAuth - OAuth 2.0

  • AzuriomAuth - CMS integration

  • UserProfile - User data

Dependencies:

  • lighty-event (optional, for events)

Documentation: lighty-auth


lighty-event

Purpose: Real-time progress tracking and event system

Responsibilities:

  • Event bus (multi-producer, multi-consumer)

  • Event types for all operations

  • Global event bus singleton

  • Progress tracking

  • Console output streaming

Key Exports:

  • EventBus - Main event bus

  • Event - Event enum

  • Specific events: AuthEvent, JavaEvent, LaunchEvent, etc.

  • EVENT_BUS - Global singleton

Dependencies: None

Documentation: lighty-event


lighty-java

Purpose: Java runtime management and distribution

Responsibilities:

  • Automatic JRE downloads

  • Multiple distribution support (Temurin, GraalVM, Zulu, Liberica)

  • Version detection and selection

  • Java process execution

  • Platform-specific handling

Key Exports:

  • JavaDistribution - Distribution enum

  • JavaRuntime - Process executor

  • jre_downloader - Download functions

Dependencies:

  • lighty-core - Download and extraction

  • lighty-event (optional)

Documentation: lighty-java


lighty-loaders

Purpose: Mod loader implementations and version metadata

Responsibilities:

  • Loader implementations (Vanilla, Fabric, Quilt, Forge, NeoForge, LightyUpdater, OptiFine)

  • Version metadata fetching and caching

  • Metadata merging (vanilla + loader)

  • Version querying

  • Manifest caching

Key Exports:

  • Loader - Loader enum

  • VersionInfo trait - Version information

  • LoaderExtensions trait - Loader operations

  • Version metadata types

Dependencies:

  • lighty-core - HTTP and caching

  • lighty-event (optional)

Documentation: lighty-loaders


lighty-version

Purpose: Version builders for game instances

Responsibilities:

  • Standard version builder (VersionBuilder)

  • Custom server builder (LightyVersionBuilder)

  • Version information implementation

  • Directory management

Key Exports:

  • VersionBuilder - Standard builder

  • LightyVersionBuilder - Custom server builder

Dependencies:

  • lighty-loaders - VersionInfo implementation

Documentation: lighty-version


lighty-launch

Purpose: Game launching and installation orchestration

Responsibilities:

  • Complete launch process coordination

  • Parallel file downloads and installation

  • Argument building and substitution

  • Process spawning and management

  • Instance lifecycle tracking

  • Console output streaming

Key Exports:

  • Launch trait - Launch builder

  • LaunchBuilder - Fluent API

  • Installer trait - Installation

  • InstanceControl trait - Process management

  • Argument constants

Dependencies:

  • lighty-core - Downloads, extraction

  • lighty-java - Java management

  • lighty-loaders - Metadata

  • lighty-event (optional)

Documentation: lighty-launch


lighty-tauri

Purpose: Tauri desktop integration

Requires: tauri-commands feature

Responsibilities:

  • Tauri command wrappers

  • State management for Tauri

  • Frontend-backend communication

  • Pre-built commands for common operations

Key Exports:

  • lighty_plugin() - Tauri plugin

  • Commands for auth, launch, java, etc.

Dependencies:

  • All other lighty crates

  • Tauri framework

Documentation: Available in lighty-tauri crate


Data Flow

Launch Flow

Event Flow

Cache Flow

Design Patterns

1. Builder Pattern

Used extensively for fluent API configuration:

Benefits:

  • Readable configuration

  • Type-safe

  • Optional parameters

  • Method chaining

2. Trait-Based Extensibility

Multiple traits for extension points:

Benefits:

  • Custom implementations

  • Separation of concerns

  • Auto-implementation where possible

3. Event-Driven Architecture

Decoupled progress tracking:

Benefits:

  • Real-time updates

  • Loose coupling

  • Multiple subscribers

  • Optional feature

4. Singleton Pattern

Global instances for shared state:

Benefits:

  • Shared state

  • Easy access

  • Single source of truth

5. Facade Pattern

Main lighty-launcher crate provides unified interface:

Benefits:

  • Simplified imports

  • Unified API

  • Version consistency

Concurrency Model

Async/Await

Built on Tokio for async operations:

Parallel Downloads

Multiple downloads run concurrently:

Performance: 5x-10x faster than sequential downloads

Background Tasks

Console streaming and instance monitoring:

Error Handling

Result Types

Each module defines its own result types:

Error Propagation

Using ? operator for clean error handling:

Error Types

Comprehensive error enums:

Platform Support

Cross-Platform Compatibility

Platform-specific implementations abstracted:

Supported Platforms

  • Windows - Full support

  • Linux - Full support

  • macOS - Full support

Platform Detection

Performance Optimizations

1. Parallel Downloads

All file categories downloaded concurrently

2. SHA1 Verification

Skip re-downloading files that already exist and are valid

3. Manifest Caching

Cache loader manifests for 1 hour (configurable)

4. Lazy Initialization

Components initialized only when needed:

5. Streaming I/O

Large files processed in chunks, not loaded entirely in memory

6. Batch Operations

Assets downloaded in batches of 50 for better parallelism

Security Considerations

1. SHA1 Verification

All downloaded files verified against expected hash

2. HTTPS Only

All API calls use HTTPS (automatically upgraded)

3. No Credentials Storage

Tokens and credentials not stored by default

4. Sandboxed Execution

Game processes spawned in controlled environment

5. Input Validation

All user inputs validated before use

Testing Strategy

Unit Tests

Each module has its own unit tests

Integration Tests

Full workflow tests in tests/ directory

Example-Based Testing

Examples serve as integration tests

Crate Documentation

Last updated