Inside the repository

Everything that runs this railroad, from the JMRI (Java Model Railroad Interface) tables to this website, is kept in one public git repository. This guide shows how it is laid out, where each fact lives, how the separate projects attach to it, and how a change reaches the layout.

The repository is github.com/lnevo/hart. It holds the JMRI tables and panels, the CATS (Crandic Automated Traffic System) dispatcher desks, the car records, the wiring documents, the scripts that build and check all of them, the decision records, and the source of this website. Six smaller projects with their own repositories are attached as submodules. The computers on the layout are installed from it, and none of them is a git checkout.

01The overview

The Mac holds the master copy. A change is made there, checked, merged into main and then deployed. Two deploys leave the repository: one installs the JMRI and CATS files on the layout computers, the other publishes the website. A few things are made on the layout itself during a session, such as a PanelPro Store or the positions of cars, and those come back into the repository by a pull command before the next deploy.

How the repository connects to everything else At the top, six submodules, each its own repository, pinned by commit. An arrow leads down to the hart repository on the Mac, which holds the facts, the tools, the wiki and the website source. From it, deploy arrows lead down to the layout Pi, which runs JMRI, CATS, the MQTT (Message Queuing Telemetry Transport) broker and the live STS; to the Windows PC, which runs JMRI, CATS and the LCOS (Layout Control Operating System) bridge; and a site deploy arrow leads to the website. A dashed arrow leads from the Pi back up to the repository, labelled pulls: Stores, sessions, STS backups. Six submodules · external/ their own repositories, pinned by commit The hart repository facts · tools · wiki · website source master copy on the Mac, where changes are made deploy deploy site deploy Layout Pi JMRI, CATS, broker live STS Windows PC JMRI, CATS LCOS bridge Website hartrailroad.com dashed: pulls back from the Pi (Stores, sessions, STS backups)
The repository in the middle. Solid arrows are deploys; the dashed one is what comes back from the layout.

Inside the repository, files fall into three kinds:

  • Sources of record. The one file that owns a fact, such as the tables file, the device master or the car repository. A change starts here.
  • Tools. Scripts that build copies from the sources, check that everything agrees, and deploy.
  • Generated files. Copies made by the tools, such as the two CATS desks, the crew documents and the website's data. Nobody edits these by hand; a fix goes into the source or the script that made them.

02The top-level folders

There are ten folders at the top, each with one purpose. A file that fits none of them is in the wrong place.

FolderWhat it holds
jmri/The layout's JMRI files: the tables file, the Operations Pro files, the layout data, and the scripts that build and check them. Also the icons and web pages JMRI uses.
cats/The CATS dispatcher desks only: the CTC and ABS desks built from the schematic, their scripts, and the reference panels they were modelled on.
ops/Operations: the car repository and its tools (ops/hart-ops/), station maps, car-card intake batches, and runbooks for the parts that run outside JMRI.
docs/Every document written for the railroad: wiring, CTC, benchwork, JMRI notes and the crew publications. docs/INDEX.md lists them, newest first.
www/The source of this website and the scripts that build and publish it.
tools/Repository-wide tools: the checks, the shared library, the AnyRail plan reader, the schematic and panel builders, host and deploy scripts, MQTT helpers and the LCOS mimic.
external/The six submodules, and the STS data folder.
wiki/Decision records, the live status of the railroad, and one page per pipeline.
media/Photos, video and research material. Kept on the Mac, not in git.
archive/Retired files, kept for reference, grouped into code/, data/ and history/. Nothing in it runs.

Three files sit at the top as well: README.md for people, AGENTS.md with the working rules for every AI tool, and a Makefile whose short commands (make lists them) run the real scripts.

03Where each fact lives

Each kind of fact has one file that owns it. Everything else that shows the same fact is built from that file or checked against it.

FactOwned byUsed by
JMRI setup: sensors, turnouts, blocks, masts, panelsGenerated: jmri/layouts/hart/output/tables.xml is written by tools/schematic/build_tables.py from the device master and a template, and a pulled PanelPro Store is split back into those sourcesEvery JMRI computer, the CATS desks, the tables browser on this site
Every device on all three levels: public name, hardware address, DCC address, control point, wiringjmri/layouts/hart/data/devices_field.csv (kept by hand) and devices_generated.csv (written by the generators), read as one by hartlib.devices and described column by column in devices.columns.csvThe tables, both desks, the wiring documents, the device viewer
Switches on every level: number, level, legs, hand, CTC leverswitches.csv in the same folder, one row per OS block or switch half, described column by column in switches.columns.csvThe panel builders, and a check against the Layout Editor, both desks and the parked USS board
Wiring: the node and port of every wired device (turnouts, feedback, fascia buttons, relays, signal heads, detectors)jmri/layouts/hart/data/wiring.csv, edited by hand; make wiring-freeze adds a main or upper control point's rows once it is wired. Until then the device map gives those levels a draft node and portThe device master, the wiring workbook and slides, comments in the tables, the wiring viewer
Track planThe AnyRail plan, version 5.3c, kept on the Mac and not in git. The schematic-maps plugin's schematic anyplan reads it into the schematic's inputs in jmri/layouts/hart/data/schematic/inputs/, and the plan lengths into block_lengths.csvThe schematic, and everything make panels builds from it, in order: the turnout hands, the signals, the device map, the main and upper masts, the schematic sheets and station pages, the CTC and ABS desks and the Layout Editor panel
Main and upper level devices: each one's JMRI name and the physical device it stands forThe main and upper rows of the device master, built from the schematic by build_device_map.pyThe tables, both desks and the schematic. JMRI runs these levels on internal devices named after each switch, block and mast; the map links each one to its planned field device, which is still a draft
Staging devices and mastsstations.csv in the schematic folder (its desk codes group the stations into the desk areas) and the device rows of the device master, whose wiring comes from wiring.csv. The masts are placed by the signal rule (ADR-024): build_device_map.py writes every level's mast and head rows of the device master, and build_masts.py writes every level's masts from them into masts.csv, with a level column. check_device_master.py --check checks them, with the main and upper rows of the device master, against tables.xmlThe Layout Editor panel, the signals and both desks
The fleetops/hart-ops/data/image_metadata.csvCar cards, STS, the Operations Pro roster, the photo pages
Operations Pro setupjmri/layouts/hart/operations/ (six files)Every JMRI computer
Where each car is and what it carriesThe live STS database on the PiJMRI Operations Pro, refreshed one way after each step

Moving a switch's legs is a change to one row of switches.csv, then a run of make panels. If the Layout Editor, a CATS desk and the parked USS board then disagree, the check fails and names the switch and both files.

The pipeline map draws the main source files, scripts and generated outputs in the repository and how they feed each other. Pick a file to see its chain, from the sources it is built from to the outputs built from it.

04The layout tree

Most of the railroad's control lives under jmri/layouts/hart/. There is one layout, hart; when the upper levels are added, the unit is the level, recorded in the level column of the switch files, not a second layout folder.

FolderWhat it holds
output/tables.xml, the one tables file, with all three panels in it
data/The device master, switch files, block lengths, control points, the schematic's inputs, and HART's settings for the STS-to-JMRI refresh
operations/The six Operations Pro files
roster/The DecoderPro roster: roster.xml and one entry file per loco, which the deploy installs on every host
scripts/54 scripts: most build, repair and check the tables on the Mac, and some run inside JMRI
ctc/, dispatcher/The USS CTC machine's icons and guide; the Dispatcher System's options and train files. Parked since the helix-join release (November 2026)
parked/The Entry/Exit, Dispatcher System and USS CTC data kept out of the active tables while those features are parked
anyrail/The AnyRail export the first panels were built from, kept for reference. The schematic now reads the plan itself (see Where each fact lives)

Two kinds of Python script live side by side here. Most run on the Mac in ordinary Python and read or write the files. The others run inside JMRI itself, from the Start Up list on each computer, such as the panel status and the STS car refresh. Those use JMRI's built-in Jython, which is Python 2, so they import nothing from the repository's shared code and run on any computer with JMRI installed.

cats/ works the same way on a smaller scale. A script writes the two desks the dispatchers use, CTC and ABS, from the schematic, and another validates them. make desks runs both.

05Shared code

The Mac-side scripts share one small library, hartlib, in tools/hartlib/. These are its four main parts; the rest (the DCC group of a JMRI comment, the device master, its dictionary and its checks, each device's ID, taken from the track plan rather than its name, what a build changes in the device master: new, gone and renamed devices, the owner's track names, kept by ID, and how they reach the schematic drawing, the template and the other parts the generated tables.xml is built from, the split of a pulled PanelPro Store back into the template and the device master, the CATS desk conventions, the parked features, the edits to a JMRI profile: startup actions, window sizes and preferences, the main and upper levels' device names, their control-point masts, the station maps' revision, the schematic's layer files, a section per sheet, the physical wiring source (wiring.csv), the main and upper blocks' JMRI numbers, from block_numbering.csv, the owner's hand lists: block overrides, main lines and the parked USS board, the railroad names in the data masters and the list of tables in code that hold railroad data, which device each piece of the drawing is, keyed by device ID, the pace of the panel and schematic films, an atomic file write and the list of tracked files, the Operations Pro rosters' cars, engines and trains, the signal coordinator script and the modules it loads, the stations and control points by id, as the devices and masts name them, the CATS desks' occupancy bindings, each block by its ID, each block's plan length and measured length, and the operating length the Dispatcher takes, the error classes every hartlib reader raises, the layout's levels (1, 2, 3) and their one parser, the typed keys that pair a Store's items with the template's, the device master's row checks, the switch list's rows, read and checked and the native SML QA's steps and the staging devices they drive) serve narrower jobs:

  • paths names every file the tools use: the tables file, the device master, the wiring table, the layout folders. A path always points into the checkout the script sits in.
  • tables loads and saves tables.xml. A load followed by a save with no edit writes the same bytes JMRI wrote, so a script that changes one sensor changes one sensor in the diff. It also knows the file's traps: sensors and turnouts split over several sections, every block written twice, two kinds of mast.
  • hosts holds the MQTT broker and the address of each layout computer, read from the environment, then a local settings file, then the defaults in tools/env/defaults.env. The shell scripts read the same settings in the same order.
  • railroad reads the fact files above once each and checks the rules between them, such as no main or upper switch reusing a staging switch number, and every main and upper device in the device map also being in tables.xml. The panel builders read their facts through it, and each builder may read only the files made before its own step, so none of them reads an old copy of what it is about to write. ./tools/check.sh runs its check.

The library is not installed. Each script finds it with two lines that walk up from the script's own folder, so a script always uses the copy beside it, and moving a script needs no edit. That matters because every change is made in a separate working copy (see Making a change); an installed library would point every copy at one of them. The scripts that run inside JMRI never import it.

06Submodules

A submodule is another git repository checked out inside this one. The hart repository records which commit of each one it uses, so a fresh clone with git clone --recurse-submodules, or make submodules after a pull, puts every one at the right version. All six live under external/ and all of them are public.

FolderWhat it isHow it connects
lcos-bridge/Firmware for the Arduino that listens to the LCOS radio nodes, and the bridge that turns their messages into MQTTThe bridge runs on the Windows PC and publishes to the broker on the Pi
sts-docker/The STS traffic simulator packaged to run in DockerThe Pi runs its release build as the live STS; the Mac runs a copy for testing
sts-plugins/Addons for STS: the track scale, coke orders, the JMRI refresh and HART's own settingsBuilt into the STS image
sts-helpers/Seeding, warm starts and switch lists for STSRun on the Mac, fed from the car repository
model-railroad-skills/Skills and plugins for AI coding agents: JMRI panels, signals, MQTT, CATS, STS, Operations Pro, car cards and the schematic drawingInstalled into the AI tools; the schematic plugin draws the panels and desks
jmri-cs105-roster-sync/Copies the JMRI roster into the TCS CS-105 command stationRun from tools/ops/ after a roster change

The rule for what becomes a submodule: a project another modeler could use on their own layout. Those projects carry nothing specific to this railroad. HART's values live in the hart repository and are loaded as settings, such as the STS-to-JMRI names in jmri/layouts/hart/data/sts_jmri_ops_settings.json, or kept in one clearly named place, such as the hart_layout plugin in sts-plugins. A test in sts-plugins fails if a HART name appears anywhere else.

A project that mostly reads and writes this railroad's own files stays in hart. The car tools, hart-ops, were a separate repository until November 2026. Nearly everything they read and write is in hart, so every change needed two pull requests, one in each repository. They now live in ops/hart-ops/, and their tests run with the rest.

Two folders look like submodules and are not. The STS data folder in external/ holds the simulator's database, backups and photos, outside git. The research scans are a private repository of their own, cloned separately into media/.

07What stays out of git

Some files are too large, too private or too changeable to track. They stay on the Mac, beside the repository, and the tools know where to find them:

  • Photos and video in media/, and the car photos in their own folder under ops/. The website build resizes them into the published site.
  • The STS database and backups in the STS data folder under external/, with copies of the live Pi data pulled there after each session.
  • CATS itself: the release and its source are downloaded by scripts in tools/cats/.
  • Local settings such as tools/env/hart.env, and any credentials.

A check, also run as a git hook before each commit, stops a private or ignored file from being added by mistake. Another reads every tracked file, Office documents included, for text that must not be published.

08From the repository to the railroad

Three computers run the layout. The Pi is production: it runs JMRI, the MQTT broker every client talks to, the CATS desks and the live STS. The Windows PC runs JMRI, CATS and the LCOS bridge. The Mac holds the repository and is where changes are tested and accepted before they reach the Pi.

The layout deploy

tools/hosts/sync_hart_package.sh builds a package from the repository for each computer and sends it: by rsync to the Pi, as one archive to Windows. The package is a subset, with the tables, panels, Operations files, JMRI scripts, CATS desks and launchers, and none of the documents or the website. On each computer it installs into JMRI_UserFiles, and every computer's JMRI loads its tables from there, so an install looks the same everywhere. Each install leaves a stamp naming the commit it shipped; make deploy-status reads them back.

What comes back

The repository is the master, so anything made on the layout has to be brought back before the next deploy replaces it:

CommandBrings back
make tables-pull-pi, make tables-pullA PanelPro Store on the Pi or the Mac, into tables.xml
make ops-pullThe Pi's Operations Pro state after a session
make sts-pullThe live STS backups and a database dump

The deploy stops if a Store or an Operations Pro session on the Pi has not been pulled. Pulled files are committed like any other change.

STS on the Pi

STS is the one exception to the package deploy. The Pi has its own clones of sts-docker and sts-plugins, and tools/hosts/pi_sts_update.sh updates it by a git pull and a rebuild there. A change is tried in a sandbox first, then on the Mac's copy, where it is accepted, and only then on the Pi.

The website

www/scripts/deploy_hartrailroad.sh builds the site from tracked files only, copies in the documents and pictures listed in www/scripts/published-files.json so the site holds no copies of its own, resizes the photos, checks every link, and publishes. It stops if the build has far fewer pages or photos than the last one.

09Making a change

The main checkout on the Mac stays on main, for pulls and deploys only. Each task gets its own working copy, a git worktree, made by make wt TOPIC=<topic>. It sits in .claude/worktrees/<topic>/ on its own branch, with links to the photo folders the website build needs. Several tasks can run at once without one switching the branch under another.

  1. Edit in the worktree.
  2. Check with ./tools/check.sh: about fifty checks and test suites, from the tables and signal logic to the car tools and the website links.
  3. Load it for real with make panelpro-test when the tables or panels changed. It opens the tables in PanelPro on the Mac and reports any error.
  4. Open a pull request. GitHub runs the same checks on a clean copy. main accepts a change only through a pull request whose checks pass.
  5. Merge and deploy. The worktree is removed automatically once the merge is half an hour old.

Hooks in .claude/hooks/ back these rules up for the AI tools. They stop a commit or push to main, and an edit in the main checkout. Cursor runs the same checks through its own hook file.

10Decisions and documents

Decisions are written down in wiki/decisions/ as short records, ADR-001 onward. Each says what was decided, why, and what it replaced, and a later change is added as a dated amendment. The layout of the folders above is ADR-007; the one tables file is ADR-008; the shared library and switch files are ADR-021; placing the signals by rule is ADR-024.

The rest of wiki/ is the railroad's current state: status/ for what is live, one file per entry, one page per pipeline in wiki/pipelines/ for how each thing is built, and a list of what is waiting on a person. Documents written for the railroad go in docs/. The working rules for AI tools are in one file, AGENTS.md; the Claude and Cursor settings point to it, and a check fails if it names a path that no longer exists.

The wiki home page, wiki/home.md, links to the decision records, the live status, the pipelines and every document.

NotesReferences

  1. The hart repository (GitHub). github.com/lnevo/hart
  2. The wiki home page, where to start reading. wiki/home.md
  3. ADR-007, Repository layout. wiki/decisions/ADR-007-repository-layout.md
  4. ADR-021, Shared library and switch facts. wiki/decisions/ADR-021-shared-library-and-switch-facts.md
  5. The hartlib README. tools/hartlib/README.md
  6. Sibling repositories and submodules. wiki/REPOS.md
  7. Git and worktree conventions. wiki/AGENTS_GIT.md

More: The tables file · The workshop · Bringing the Railroad Together · Behind the Scenes