Architecture
High Level Architecture
mcTUI follows a Clean Architecture design, enforcing the Single Responsibility Principle (SRP). Packages are highly isolated and only interact via dependency injection. No package (except UI and Launcher) is aware of the others unless strictly necessary.
Package Structure
main.go
- Purpose: Boot orchestrator and wiring.
- Responsibilities: Initializes dependencies, starts the TUI, and triggers the launcher subprocess if the user chooses to play upon UI exit.
internal/ui
- Purpose: Presentation layer.
- Responsibilities: Holds the Bubble Tea state machine (Model, Update, View) and visual components (Lipgloss styles). It strictly mutates state and interacts with the user, delegating all heavy lifting (downloads, process spawning) to the domain layers.
internal/mojang
- Purpose: Vanilla Minecraft API integration.
- Responsibilities: Interacts with
piston-meta.mojang.com, parses manifests, manages asset indexes, and provides a SHA-1 validating Downloader factory.
internal/fabric
- Purpose: Fabric Modloader integration.
- Responsibilities: Interacts with
meta.fabricmc.net, resolves modding profiles, discovers the injected MainClass, and queues Maven libraries.
internal/java
- Purpose: Java Runtime Environment discovery.
- Responsibilities: Exclusively handles scanning the file system and executing
java -versionto tabulate valid JRE candidates.
internal/nbt
- Purpose: Native binary parser.
- Responsibilities: Minimalist, zero-dependency engine written from scratch to decode Named Binary Tag (NBT) structures. Built to be entirely agnostic to Minecraft specifics.
internal/worlds
- Purpose: Saved worlds metadata extraction.
- Responsibilities: Uses the
nbtpackage to read~/.minecraft/saves/*/level.dat, extract useful data, and format relative timestamps (e.g., "2 hours ago").
internal/launcher
- Purpose: Core execution engine.
- Responsibilities: Coordinates Mojang, Fabric, and Java packages. Assembles the massive
exec.Commandclasspath, executes the JVM, and interceptsstdout/stderrto capture early crashes.
internal/config
- Purpose: State persistence and path resolution.
- Responsibilities: Resolves cross-platform OS paths and persists session preferences to JSON.
internal/roadmap
- Purpose: Dynamic feature tracking.
- Responsibilities: Ingests remote JSON from GitHub to dynamically populate the "Future Changes" panel in the TUI.