Architecture Overview
This is the front door of the Developer Guide. It is for contributors who change Tack and integrators who build on it. After reading it you will know why the code is layered the way it is, how a request travels through it, where the other two guides stop, and which page to read next.
Three pages share the architecture, and each owns one thing. This page owns the why: the layering rule, the item model and the paths a request and a live event take. The Crate Tour owns where things live, file by file. docs/ARCHITECTURE.md owns the boundaries: what each crate may hold and name, and the rules that hold across crates. Where they disagree, docs/ARCHITECTURE.md wins.
How the three guides fit
| Guide | Reader | Where it stops |
|---|---|---|
| User Guide | Someone who works in Tack every day | It says what a control does and what you will see. It never names a crate, a file or a function |
| Administrator Guide | Someone who installs, secures, runs and recovers Tack and its runners | It says how to set it up and fix it. It points here for why a rule exists |
| Developer Guide (this one) | A contributor or integrator | It says how the code is built, what the contract is, how to extend it and why it was decided |
A user page that needs a setting points to the Administrator Guide for how to set it. An administrator page that needs a rule points here for why. This guide never repeats step-by-step instructions for end users.
A map of this guide
| Page | Read it to |
|---|---|
| This page | See why the code is layered, the item model, a request's path and the live board channel |
| Crate Tour | Find the file that owns a behaviour, crate by crate |
docs/ARCHITECTURE.md | Check what a crate may hold and name, and the implementation rules that hold across crates |
| Runs, Teams and Automation | Follow an automatic run from a waiting task to a merge, and see how docket teams, the ceiling, usage and recurrence are built |
| The Runner Contract | Write or change a runner, or an adapter for an agent |
| The Project File Format | Produce, check or extend the file that carries a whole project |
| Frontend & Design System | Work on the SolidJS app and its design tokens |
| Adding Features | Follow a recipe for a new entity, a workflow preset or a project-file key |
| MCP Server | Use or extend the stdio server for assistants |
| API Reference | Look up a route (generated from docs/openapi.json) |
| Testing | Run the suites and know where a new test belongs |
| Architecture Decisions | Find the ADR behind a behaviour |
| Learning Path | Learn Rust, async, Axum, sqlx and SolidJS as you need them |
Where to start
- Read this page to the end.
- Skim the Crate Tour for the crate you will touch.
- Read Runs, Teams and Automation if you work on runs, agents or merging, or The Project File Format if you work on import and export.
- Read the six records listed in Architecture Decisions.
- Before your first change, read Testing and run
.githooks/pre-push(the gate a push must pass).
Why a board and a runner
They are separate because they scale and fail differently. One board, many runners: a board on a small VPS dispatches to runners on ten developers' machines, each with its own agent, model and capacity. A runner that dies mid-run cannot corrupt the board: its lease expires and its fencing token stops writing. A board that restarts cannot lose a run: the runner's journal knows what it started. One developer runs both in one process with one command, on the same contract, with the same recovery.
The rest of this page explains why the code is structured the way it is: the reasoning behind each layer, how a request travels through the system, and where the interesting domain logic lives.
1. The Layering Rule
Tack enforces a strict one-way dependency graph across the workspace's crates:
tack-protocol -> (none)
tack-core -> tack-protocol
tack-orch -> tack-protocol tack-core
tack-db -> tack-protocol tack-core
tack-app -> tack-protocol tack-core tack-orch tack-db
tack-api -> tack-protocol tack-core tack-db tack-app
tack-runner -> tack-protocol tack-core
tack-cli -> tack-api tack-app tack-runner tack-db tack-protocol tack-core
tack-test-support -> tack-protocol tack-core tack-db
tack-evals -> tack-test-support
Each line lists what a crate may depend on. scripts/check-crate-graph.sh --print prints exactly this, and the check fails on any other normal dependency. No reverse edges are allowed. scripts/arch-facts.sh prints the crate, route, migration and test counts, so this page quotes none of them.
Two crates stand apart. tack-test-support holds test helpers and is a dependency of the others' tests only. tack-evals is a development tool that is never released, and nothing depends on it. An eleventh crate, tack-desktop, is deliberately excluded from the workspace (its own Cargo.toml and lockfile) because Tauri drags GTK/WebKit/glib into whatever workspace holds it; the Crate Tour says how it supervises tack instead of linking against it.
What each crate may hold and name is in docs/ARCHITECTURE.md. Three consequences matter for the rest of this page:
- Rules live below the I/O.
tack-protocol,tack-coreandtack-orchdo no I/O, so every rule in them is a pure function over plain values. - Names are fenced. Only
tack-dbnamessqlxand onlytack-apinamesaxum. Every storage call fails withStoreError, and every handler extracts, calls atack-appuse case or atack-dbmethod, maps the error and responds. - The CLI is a client.
tack-cliis the singletackbinary and the composition root:serve.rsbuilds theRepository, hands it to the server and spawns the background ticks. Its client commands only talk to a running server over HTTP, so the CLI works whether the server is local or remote.tack-runneris a separate binary that speaks runner-v1 totack-apithe same way a remote runner does, and never depends ontack-dbortack-api.
Why bother? The layering prevents the kind of "everything knows about everything" entanglement that makes codebases brittle. It also means:
- Workflow rules are always consistent. Because all validation lives in
tack-core, neither a direct DB call nor an API call nor a CLI command can bypass it. - Tests are fast. Core tests are pure function calls — no test database, no async runtime, no cleanup.
- The domain model can be reused. If a future project needs the same workflow engine, it can depend on
tack-corewithout dragging in SQLite or Axum.
2. The Universal Item Model
Every piece of work in Tack — whether it is called a task, an epic, a bug, a work order, or an assignment — is stored as an Item. There is one table, one struct, one set of repository functions.
The Item struct in tack-core/src/models.rs carries an item_type field that records what kind of thing it is: a key of the project's type catalog. The catalog (tack-core/src/item_types.rs, table item_types) is data of the project, not an enum. Each type has a key, a name, a colour and a level, group or work, and exactly one type is the project's default work type. A software project's catalog has Epic (a group) and Feature, Task, Bug and Requirement (work); a construction project's has Building and Section (groups) and Work Order, Activity, Defect and Specification (work). The level drives the tree rule (tack-core/src/hierarchy.rs): a type that holds work never goes under work, the tree has at most five levels and no loops, and an item can be moved under another parent at any time by that same rule. The vocabulary system translates the other ten words (sprint, backlog, …) into whatever label the project uses.
Think of it like a spreadsheet: every row has the same columns. The header labels change depending on who is looking at the sheet. A construction project calls its default work type Work Order and sprint Phase, but the underlying row structure is identical.
Benefits:
- One migration path. Adding a new field to items (say, a
story_pointscolumn) means one migration, one struct update, one set of repository functions — not separate migrations per item type. - Hierarchy is one table. Because every item can have a
parent_idpointing to another item, the tree falls out of that column without a separate parent-type/child-type mapping. A type's level is what the tree reads: a type at levelgroupholds groups and work, work holds work, and an item with children is a group whatever its type (ADR 0036, decisions 10 and 11). "Subtask" is not a type; it is work under work. - Filtering is uniform. The same
ItemFilterstruct handles filtering byitem_type,status,priority,assignee, or tag regardless of project type.
The tradeoff is that the item_type field carries less compile-time enforcement than an enum would. This is intentional — a project names its own types, and the store checks that an item's key is in its project's catalog inside the write's transaction.
3. How a Request Flows Through the System
Here is a concrete walk-through of PATCH /api/items/{id} — the endpoint that moves an item to a new status.
HTTP client
│
▼
Axum router (tack-api/src/router.rs)
│ Extracts: Path(item_id), State(AppState), Json(UpdateItem)
▼
Handler: update_item (tack-api/src/handlers/items.rs)
│ 1. Validates the body, then loads repo.get_item_snapshot(id) and checks If-Match
│ 2. Calls repo.get_project(project_id) to load the workflow
│ 3. Calls repo.update_item_atomically(id, input, &workflow, &Hierarchy, expected_version),
│ which inside one transaction asks the workflow (StatusGate: validate_transition and
│ check_wip_limit) and the tree rule (ParentGate) ← all pure, no I/O in tack-core
│ 4. after_update(...) then: state.events().emit(DomainEvent::item_changed(...)) ← the bus,
│ and with it the WebSocket event
│ 5. create_next_recurrence(...) ← a repeating task that reached Done makes its successor
│ 6. maybe_sync_github(...) and, for a task moved to Done, merge::on_done(...)
▼
Repository (tack-db/src/repo/items.rs)
│ Runs parameterised SQL via sqlx
▼
SQLite
│
◀── Result<Item, StoreError>
│
Handler maps error → ApiError → HTTP response
│
▼
HTTP client receives JSON
A few things worth noting:
- Step 3 calls pure functions in
tack-core. No extra database round-trip is needed to validate the transition: the entire workflow config was loaded with the project in step 2, and it lives in memory as aWorkflowConfigstruct. The repository runs the checks in the same transaction as the write, so a rejected move leaves the item's version untouched. - The handler owns the orchestration. It decides the order of validation, persistence, and notification. The repository and the core crate do not know about each other.
- Errors propagate upward via Rust's
?operator. TheApiErrortype (intack-api/src/error.rs) implementsIntoResponse, giving every failure aStableErrorCode(one per rule ofCoreError), which decides the HTTP status and is in the body ascode.
4. How Workflow Validation Works
The workflow for a project is a WorkflowConfig struct stored as JSON in the projects table. When the server loads a project, it deserialises that JSON back into the struct — no extra tables, no joins.
The WorkflowConfig holds:
- A list of
StatusDefentries (name, category, optional WIP limit, sort order). - An optional list of
Transitionpairs (from,to).
validate_transition(from, to) does two things:
- Checks that both
fromandtoexist in the status list. - If an explicit transition list exists, checks that the pair is in it.
If the transition list is absent (None), any move between two valid statuses is allowed. This is the Scrum and Kanban default. The construction workflow, by contrast, defines an explicit list — you cannot skip from Permit to Handover.
Why is this in tack-core and not in the database layer?
Because it is a business rule, not a storage rule. The database does not know what statuses are valid — that is configuration data stored in a JSON column. Only tack-core knows how to interpret that configuration and enforce the rules. Putting the validation in the repository would mean the repository would need to import workflow logic, violating the layer boundary. Putting it in the handler (without core) would scatter the logic and make it untestable without a running server.
By living in tack-core, the validation is:
- Testable with zero dependencies (its tests never touch a database).
- Reusable by any layer that loads a
WorkflowConfig. - Independent of how the config was persisted.
5. How Real-Time Updates Work
The real-time board feature uses a Tokio broadcast channel. Here is the architecture:
AppState
└── broadcast_tx: broadcast::Sender<BoardEvent> (capacity: 100)
On an item change:
handler emits a DomainEvent through state.events()
└── the adapter in tack-api/src/ports.rs calls broadcast_event(&state, BoardEvent::ItemUpdated { ... })
└── state.broadcast_tx.send(event) ← non-blocking, drops if no subscribers
On WebSocket connection (GET /api/projects/{id}/boards/live):
handler upgrades the connection
spawns two tasks:
send_task: rx.recv() in a loop → filter by project_id → send JSON to client
recv_task: reads messages from client (ignores all but Close)
tokio::select! on both tasks — whichever ends first, the other is aborted
The broadcast channel is the pub/sub backbone. Every handler that modifies an item emits a domain event, and the adapter sends the browser's share of it; a run or a decision has no browser message. Every WebSocket connection subscribes to the channel and filters events by project_id before forwarding them to the client.
Important properties:
- Fire and forget.
broadcast_tx.send()returns immediately whether or not there are subscribers. If nobody is listening, the event is dropped. This keeps the write path fast. - Per-project filtering happens in the send task. The channel carries events for all projects; each WebSocket connection only forwards events that match its
project_id. This keeps the channel logic simple while allowing one channel to serve many concurrent connections. - No persistence. Events are not stored. A client that disconnects and reconnects will not receive missed events — it will simply see the current board state on the next page load.