# zayonx-0/chatisen architecture

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

- Interactive diagram: https://gitdiagram.com/zayonx-0/chatisen
- Repository: https://github.com/zayonx-0/chatisen

## Overview

ChatISEN is a real-time chat product with two runtime profiles: a local standalone server and a Compose target built around a TypeScript API and PostgreSQL. The main user journey is account access, finding or creating a conversation, sending messages, and receiving updates; group conversations and call signaling are additional stages. The graph separates those domain stages from persistence, transport, and client layers. The README documents more Compose integrations than the excerpts verify, so LiveKit is shown as optional and unverified; the Compose profile’s full operation is not demonstrated.

Main entry points: [`apps/api/src/server.ts`](https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/server.ts) (Fastify entry), [`apps/api/src/identity/postgres-routes.ts`](https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/identity/postgres-routes.ts) (Identity and sessions), [`apps/api/src/repositories/postgres.ts`](https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/repositories/postgres.ts) (Postgres repository), [`apps/standalone/server.mjs`](https://github.com/zayonx-0/chatisen/blob/main/apps/standalone/server.mjs) (Local server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_standalone["Standalone profile"]
  node_standalone_server["Local server<br/>[server.mjs]"]
  node_push["Push delivery<br/>[push.mjs]"]
end

subgraph group_api["Compose API"]
  node_api_server["Fastify entry<br/>[server.ts]"]
  node_identity["Identity and sessions<br/>[postgres-routes.ts]"]
  node_chat_routes["Conversation and messages<br/>[postgres-routes.ts]"]
  node_group_ops["Group operations"]
  node_calls["Call signaling<br/>[postgres-routes.ts]"]
  node_event_stream["WebSocket events"]
  node_security["Password and CSRF<br/>[security.ts]"]
  node_metrics["API metrics<br/>[metrics.ts]"]
end

subgraph group_data["Persistence"]
  node_repository["Postgres repository<br/>[postgres.ts]"]
  node_memory_store["Memory store<br/>[store.ts]"]
  node_postgres[("PostgreSQL<br/>[001_initial.sql]")]
end

subgraph group_clients["Clients"]
  node_react_client["Compose web client<br/>[main.tsx]"]
  node_standalone_client["Standalone web client<br/>[app.js]"]
  node_service_worker["Browser notifications<br/>[sw.js]"]
end

subgraph group_integrations["Realtime integrations"]
  node_livekit["LiveKit service"]
  node_webrtc["Peer WebRTC"]
end

node_user(("Chat participant"))
node_browser(("Browser"))

node_user -->|"uses"| node_browser
node_browser -->|"loads"| node_standalone_client
node_browser -->|"uses"| node_react_client
node_standalone_client -->|"requests"| node_standalone_server
node_react_client -->|"requests"| node_api_server
node_standalone_server -->|"creates"| node_push
node_standalone_server -->|"serves"| node_standalone_client
node_standalone_server -->|"signals calls"| node_webrtc
node_api_server -->|"registers"| node_identity
node_api_server -->|"registers"| node_chat_routes
node_api_server -->|"registers"| node_event_stream
node_api_server -->|"registers"| node_calls
node_api_server -->|"creates"| node_repository
node_api_server -->|"uses"| node_memory_store
node_api_server -->|"uses"| node_security
node_api_server -->|"records"| node_metrics
node_identity -->|"reads/writes"| node_repository
node_identity -->|"hashes and checks"| node_security
node_chat_routes -->|"reads/writes"| node_repository
node_chat_routes -->|"uses"| node_group_ops
node_chat_routes -->|"authenticates with"| node_identity
node_calls -->|"reads/writes"| node_repository
node_calls -->|"authenticates with"| node_identity
node_event_stream -->|"reads events"| node_repository
node_event_stream -->|"authenticates with"| node_identity
node_repository -.->|"queries"| node_postgres
node_standalone_server -.->|"stores separately"| node_postgres
node_push -->|"sends notifications"| node_browser
node_service_worker -.->|"displays notifications"| node_browser
node_calls -.->|"optional media"| node_livekit

click node_standalone_server "https://github.com/zayonx-0/chatisen/blob/main/apps/standalone/server.mjs"
click node_push "https://github.com/zayonx-0/chatisen/blob/main/apps/standalone/push.mjs"
click node_api_server "https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/server.ts"
click node_identity "https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/identity/postgres-routes.ts"
click node_chat_routes "https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/chat/postgres-routes.ts"
click node_group_ops "https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/chat/group-operations.ts"
click node_calls "https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/calls/postgres-routes.ts"
click node_event_stream "https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/chat/postgres-websocket.ts"
click node_security "https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/security.ts"
click node_metrics "https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/metrics.ts"
click node_repository "https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/repositories/postgres.ts"
click node_memory_store "https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/store.ts"
click node_postgres "https://github.com/zayonx-0/chatisen/blob/main/db/migrations/001_initial.sql"
click node_react_client "https://github.com/zayonx-0/chatisen/blob/main/apps/web/src/main.tsx"
click node_standalone_client "https://github.com/zayonx-0/chatisen/blob/main/apps/web/public/app.js"
click node_service_worker "https://github.com/zayonx-0/chatisen/blob/main/apps/web/public/sw.js"

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_standalone_server,node_push,node_browser toneBlue
class node_api_server,node_identity,node_chat_routes,node_group_ops,node_calls,node_event_stream,node_security,node_metrics toneAmber
class node_repository,node_memory_store,node_postgres toneMint
class node_react_client,node_standalone_client,node_service_worker toneRose
class node_livekit,node_webrtc,node_user toneIndigo
```

## Components

### Standalone profile

- [Local server](https://github.com/zayonx-0/chatisen/blob/main/apps/standalone/server.mjs): `apps/standalone/server.mjs`
- [Push delivery](https://github.com/zayonx-0/chatisen/blob/main/apps/standalone/push.mjs): `apps/standalone/push.mjs`

### Compose API

- [Fastify entry](https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/server.ts): `apps/api/src/server.ts`
- [Identity and sessions](https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/identity/postgres-routes.ts): `apps/api/src/identity/postgres-routes.ts`
- [Conversation and messages](https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/chat/postgres-routes.ts): `apps/api/src/chat/postgres-routes.ts`
- [Group operations](https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/chat/group-operations.ts): `apps/api/src/chat/group-operations.ts`
- [Call signaling](https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/calls/postgres-routes.ts): `apps/api/src/calls/postgres-routes.ts`
- [WebSocket events](https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/chat/postgres-websocket.ts): `apps/api/src/chat/postgres-websocket.ts`
- [Password and CSRF](https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/security.ts): `apps/api/src/security.ts`
- [API metrics](https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/metrics.ts): `apps/api/src/metrics.ts`

### Persistence

- [Postgres repository](https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/repositories/postgres.ts): `apps/api/src/repositories/postgres.ts`
- [Memory store](https://github.com/zayonx-0/chatisen/blob/main/apps/api/src/store.ts): `apps/api/src/store.ts`
- [PostgreSQL](https://github.com/zayonx-0/chatisen/blob/main/db/migrations/001_initial.sql): `db/migrations/001_initial.sql`

### Clients

- [Compose web client](https://github.com/zayonx-0/chatisen/blob/main/apps/web/src/main.tsx): `apps/web/src/main.tsx`
- [Standalone web client](https://github.com/zayonx-0/chatisen/blob/main/apps/web/public/app.js): `apps/web/public/app.js`
- [Browser notifications](https://github.com/zayonx-0/chatisen/blob/main/apps/web/public/sw.js): `apps/web/public/sw.js`

### Realtime integrations

- **LiveKit service**
- **Peer WebRTC**

### Other components

- **Chat participant**
- **Browser**

## Connections

- Chat participant → Browser: uses (evidence: `README.md`)
- Browser → Standalone web client: loads (evidence: `README.md`)
- Browser → Compose web client: uses (evidence: `README.md`)
- Standalone web client → Local server: requests (evidence: `README.md`)
- Compose web client → Fastify entry: requests (evidence: `README.md`)
- Local server → Push delivery: creates (evidence: `apps/standalone/server.mjs`)
- Local server → Standalone web client: serves (evidence: `apps/standalone/server.mjs`)
- Local server → Peer WebRTC: signals calls (evidence: `README.md`)
- Fastify entry → Identity and sessions: registers (evidence: `apps/api/src/server.ts`)
- Fastify entry → Conversation and messages: registers (evidence: `apps/api/src/server.ts`)
- Fastify entry → WebSocket events: registers (evidence: `apps/api/src/server.ts`)
- Fastify entry → Call signaling: registers (evidence: `apps/api/src/server.ts`)
- Fastify entry → Postgres repository: creates (evidence: `apps/api/src/server.ts`)
- Fastify entry → Memory store: uses (evidence: `apps/api/src/server.ts`)
- Fastify entry → Password and CSRF: uses (evidence: `apps/api/src/server.ts`)
- Fastify entry → API metrics: records (evidence: `apps/api/src/server.ts`)
- Identity and sessions → Postgres repository: reads/writes (evidence: `apps/api/src/identity/postgres-routes.ts`)
- Identity and sessions → Password and CSRF: hashes and checks (evidence: `apps/api/src/identity/postgres-routes.ts`)
- Conversation and messages → Postgres repository: reads/writes (evidence: `apps/api/src/chat/postgres-routes.ts`)
- Conversation and messages → Group operations: uses (evidence: `apps/api/src/chat/postgres-routes.ts`)
- Conversation and messages → Identity and sessions: authenticates with (evidence: `apps/api/src/chat/postgres-routes.ts`)
- Call signaling → Postgres repository: reads/writes (evidence: `apps/api/src/calls/postgres-routes.ts`)
- Call signaling → Identity and sessions: authenticates with (evidence: `apps/api/src/calls/postgres-routes.ts`)
- WebSocket events → Postgres repository: reads events (evidence: `apps/api/src/chat/postgres-websocket.ts`)
- WebSocket events → Identity and sessions: authenticates with (evidence: `apps/api/src/chat/postgres-websocket.ts`)
- Postgres repository → PostgreSQL: queries
- Local server → PostgreSQL: stores separately
- Push delivery → Browser: sends notifications (evidence: `apps/standalone/push.mjs`)
- Browser notifications → Browser: displays notifications
- Call signaling → LiveKit service: optional media
