# orzfly/todou architecture

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

- Interactive diagram: https://gitdiagram.com/orzfly/todou
- Repository: https://github.com/orzfly/todou

## Overview

todou is a self-hostable issue tracker for people and AI agents. Users work through the web app or CLI; requests reach the API, which authenticates them and operates on project data and attachments. Issues support comments, labels, questions, and versioned spec review; search and cursor-based SSE watching extend the workflow. The CLI also resolves server/project configuration and agent-session context. The graph preserves documented capabilities, but many route and UI implementations were not sampled, so some documented links are cited to the README rather than inferred from source.

Main entry points: [`projects/server/src/app.ts`](https://github.com/orzfly/todou/blob/master/projects/server/src/app.ts) (HTTP API), [`projects/cli/src/commands`](https://github.com/orzfly/todou/tree/master/projects/cli/src/commands) (CLI commands), [`projects/web/src`](https://github.com/orzfly/todou/tree/master/projects/web/src) (Web app), [`projects/shared/src/client.ts`](https://github.com/orzfly/todou/blob/master/projects/shared/src/client.ts) (Shared API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User clients"]
  node_web["Web app"]
  node_cli["CLI commands"]
  node_cli_config["CLI configuration<br/>[config.ts]"]
  node_cli_context["CLI context resolution<br/>[context.ts]"]
  node_harness["Agent harness detection<br/>[index.ts]"]
end

subgraph group_server["API and identity"]
  node_api["HTTP API<br/>[app.ts]"]
  node_auth["Authentication<br/>[middleware.ts]"]
end

subgraph group_domain["Issue workflows"]
  node_issues["Issues and projects<br/>[issues.ts]"]
  node_specs["Spec review<br/>[spec.ts]"]
  node_questions["Structured questions<br/>[inbox.ts]"]
  node_search["Search<br/>[search.ts]"]
  node_watch["SSE watch<br/>[sse.ts]"]
  node_agents["Agent accounts<br/>[agents.ts]"]
  node_attachments["Attachments<br/>[attachments.ts]"]
end

subgraph group_data["Persistence and events"]
  node_db_router["Database routing<br/>[router.ts]"]
  node_database[("Project and system databases<br/>[system-schema.ts]")]
  node_storage["Blob storage<br/>[types.ts]"]
  node_events["Event bus<br/>[bus.ts]"]
end

subgraph group_shared["Shared contracts"]
  node_client["Shared API client<br/>[client.ts]"]
  node_schemas["Shared schemas<br/>[common.ts]"]
end

node_people(("People and agents"))

node_people -->|"uses"| node_web
node_people -->|"uses"| node_cli
node_web -.->|"requests"| node_api
node_cli -.->|"requests"| node_api
node_cli -->|"loads config"| node_cli_config
node_cli -->|"resolves context"| node_cli_context
node_cli_context -->|"detects harness"| node_harness
node_api -->|"authenticates"| node_auth
node_api -.->|"routes requests"| node_issues
node_api -->|"routes requests"| node_specs
node_api -.->|"routes requests"| node_questions
node_api -->|"routes requests"| node_search
node_api -->|"routes requests"| node_watch
node_api -->|"routes requests"| node_agents
node_api -->|"routes requests"| node_attachments
node_api -->|"uses context"| node_db_router
node_db_router -->|"opens databases"| node_database
node_attachments -.->|"stores blobs"| node_storage
node_api -->|"provides event bus"| node_events
node_web -.->|"uses API client"| node_client
node_cli -->|"uses API client"| node_client
node_client -.->|"uses contracts"| node_schemas
node_people -.->|"reviews versions"| node_specs
node_people -.->|"answers questions"| node_questions
node_people -.->|"watches updates"| node_watch
node_people -.->|"creates accounts"| node_agents

click node_web "https://github.com/orzfly/todou/tree/master/projects/web/src"
click node_cli "https://github.com/orzfly/todou/tree/master/projects/cli/src/commands"
click node_cli_config "https://github.com/orzfly/todou/blob/master/projects/cli/src/config.ts"
click node_cli_context "https://github.com/orzfly/todou/blob/master/projects/cli/src/context.ts"
click node_harness "https://github.com/orzfly/todou/blob/master/projects/cli/src/harness/index.ts"
click node_api "https://github.com/orzfly/todou/blob/master/projects/server/src/app.ts"
click node_auth "https://github.com/orzfly/todou/blob/master/projects/server/src/auth/middleware.ts"
click node_issues "https://github.com/orzfly/todou/blob/master/projects/server/src/routes/issues.ts"
click node_specs "https://github.com/orzfly/todou/blob/master/projects/server/src/routes/spec.ts"
click node_questions "https://github.com/orzfly/todou/blob/master/projects/server/src/routes/inbox.ts"
click node_search "https://github.com/orzfly/todou/blob/master/projects/server/src/routes/search.ts"
click node_watch "https://github.com/orzfly/todou/blob/master/projects/server/src/routes/sse.ts"
click node_agents "https://github.com/orzfly/todou/blob/master/projects/server/src/routes/agents.ts"
click node_attachments "https://github.com/orzfly/todou/blob/master/projects/server/src/routes/attachments.ts"
click node_db_router "https://github.com/orzfly/todou/blob/master/projects/server/src/db/router.ts"
click node_database "https://github.com/orzfly/todou/blob/master/projects/server/src/db/system-schema.ts"
click node_storage "https://github.com/orzfly/todou/blob/master/projects/server/src/storage/types.ts"
click node_events "https://github.com/orzfly/todou/blob/master/projects/server/src/events/bus.ts"
click node_client "https://github.com/orzfly/todou/blob/master/projects/shared/src/client.ts"
click node_schemas "https://github.com/orzfly/todou/blob/master/projects/shared/src/schemas/common.ts"

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_web,node_cli,node_cli_config,node_cli_context,node_harness toneBlue
class node_api,node_auth toneAmber
class node_issues,node_specs,node_questions,node_search,node_watch,node_agents,node_attachments toneMint
class node_db_router,node_database,node_storage,node_events toneRose
class node_client,node_schemas,node_people toneIndigo
```

## Components

### User clients

- [Web app](https://github.com/orzfly/todou/tree/master/projects/web/src): `projects/web/src`
- [CLI commands](https://github.com/orzfly/todou/tree/master/projects/cli/src/commands): `projects/cli/src/commands`
- [CLI configuration](https://github.com/orzfly/todou/blob/master/projects/cli/src/config.ts): `projects/cli/src/config.ts`
- [CLI context resolution](https://github.com/orzfly/todou/blob/master/projects/cli/src/context.ts): `projects/cli/src/context.ts`
- [Agent harness detection](https://github.com/orzfly/todou/blob/master/projects/cli/src/harness/index.ts): `projects/cli/src/harness/index.ts`

### API and identity

- [HTTP API](https://github.com/orzfly/todou/blob/master/projects/server/src/app.ts): `projects/server/src/app.ts`
- [Authentication](https://github.com/orzfly/todou/blob/master/projects/server/src/auth/middleware.ts): `projects/server/src/auth/middleware.ts`

### Issue workflows

- [Issues and projects](https://github.com/orzfly/todou/blob/master/projects/server/src/routes/issues.ts): `projects/server/src/routes/issues.ts`
- [Spec review](https://github.com/orzfly/todou/blob/master/projects/server/src/routes/spec.ts): `projects/server/src/routes/spec.ts`
- [Structured questions](https://github.com/orzfly/todou/blob/master/projects/server/src/routes/inbox.ts): `projects/server/src/routes/inbox.ts`
- [Search](https://github.com/orzfly/todou/blob/master/projects/server/src/routes/search.ts): `projects/server/src/routes/search.ts`
- [SSE watch](https://github.com/orzfly/todou/blob/master/projects/server/src/routes/sse.ts): `projects/server/src/routes/sse.ts`
- [Agent accounts](https://github.com/orzfly/todou/blob/master/projects/server/src/routes/agents.ts): `projects/server/src/routes/agents.ts`
- [Attachments](https://github.com/orzfly/todou/blob/master/projects/server/src/routes/attachments.ts): `projects/server/src/routes/attachments.ts`

### Persistence and events

- [Database routing](https://github.com/orzfly/todou/blob/master/projects/server/src/db/router.ts): `projects/server/src/db/router.ts`
- [Project and system databases](https://github.com/orzfly/todou/blob/master/projects/server/src/db/system-schema.ts): `projects/server/src/db/system-schema.ts`
- [Blob storage](https://github.com/orzfly/todou/blob/master/projects/server/src/storage/types.ts): `projects/server/src/storage/types.ts`
- [Event bus](https://github.com/orzfly/todou/blob/master/projects/server/src/events/bus.ts): `projects/server/src/events/bus.ts`

### Shared contracts

- [Shared API client](https://github.com/orzfly/todou/blob/master/projects/shared/src/client.ts): `projects/shared/src/client.ts`
- [Shared schemas](https://github.com/orzfly/todou/blob/master/projects/shared/src/schemas/common.ts): `projects/shared/src/schemas/common.ts`

### Other components

- **People and agents**

## Connections

- People and agents → Web app: uses (evidence: `README.md`)
- People and agents → CLI commands: uses (evidence: `README.md`)
- Web app → HTTP API: requests
- CLI commands → HTTP API: requests
- CLI commands → CLI configuration: loads config
- CLI commands → CLI context resolution: resolves context
- CLI context resolution → Agent harness detection: detects harness (evidence: `projects/cli/src/context.ts`)
- HTTP API → Authentication: authenticates (evidence: `projects/server/src/app.ts`)
- HTTP API → Issues and projects: routes requests (evidence: `projects/server/src/app.ts`)
- HTTP API → Spec review: routes requests (evidence: `projects/server/src/app.ts`)
- HTTP API → Structured questions: routes requests (evidence: `projects/server/src/app.ts`)
- HTTP API → Search: routes requests (evidence: `projects/server/src/app.ts`)
- HTTP API → SSE watch: routes requests (evidence: `projects/server/src/app.ts`)
- HTTP API → Agent accounts: routes requests (evidence: `projects/server/src/app.ts`)
- HTTP API → Attachments: routes requests (evidence: `projects/server/src/app.ts`)
- HTTP API → Database routing: uses context
- Database routing → Project and system databases: opens databases (evidence: `projects/server/src/db/router.ts`)
- Attachments → Blob storage: stores blobs
- HTTP API → Event bus: provides event bus
- Web app → Shared API client: uses API client
- CLI commands → Shared API client: uses API client
- Shared API client → Shared schemas: uses contracts
- People and agents → Spec review: reviews versions (evidence: `README.md`)
- People and agents → Structured questions: answers questions (evidence: `README.md`)
- People and agents → SSE watch: watches updates (evidence: `README.md`)
- People and agents → Agent accounts: creates accounts (evidence: `README.md`)
