# vmvarela/ztd architecture

> Architecture diagram of the GitHub repository vmvarela/ztd, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vmvarela/ztd
- Repository: https://github.com/vmvarela/ztd

## Overview

ZTD is a local, single-user task and continuity system for people working with an AI agent. Its main workflow captures an inbox note, processes it into an outcome such as work items, commits priorities to a plan, and prepares a read-only daily brief. The product also supports focus sessions, reviews, routines, knowledge and documents, source ingestion, provenance tracing, database preservation, and a local stdio MCP interface. The README documents these capabilities and the database as the authority; source excerpts do not include the Zig runtime, so internal call ownership beyond those documented flows is not inferred.

Main entry points: [`src/cli.zig`](https://github.com/vmvarela/ztd/blob/master/src/cli.zig) (Command interface), [`src/mcp.zig`](https://github.com/vmvarela/ztd/blob/master/src/mcp.zig) (Stdio MCP server), [`src/store/core.zig`](https://github.com/vmvarela/ztd/blob/master/src/store/core.zig) (SQLite store), [`src/install.zig`](https://github.com/vmvarela/ztd/blob/master/src/install.zig) (Asset installer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Interfaces"]
  node_cli["Command interface<br/>[cli.zig]"]
  node_mcp["Stdio MCP server<br/>[mcp.zig]"]
  node_installer["Asset installer<br/>[install.zig]"]
end

subgraph group_workflow["Task workflow"]
  node_capture["Capture inbox<br/>[cli.zig]"]
  node_process["Process outcomes<br/>[cli.zig]"]
  node_planning["Goals and plans<br/>[cli.zig]"]
  node_prepare["Daily prepare<br/>[cli.zig]"]
  node_focus["Focus sessions<br/>[cli.zig]"]
  node_routines["Routines<br/>[cli.zig]"]
end

subgraph group_knowledge["Continuity"]
  node_reviews["Reviews and metrics<br/>[cli.zig]"]
  node_knowledge_docs["Knowledge documents<br/>[cli.zig]"]
  node_sources["Source ingestion<br/>[cli.zig]"]
  node_provenance["Provenance trace<br/>[cli.zig]"]
  node_scope["Scopes and context<br/>[domain.zig]"]
end

subgraph group_persistence["Data and preservation"]
  node_store[("SQLite store<br/>[core.zig]")]
  node_preservation["Export and snapshots<br/>[cli.zig]"]
end

node_person(("Person or agent"))

node_person -->|"runs commands"| node_cli
node_person -->|"connects over stdio"| node_mcp
node_cli -->|"captures notes"| node_capture
node_cli -->|"processes inbox"| node_process
node_cli -->|"commits plans"| node_planning
node_cli -->|"reads brief"| node_prepare
node_cli -->|"runs sessions"| node_focus
node_cli -->|"tracks routines"| node_routines
node_cli -->|"records reviews"| node_reviews
node_cli -->|"manages documents"| node_knowledge_docs
node_cli -->|"feeds batches"| node_sources
node_cli -->|"traces links"| node_provenance
node_cli -->|"binds commands"| node_scope
node_cli -->|"reads and writes"| node_store
node_mcp -.->|"uses database authority"| node_store
node_cli -->|"exports and snapshots"| node_preservation
node_person -->|"publishes assets"| node_installer

click node_cli "https://github.com/vmvarela/ztd/blob/master/src/cli.zig"
click node_mcp "https://github.com/vmvarela/ztd/blob/master/src/mcp.zig"
click node_capture "https://github.com/vmvarela/ztd/blob/master/src/cli.zig"
click node_process "https://github.com/vmvarela/ztd/blob/master/src/cli.zig"
click node_planning "https://github.com/vmvarela/ztd/blob/master/src/cli.zig"
click node_prepare "https://github.com/vmvarela/ztd/blob/master/src/cli.zig"
click node_focus "https://github.com/vmvarela/ztd/blob/master/src/cli.zig"
click node_routines "https://github.com/vmvarela/ztd/blob/master/src/cli.zig"
click node_reviews "https://github.com/vmvarela/ztd/blob/master/src/cli.zig"
click node_knowledge_docs "https://github.com/vmvarela/ztd/blob/master/src/cli.zig"
click node_sources "https://github.com/vmvarela/ztd/blob/master/src/cli.zig"
click node_provenance "https://github.com/vmvarela/ztd/blob/master/src/cli.zig"
click node_scope "https://github.com/vmvarela/ztd/blob/master/src/domain.zig"
click node_store "https://github.com/vmvarela/ztd/blob/master/src/store/core.zig"
click node_preservation "https://github.com/vmvarela/ztd/blob/master/src/cli.zig"
click node_installer "https://github.com/vmvarela/ztd/blob/master/src/install.zig"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_mcp,node_installer toneBlue
class node_capture,node_process,node_planning,node_prepare,node_focus,node_routines toneAmber
class node_reviews,node_knowledge_docs,node_sources,node_provenance,node_scope toneMint
class node_store,node_preservation toneRose
class node_person toneIndigo
```

## Components

### Interfaces

- [Command interface](https://github.com/vmvarela/ztd/blob/master/src/cli.zig): `src/cli.zig`
- [Stdio MCP server](https://github.com/vmvarela/ztd/blob/master/src/mcp.zig): `src/mcp.zig`
- [Asset installer](https://github.com/vmvarela/ztd/blob/master/src/install.zig): `src/install.zig`

### Task workflow

- [Capture inbox](https://github.com/vmvarela/ztd/blob/master/src/cli.zig): `src/cli.zig`
- [Process outcomes](https://github.com/vmvarela/ztd/blob/master/src/cli.zig): `src/cli.zig`
- [Goals and plans](https://github.com/vmvarela/ztd/blob/master/src/cli.zig): `src/cli.zig`
- [Daily prepare](https://github.com/vmvarela/ztd/blob/master/src/cli.zig): `src/cli.zig`
- [Focus sessions](https://github.com/vmvarela/ztd/blob/master/src/cli.zig): `src/cli.zig`
- [Routines](https://github.com/vmvarela/ztd/blob/master/src/cli.zig): `src/cli.zig`

### Continuity

- [Reviews and metrics](https://github.com/vmvarela/ztd/blob/master/src/cli.zig): `src/cli.zig`
- [Knowledge documents](https://github.com/vmvarela/ztd/blob/master/src/cli.zig): `src/cli.zig`
- [Source ingestion](https://github.com/vmvarela/ztd/blob/master/src/cli.zig): `src/cli.zig`
- [Provenance trace](https://github.com/vmvarela/ztd/blob/master/src/cli.zig): `src/cli.zig`
- [Scopes and context](https://github.com/vmvarela/ztd/blob/master/src/domain.zig): `src/domain.zig`

### Data and preservation

- [SQLite store](https://github.com/vmvarela/ztd/blob/master/src/store/core.zig): `src/store/core.zig`
- [Export and snapshots](https://github.com/vmvarela/ztd/blob/master/src/cli.zig): `src/cli.zig`

### Other components

- **Person or agent**

## Connections

- Person or agent → Command interface: runs commands (evidence: `README.md`)
- Person or agent → Stdio MCP server: connects over stdio (evidence: `README.md`)
- Command interface → Capture inbox: captures notes (evidence: `README.md`)
- Command interface → Process outcomes: processes inbox (evidence: `README.md`)
- Command interface → Goals and plans: commits plans (evidence: `README.md`)
- Command interface → Daily prepare: reads brief (evidence: `README.md`)
- Command interface → Focus sessions: runs sessions (evidence: `README.md`)
- Command interface → Routines: tracks routines (evidence: `README.md`)
- Command interface → Reviews and metrics: records reviews (evidence: `README.md`)
- Command interface → Knowledge documents: manages documents (evidence: `README.md`)
- Command interface → Source ingestion: feeds batches (evidence: `README.md`)
- Command interface → Provenance trace: traces links (evidence: `README.md`)
- Command interface → Scopes and context: binds commands (evidence: `README.md`)
- Command interface → SQLite store: reads and writes (evidence: `README.md`)
- Stdio MCP server → SQLite store: uses database authority
- Command interface → Export and snapshots: exports and snapshots (evidence: `README.md`)
- Person or agent → Asset installer: publishes assets (evidence: `README.md`)
