# vlukyanets/titan architecture

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

- Interactive diagram: https://gitdiagram.com/vlukyanets/titan
- Repository: https://github.com/vlukyanets/titan

## Overview

TITAN is a self-hosted personal AI assistant: users chat through a CLI, while backend services provide authentication and isolated data access. The README describes task, habit, memory and planning capabilities; the supplied excerpts do not show their domain-specific implementation, so these are represented at the documented subsystem level. The backend’s main evidenced request path is app-to-data-server, with domain operations and internal account operations handled separately. Migration validation and role management form a distinct database-safety layer.

Main entry points: [`backend/src/titan/data/server.py`](https://github.com/vlukyanets/titan/blob/master/backend/src/titan/data/server.py) (Data HTTP service), [`backend/src/titan/api/app.py`](https://github.com/vlukyanets/titan/blob/master/backend/src/titan/api/app.py) (Login and token API), [`backend/src/titan/migrate/run.py`](https://github.com/vlukyanets/titan/blob/master/backend/src/titan/migrate/run.py) (Migration runner), [`cli`](https://github.com/vlukyanets/titan/tree/master/cli) (Chat CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User interface"]
  node_cli["Chat CLI"]
  node_domains["Tasks, habits, memory, planning"]
end

subgraph group_api["Authentication API"]
  node_app["Login and token API<br/>[app.py]"]
  node_limits["Login rate limits<br/>[limits.py]"]
  node_core_client["Core HTTP client<br/>[core.py]"]
  node_accounts["Account name rules<br/>[accounts.py]"]
end

subgraph group_data["Data services"]
  node_data_server["Data HTTP service<br/>[server.py]"]
  node_domain_ops["Domain operations<br/>[apply.py]"]
  node_catalog["Domain table catalog<br/>[catalog.py]"]
  node_account_ops["Core account operations<br/>[core_ops.py]"]
  node_postgres[("PostgreSQL database")]
end

subgraph group_safety["Database safety"]
  node_migrate["Migration runner<br/>[run.py]"]
  node_schema_checks["Domain schema checks<br/>[checks.py]"]
  node_role_manager["Data role management<br/>[roles.py]"]
  node_table_rules["Shared table rules<br/>[tables.py]"]
end

node_user(("Assistant user"))

node_user -->|"chats through"| node_cli
node_cli -.->|"uses backend"| node_app
node_app -->|"checks login limits"| node_limits
node_app -->|"calls core"| node_core_client
node_app -->|"validates names"| node_accounts
node_core_client -->|"posts core operations"| node_data_server
node_data_server -->|"applies batches"| node_domain_ops
node_data_server -->|"applies core operation"| node_account_ops
node_data_server -->|"passes catalog"| node_catalog
node_domain_ops -->|"reads and writes"| node_postgres
node_account_ops -.->|"reads and writes"| node_postgres
node_migrate -->|"runs checks"| node_schema_checks
node_migrate -->|"manages role"| node_role_manager
node_schema_checks -->|"uses table rules"| node_table_rules
node_role_manager -->|"uses role rules"| node_table_rules
node_migrate -.->|"checks and migrates"| node_postgres
node_domains -.->|"stores user data"| node_data_server

click node_cli "https://github.com/vlukyanets/titan/tree/master/cli"
click node_domains "https://github.com/vlukyanets/titan/tree/master/domains"
click node_app "https://github.com/vlukyanets/titan/blob/master/backend/src/titan/api/app.py"
click node_limits "https://github.com/vlukyanets/titan/blob/master/backend/src/titan/api/limits.py"
click node_core_client "https://github.com/vlukyanets/titan/blob/master/backend/src/titan/api/core.py"
click node_accounts "https://github.com/vlukyanets/titan/blob/master/backend/src/titan/core/accounts.py"
click node_data_server "https://github.com/vlukyanets/titan/blob/master/backend/src/titan/data/server.py"
click node_domain_ops "https://github.com/vlukyanets/titan/blob/master/backend/src/titan/data/apply.py"
click node_catalog "https://github.com/vlukyanets/titan/blob/master/backend/src/titan/data/catalog.py"
click node_account_ops "https://github.com/vlukyanets/titan/blob/master/backend/src/titan/data/core_ops.py"
click node_migrate "https://github.com/vlukyanets/titan/blob/master/backend/src/titan/migrate/run.py"
click node_schema_checks "https://github.com/vlukyanets/titan/blob/master/backend/src/titan/migrate/checks.py"
click node_role_manager "https://github.com/vlukyanets/titan/blob/master/backend/src/titan/migrate/roles.py"
click node_table_rules "https://github.com/vlukyanets/titan/blob/master/backend/src/titan/core/tables.py"

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_domains,node_user toneBlue
class node_app,node_limits,node_core_client,node_accounts toneAmber
class node_data_server,node_domain_ops,node_catalog,node_account_ops,node_postgres toneMint
class node_migrate,node_schema_checks,node_role_manager,node_table_rules toneRose
```

## Components

### User interface

- [Chat CLI](https://github.com/vlukyanets/titan/tree/master/cli): `cli`
- [Tasks, habits, memory, planning](https://github.com/vlukyanets/titan/tree/master/domains): `domains`

### Authentication API

- [Login and token API](https://github.com/vlukyanets/titan/blob/master/backend/src/titan/api/app.py): `backend/src/titan/api/app.py`
- [Login rate limits](https://github.com/vlukyanets/titan/blob/master/backend/src/titan/api/limits.py): `backend/src/titan/api/limits.py`
- [Core HTTP client](https://github.com/vlukyanets/titan/blob/master/backend/src/titan/api/core.py): `backend/src/titan/api/core.py`
- [Account name rules](https://github.com/vlukyanets/titan/blob/master/backend/src/titan/core/accounts.py): `backend/src/titan/core/accounts.py`

### Data services

- [Data HTTP service](https://github.com/vlukyanets/titan/blob/master/backend/src/titan/data/server.py): `backend/src/titan/data/server.py`
- [Domain operations](https://github.com/vlukyanets/titan/blob/master/backend/src/titan/data/apply.py): `backend/src/titan/data/apply.py`
- [Domain table catalog](https://github.com/vlukyanets/titan/blob/master/backend/src/titan/data/catalog.py): `backend/src/titan/data/catalog.py`
- [Core account operations](https://github.com/vlukyanets/titan/blob/master/backend/src/titan/data/core_ops.py): `backend/src/titan/data/core_ops.py`
- **PostgreSQL database**

### Database safety

- [Migration runner](https://github.com/vlukyanets/titan/blob/master/backend/src/titan/migrate/run.py): `backend/src/titan/migrate/run.py`
- [Domain schema checks](https://github.com/vlukyanets/titan/blob/master/backend/src/titan/migrate/checks.py): `backend/src/titan/migrate/checks.py`
- [Data role management](https://github.com/vlukyanets/titan/blob/master/backend/src/titan/migrate/roles.py): `backend/src/titan/migrate/roles.py`
- [Shared table rules](https://github.com/vlukyanets/titan/blob/master/backend/src/titan/core/tables.py): `backend/src/titan/core/tables.py`

### Other components

- **Assistant user**

## Connections

- Assistant user → Chat CLI: chats through (evidence: `README.md`)
- Chat CLI → Login and token API: uses backend (evidence: `README.md`)
- Login and token API → Login rate limits: checks login limits (evidence: `backend/src/titan/api/app.py`)
- Login and token API → Core HTTP client: calls core (evidence: `backend/src/titan/api/app.py`)
- Login and token API → Account name rules: validates names (evidence: `backend/src/titan/api/app.py`)
- Core HTTP client → Data HTTP service: posts core operations (evidence: `backend/src/titan/api/core.py`)
- Data HTTP service → Domain operations: applies batches (evidence: `backend/src/titan/data/server.py`)
- Data HTTP service → Core account operations: applies core operation (evidence: `backend/src/titan/data/server.py`)
- Data HTTP service → Domain table catalog: passes catalog (evidence: `backend/src/titan/data/server.py`)
- Domain operations → PostgreSQL database: reads and writes (evidence: `backend/src/titan/data/apply.py`)
- Core account operations → PostgreSQL database: reads and writes
- Migration runner → Domain schema checks: runs checks (evidence: `backend/src/titan/migrate/run.py`)
- Migration runner → Data role management: manages role (evidence: `backend/src/titan/migrate/run.py`)
- Domain schema checks → Shared table rules: uses table rules (evidence: `backend/src/titan/migrate/checks.py`)
- Data role management → Shared table rules: uses role rules (evidence: `backend/src/titan/migrate/roles.py`)
- Migration runner → PostgreSQL database: checks and migrates
- Tasks, habits, memory, planning → Data HTTP service: stores user data (evidence: `README.md`)
