ROM Farmer is a sophisticated build orchestration system designed for processing ROM collections at scale. It provides a flexible, configuration-driven architecture that separates platform-specific concerns from build orchestration logic, enabling:
Multi-platform processing across 50+ gaming systems
Nested build orchestrations for complex deployment scenarios
Deep configuration override system for build-time customization
Resumable builds with state persistence
Stage-based processing pipeline with pluggable components
1. Architecture Overview
High-Level Architecture
The system is organized into four distinct layers: CLI, Orchestration, Configuration, and Processing.
flowchart TB
subgraph CLI["CLI Layer"]
cmd[romfarmer build run]
end
subgraph Orchestration["Build Orchestration Layer"]
BO[BuildOrchestrator]
PP[PlatformProcessor]
end
subgraph Config["Configuration Layer"]
BC[BuildConfig]
PC[PlatformConfig]
OV[Override System]
end
subgraph Processing["Processing Layer"]
PL[Pipeline]
ST[Stages]
CTX[StageContext]
end
subgraph Output["Output Layer"]
OUT[Organized ROMs]
META[Metadata/Gamelists]
RPT[Build Reports]
end
cmd --> BO
BO --> BC
BO --> PP
PP --> PC
PC --> OV
OV --> PC
PP --> PL
PL --> ST
ST --> CTX
CTX --> OUT
CTX --> META
BO --> RPT
Core Module Relationships
The class diagram below shows the relationships between the core components:
sequenceDiagram
participant CLI as CLI
participant BO as BuildOrchestrator
participant BC as BuildConfig
participant PP as PlatformProcessor
participant PL as Pipeline
participant ST as Stages
CLI->>BO: run(build_name)
BO->>BC: load_build_config()
BC-->>BO: config with merged includes
BO->>BO: validate()
loop For each platform
BO->>PP: process(platform)
PP->>PP: load_platform_config()
PP->>PP: apply_overrides()
PP->>PL: create_pipeline()
loop For each stage
PL->>ST: execute(context)
ST-->>PL: StageResult
end
PP-->>BO: platform_result
BO->>BO: save_state()
end
BO->>BO: run_post_build_hooks()
BO->>BO: generate_report()
BO-->>CLI: complete
Build State & Resume
ROM Farmer persists build state to enable resumable builds:
When --resume is passed, completed platforms are skipped automatically.
3. Configuration System
Configuration Hierarchy
ROM Farmer uses a two-level configuration system:
flowchart TB
subgraph BuildLevel["Build Level (config/builds/)"]
BC[BuildConfig YAML]
BC --> INC[includes: list]
BC --> EXC[excludes: list]
BC --> PLAT[platforms: list]
BC --> PO[platform_overrides: dict]
BC --> STOR[storage: dict]
BC --> SET[settings: dict]
end
subgraph PlatformLevel["Platform Level (config/platforms/)"]
PC[PlatformConfig YAML]
PC --> DAT[dat: DATConfig]
PC --> SRC[sources: List]
PC --> EXT[extraction: ExtractionConfig]
PC --> CMP[compression: CompressionConfig]
PC --> SEL[selection: SelectionConfig]
PC --> TGT[targets: List TargetProfile]
end
BC -.->|references| PC
PO -.->|overrides| PC
Nested Orchestration (includes)
Build configs can include other build configs, creating composable deployment profiles:
flowchart TB
subgraph Master["1tb-batocera-complete.yaml"]
M[Master Build]
end
subgraph Children["Included Orchestrations"]
N[nointro-1g1r-eng-7z-batocera]
R[redump-1g1r-eng-chd-batocera]
D[nintendo-disc-1g1r-eng-rvz-batocera]
end
subgraph Platforms["Resolved Platforms - 37 total"]
NP["NES, SNES, GB, GBC, GBA...
26 cartridge systems"]
RP["PSX, PS2, Saturn, Dreamcast...
8 disc systems"]
DP["GameCube, Wii, Wii U
3 Nintendo disc systems"]
end
M --> N
M --> R
M --> D
N --> NP
R --> RP
D --> DP
# Run a complete build
romfarmer build run 1tb-batocera-complete
# Run specific platforms only
romfarmer build run 1tb-batocera-complete --platforms saturn,dreamcast
# Resume interrupted build
romfarmer build run 1tb-batocera-complete --resume
# Validate without running
romfarmer build run 1tb-batocera-complete --validate-only
# Test mode: random sample
romfarmer build run 1tb-batocera-complete --test-sample 10 --seed 42
# Fast test: skip processing, copy originals
romfarmer build run 1tb-batocera-complete --test-sample 10 --passthrough
# Check build status
romfarmer build status 1tb-batocera-complete --verbose
# List available builds
romfarmer build list
CLI Options Impact on Overrides
flowchart LR
subgraph CLIOptions["CLI Options"]
TS[--test-sample N]
SEED[--seed N]
PT[--passthrough]
PLAT[--platforms x,y,z]
end
subgraph RuntimeOverrides["Injected Overrides"]
TS --> SEL["selection:
strategy: random
limit: N
seed: N"]
PT --> EXT["extraction:
enabled: false
compression:
format: none"]
PLAT --> PL["platforms: x,y,z"]
end
subgraph Effect["Effective Config"]
MC[Merged Config]
end
SEL --> MC
EXT --> MC
PL --> MC
flowchart TB
subgraph Load["1. Load and Merge"]
M[Master Config]
I1[nointro-1g1r-eng-7z]
I2[redump-1g1r-eng-chd]
I3[nintendo-disc-rvz]
M --> I1 & I2 & I3
end
subgraph Process["2. Process 37 Platforms"]
P1["NES → Organize"]
P2["SNES → Organize"]
P3["..."]
P4["Saturn → CHD → Organize"]
P5["Wii → RVZ → Organize"]
end
subgraph PostBuild["3. Post-Build"]
D[jdupes -r -L]
R[Generate Report]
end
subgraph Deploy["4. Deploy - optional"]
RS[rsync to device]
end
Load --> Process --> PostBuild --> Deploy
Summary
ROM Farmer's build orchestration system provides:
Capability
Implementation
Composability
Nested includes with merge semantics
Flexibility
Deep override system at build/platform/target levels
Reliability
State persistence, resume, validation
Extensibility
Pluggable stage pipeline
Efficiency
Test modes, passthrough, parallel processing
Automation
Post-build hooks, deployment integration
The separation of concerns between build orchestration, platform configuration, and processing stages enables ROM Farmer to scale from simple single-platform builds to complex multi-terabyte production deployments.