Architecture
The rules are in COLLABORATION.md, under Code hygiene and Architecture.
Backend packages
| Package | Holds |
|---|---|
| api/ | routes by domain under api/routes/, the contract (contract.py), guards, errors, static files; no business logic |
| cli/ | the bobine command, a pure HTTP client on the standard library, commands declared in cli/specs/ |
| outputs/ | the canonical table of outputs (registry.py), modes and shared metadata |
| playback/, radio/, signage/ | video and audio playback engines, radio per output, the visuals loop |
| scheduling/ | occurrences, launches, scheduled tasks, recovery after a restart |
| updates/ | GitHub lookups, versions, artifacts, Android guard, scheduled updates |
| catalog/, metrics/, media_assets/, videos/ | paged SQL catalog, metrics, the shared core of backgrounds and visuals, the video library |
| inputs/, network/, host/, paths/, process/ | input table, network and mDNS, host detection, data paths, subprocesses |
| hardware/, devices/, storage/, desktop/ | system domains, drivers per platform behind a registry |
| config_apply/, reference/ | JSON appliers per domain, export of the command and API reference |
| models/, database/ | SQLAlchemy models by domain, engine, sessions, idempotent migrations, foreign keys |
| utils/ | helpers without a domain of their own; never a new catch-all |
Splitting code
Python: a module that grows becomes a package of the same name; a service class splits into mixins (playback/, radio/, storage/service/); routes form a package, one router without prefix per module, included by init.py with the original prefix and tag, fixed paths before parameter paths. A test that patches an attribute patches it in the module that reads the name.
TypeScript: components by domain under components/domain/, hooks useX.ts beside them, pure computations in lib/ tested by node –test. React hooks without lint exceptions. Imperative logic with closures (player, socket, follower) lives in module functions on an explicit state, not in a factory of closures. Top-level branches of a component are render functions, not components, when the old code reused the same element, otherwise React unmounts and the page jumps.
Proving a split
| Change | Proof |
|---|---|
| moved CSS | no inversion in the cascade order, zero rendering difference on a bench of two isolated backends |
| components and pure functions | old source against new, states injected, seeded generator |
| hooks and effects | old and new effect bodies run with fake WebSocket, timers, clock, document, fetch and media elements; operation logs compared; sensitivity proven by two to four mutations |
| Python and Rust | AST comparison, old and new binaries compared |
The CSS cascade follows the import order of styles/index.css, without @layer or per-page CSS.