Skip to content

Add an architecture document - #13

Merged
schreck61 merged 3 commits into
mainfrom
architecture-doc
Nov 11, 2026
Merged

schreck61 merged 3 commits into
mainfrom
architecture-doc

Conversation

@schreck61

Copy link
Copy Markdown
Owner

What

docs/architecture.md describes how Intersection Lab 0.5.1 is put together:

  • Sections 1–5: what the program is, how the code is split into layers, the boundary between ground truth and what controllers see, the crate layout and build targets, module dependencies and the order of one simulation step.
  • Section 6: each file in src/sim/: the engine, the road network for every layout, signals, sensors, demand, vehicle classes, statistics, determinism, corridors and the cooperative crossing.
  • Sections 7–8: the controller contract, what the simulation does with a controller's request, each controller and the learning code: inputs, the safety shield, the reward, training and model selection, network size and the weights files.
  • Section 9: the app's files, its frame loop, the comparison twin and an illustrated tour of the window, panel by panel, including corridors and the cooperative crossing.
  • Sections 10–13: entry points, studies and tests; the build, CI and release pipeline; design principles; where to change the code to add a controller, a layout or a sensor.
  • Appendix A: how every screenshot was made, so they can be remade when the app changes.

It has 21 Mermaid diagrams, which share one color legend, and 40 screenshots and three figures in docs/images/architecture/. The README and CONTRIBUTING.md link to it.

Also in this change:

  • Scripted screenshots: the app accepts TS_OVERLAYS, TS_SELECT, TS_BENCH and TS_SCROLL_LEFT, which the screenshots needed. A scripted screenshot now stops the clock at TS_SHOT_AFTER and waits 600 ms for the panels to catch up, so every capture of a run shows the same moment. None of this does anything unless the variables are set.
  • American spelling: "T-junction" is now "T-intersection" everywhere, including the layout's name in the app, and .gitattributes says "Normalize".

Checking the document against the code turned up a few bugs in 0.5.1, which will be fixed in separate pull requests. The document describes 0.5.1 as it is, so §8.7 records one of them: the Hybrid's Save weights writes a file that doesn't load.

Why

Contributors need a map of the code before they change it, and the README only describes the modules briefly. This also covers the documentation_architecture criterion of the OpenSSF Best Practices silver badge.

Testing

  • The document was checked claim by claim against the code.
  • Every diagram renders without errors in light and dark themes and fits GitHub's page width.
  • Every relative link, anchor and image path in the changed files resolves.
  • cargo clippy --locked --release --all-targets -- -D warnings, its wasm32 counterpart and cargo test --locked --release pass.

The layout the app called T-Junction is now T-Intersection. The README,
docs/insights.md and a comment in the renderer follow suit, and the
paragraphs that grew are rewrapped. The comment in .gitattributes now
says "Normalize".

Signed-off-by: Jim Schreckengast <schreck@gmail.com>
Scripted runs can now set TS_OVERLAYS (the overlays to show), TS_SELECT
(a vehicle to select), TS_BENCH (start the controller or sensor
benchmark) and TS_SCROLL_LEFT (the left panel's scroll offset).

With TS_SHOT set, the clock now stops at TS_SHOT_AFTER and the capture
waits 600 ms for the panels to refresh, so every capture of the same run
shows the same moment. None of this has any effect unless the variables
are set.

Signed-off-by: Jim Schreckengast <schreck@gmail.com>
docs/architecture.md explains how Intersection Lab 0.5.1 fits together.
It covers the layers, the boundary between ground truth and what
controllers see, what each source file does and the order of one
simulation step. It then describes the controllers and the learning
code, gives an illustrated tour of the app and covers the build, CI and
release pipeline. Section 13 lists where to change the code to add a
controller, a layout or a sensor, and Appendix A says how each
screenshot was made.

It has 21 Mermaid diagrams, 40 screenshots and three figures, which are
in docs/images/architecture/. The README and CONTRIBUTING.md link to it.

Signed-off-by: Jim Schreckengast <schreck@gmail.com>
@schreck61
schreck61 enabled auto-merge (rebase) November 11, 2026 12:55
@schreck61
schreck61 merged commit 24248e3 into main Nov 11, 2026
12 checks passed
@schreck61
schreck61 deleted the architecture-doc branch November 11, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant