The System the Solutions Build
The reference solutions build one system, called forge, and grow it in passes. This page is the map you will come back to throughout the course: what the components are, which language each is written in, where its solution lives, and the contracts where the components meet. Every contract is a file in course/contracts/. The solution implements those files, and any component can be replaced by another implementation that meets the same contract.
The components after the tracer
Section titled “The components after the tracer”After Pass 1, every layer of the final system exists in its thinnest form. The table lists each component with its solution directory and the section that explains it:
| Component | Language | Solution | What it does | Explained in |
|---|---|---|---|---|
| optional C exercises | C | c/src/ | standalone kernels and data structures, specified by C headers and shared fixtures | Optional standalone C kernels, Vectors, matrices, and matmul, and the data structures from A growable array to Heap top-k in C |
tinyllm | Python | python/tinyllm/ | the byte bigram fitted by counting, safetensors v0, tokenizer files, the tinyllm CLI | Byte bigram |
tl-serve | Rust | rust/crates/ | a Candle engine streaming SSE completions from safetensors checkpoints, with one OTLP span per request | Your first endpoint |
| gateway | Go | go/gateway/proxy/, entry/go/cmd/gateway | API-key check, SSE pass-through without buffering, traceparent and X-Request-Id | The tracer gateway, One trace |
| deploy | Docker, Helm, kind | entry/deploy/ | engine and gateway images, charts, a kind cluster with NodePorts 30080 and 30686, Jaeger | Tracer deploy |
| docs | Markdown | docs/ | ADR-0001, the engine-crashloop runbook, postmortems | Architecture decision records, First drill |
| CI | GitHub Actions | entry/.github/workflows/ci.yml, entry/.githooks/ | commit lint and native tests for every language | The repository and its CI gate |
The diagram shows how a request and the model’s files move between those components:
flowchart LR U["curl / OpenAI SDK"] -- "HTTP + key (openai-subset v0)" --> GW["gateway (Go)"] GW -- "HTTP SSE + traceparent" --> EN["tl-serve (Rust)"] PY["tinyllm CLI (Python)"] -- "model.safetensors + config.json" --> EN PY -- "tokenizer.json + fixtures" --> EN GW -- "OTLP/HTTP JSON" --> J["Jaeger"] EN -- "OTLP/HTTP JSON" --> J
Notice that Python and Rust exchange data only through files: safetensors checkpoints, tokenizer.json, and shared fixtures. No language boundary in the system uses FFI. ADR-0001 records why: in-process bindings would couple memory ownership and failure behavior across runtimes, while files with versioned schemas and parity fixtures let each language own its memory and errors and let each service be built, tested, and restarted on its own.
The contracts
Section titled “The contracts”Those boundaries are only useful if they are written down. The contracts the tracer depends on, and the sections that first read or write them, are:
| Contract | File | Used from |
|---|---|---|
| C exercise contracts | c/include/tinyllm.h, tinyllm/abi.h, tinyllm/matmul.h, rules in c/ABI.md | the optional standalone C sections |
| C test kit | c/include/ol_test.h | the C example tests |
| Python interfaces | py/tinyllm/ (lm/bigram.pyi, io/safetensors.pyi) | Byte bigram |
| HTTP API v0 | openapi/openai-subset.v0.yaml | Your first endpoint (engine tier), The tracer gateway (gateway tier) |
| Checkpoint | formats/safetensors.md, formats/config.schema.json | written by Byte bigram, read by Your first endpoint |
| Tokenizer | formats/tokenizer.md (the bytes tokenizer) | both of the above |
| Entry points | spec/cli-roles.md | every role the system starts |
| System manifest | config/system.schema.json | how a system declares its build steps and the command for each role |
| Decision record | templates/ADR.md | Architecture decision records |
The spiral
Section titled “The spiral”After every pass the system runs end to end: a request enters at the gateway, reaches a model the Python side trained, and leaves a trace. Later sections do one of two things. Most upgrade a component behind an unchanged contract; the bigram retrained by autograd in Pass 2, for example, still serves through the same checkpoint and the same engine. The rest change a contract, and they do it through an explicit migration. Because every pass keeps the earlier end-to-end paths working, a regression anywhere shows up as a broken path you already understood.
The table traces how each contract grows across the passes:
| Contract | How it grows |
|---|---|
| the model behind the checkpoint | count bigram (Pass 1), autograd bigram (Pass 2), the transformer family (Pass 5), the Llama family served by the engine (Pass 7 on) |
| standalone C kernels | optional exercises, whose outputs are compared with the Python reference’s outputs for the same inputs |
HTTP openai-subset | v0 completions with SSE (Pass 1), v1 with chat, usage, and tools (Pass 7), the v2 migration (Pass 11) |
| gateway | proxy (Pass 1); auth, limits, routing, cache, and ledger (Pass 7); usage policy (Pass 10) |
| deploy | two charts and Jaeger (Pass 1), per-role charts and the observability stack (Pass 7), durable workers (Pass 8) |