How slimevr/slimevr-firmware-webbuilder works
1. What this repo is
- This is a NestJS backend API for building SlimeVR tracker firmware from configurable inputs such as boards, IMUs, pins, and other firmware options.
- There is no frontend in this repo; the service is the orchestration layer between HTTP requests, the firmware build toolchain, database state, and artifact storage.
2. Top-level application boundary
- src/main.ts is the runtime entrypoint.
- src/app.module.ts wires the application together.
- src/instrument.ts is a separate bootstrap concern, likely for app instrumentation/telemetry, kept outside the business modules so it doesn’t pollute request handling.
3. HTTP/API layer
- src/app.controller.ts provides the root controller.
- src/firmware/firmware.controller.ts is the main API surface for firmware-related operations.
- The controller boundary is where external clients submit build requests, query build state, or retrieve build-related metadata.
4. Firmware orchestration subsystem
- src/firmware/firmware.module.ts, firmware.service.ts, and firmware.types.ts contain the core domain logic.
- This subsystem is responsible for turning a requested firmware configuration into a concrete build plan, coordinating the build, and returning or persisting the result.
- The types.ts file suggests explicit domain contracts for request/response payloads and build configuration data.
5. Build engine integration
- src/firmware/platformio.service.ts isolates integration with PlatformIO, which is the actual firmware build toolchain.
- This is a key architectural boundary: the API layer does not directly build firmware; it delegates to a dedicated service that wraps the external build system.
- That separation makes it easier to swap build mechanics without changing the public API.
6. Persistence layer
- src/db.schema.ts defines the database schema used by the application.
- drizzle.config.ts plus the drizzle/ directory indicate Drizzle ORM with versioned SQL migrations.
- The database is used for durable state around firmware builds and related metadata rather than for heavy binary storage.
7. Artifact storage
- The repo includes MinIO configuration under docker/minio/, which means build outputs are stored in object storage rather than directly in the database or local disk.
- This is the natural place for compiled firmware binaries, archives, or other generated artifacts.
- MinIO is a major infrastructure boundary in the system: database stores metadata, MinIO stores the actual files.
8. Configuration and source management
- .env.template and src/env.ts show that runtime configuration is environment-driven.
- sources.json is an important operational input: the README says the container checks it every 5 minutes to add different firmware versions.
- That means firmware source/version availability is controlled by a file-based config layer, not only by code or DB records.
9. Deployment/runtime model
- Dockerfile, docker-compose.yml, and docker-compose.dev.yml define the containerized runtime.
- The README explicitly recommends the dev compose setup and shows that the service expects PostgreSQL plus MinIO alongside the API container.
- This repo is therefore designed as a multi-container backend system, not a standalone binary.
10. Operational setup
- The README’s MinIO access/secret key files under docker/minio/ are part of the operational contract for bringing the stack up.
- Migrations are applied separately with drizzle-kit migrate, so schema evolution is explicit and controlled.
- This implies the app startup path is lightweight, while initialization of persistent infrastructure is handled out-of-band.
11. Tooling and language stack
- The codebase is TypeScript on NestJS.
- It uses Drizzle for schema/migrations, Docker for runtime packaging, and Nix files (flake.nix, shell.nix, flake.lock) for reproducible developer environments.
- nestia.config.ts suggests additional API typing/codegen support around the NestJS boundary.
12. Data flow summary
- Client sends a firmware build request to the API.
- The firmware module validates/normalizes the requested configuration and resolves the appropriate source/version.
- The PlatformIO integration performs the build.
- Build metadata is persisted in Postgres via Drizzle.
- Generated firmware artifacts are stored in MinIO and referenced from the database.
13. How to draw the architecture
- Model this as a single backend service with three external dependencies: Postgres, MinIO, and PlatformIO/build tooling.
- Keep the API/controller layer, firmware orchestration layer, build execution layer, and storage layer as distinct boxes.
- Show sources.json and environment config as supporting inputs to the service rather than runtime services themselves.
Main entry points: firmware.service.ts Firmware service · docker-compose.dev.yml Compose stack · app.module.ts App module · firmware.module.ts Firmware module
Components 17
Backend service
NestJS API and firmware orchestration
- Bootstrap · Starts the API process
src/main.ts - App module · Wires controllers and providers
src/app.module.ts - Root controller · Base API surface
src/app.controller.ts - Instrument · Separate startup instrumentation
src/instrument.ts - Firmware API · Build and firmware endpoints
src/firmware/firmware.controller.ts - Firmware module · Domain boundary for firmware flows
src/firmware/firmware.module.ts - Firmware service · Resolves configs and coordinates builds
src/firmware/firmware.service.ts - Firmware types · Request and build data shapes
src/firmware/firmware.types.ts - PlatformIO · Wraps external firmware toolchain
src/firmware/platformio.service.ts
Storage
Persistent metadata and artifact storage
- DB schema · Tables for build metadata
src/db.schema.ts - Migrations · Versioned schema changes
drizzle/0000_thick_leo.sql - Postgres · Durable build state and metadata
- MinIO · Stores built firmware outputs
docker/minio
Runtime
Container and deployment inputs
- Env config · Environment-driven settings
src/env.ts - Sources manifest · Firmware versions and source inputs
sources.json - Compose stack · API, Postgres, and MinIO runtime setup
docker-compose.dev.yml - Dockerfile · Container image for the service
Dockerfile
Connections 18
- Bootstrap → App module: starts · Bootstraps the Nest application
- Bootstrap → Instrument: loads · Initializes instrumentation at startup
- App module → Root controller: registers · Exposes the root controller
- App module → Firmware module: imports · Includes firmware subsystem
- Firmware module → Firmware API: registers · Publishes firmware HTTP endpoints
- Firmware module → Firmware service: provides · Makes orchestration service available
- Firmware service → Firmware types: uses · Shares domain contracts
- Firmware service → PlatformIO: delegates · Hands off actual build execution
- Firmware service → Sources manifest: resolves · Selects firmware source/version inputs
- Firmware service → Env config: reads · Consumes runtime configuration
- Firmware service → DB schema: persists via · Stores build metadata model
- DB schema → Postgres: maps to · Schema is stored in Postgres
- Migrations → Postgres: applies to · Migrates database state
- PlatformIO → MinIO: writes artifacts · Build outputs are stored in object storage
- Firmware API → Firmware service: calls · HTTP requests trigger orchestration
- Compose stack → Postgres: includes · Local stack dependency
- Compose stack → MinIO: includes · Local stack dependency
- Compose stack → Dockerfile: builds · Containerized service runtime