# singhsanket143/chatupai architecture

> Architecture diagram of the GitHub repository singhsanket143/chatupai, 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/singhsanket143/chatupai
- Repository: https://github.com/singhsanket143/chatupai

## Overview

ChatUp is a chat application with a React interface and a FastAPI backend. Users identify themselves, select or create a thread, send messages, and receive streamed chat events; the interface also exposes thread history, compaction, and categorized memory. The backend routes requests through services and repositories, with agent runtime modules providing an internal agent layer. The excerpts show only part of the chat and memory implementations, so those internal links are omitted where their callers are not evidenced.

Main entry points: [`frontend/src/api.ts`](https://github.com/singhsanket143/chatupai/blob/main/frontend/src/api.ts) (API client), [`src/chatup/api/routers/chat.py`](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/api/routers/chat.py) (Chat routes), [`src/chatup/api/main.py`](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/api/main.py) (API application), [`frontend/src/App.tsx`](https://github.com/singhsanket143/chatupai/blob/main/frontend/src/App.tsx) (Chat workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Chat interface"]
  node_app["Chat workspace<br/>[App.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_message_view["Message display<br/>[MessageContent.tsx]"]
  node_activity_view["Activity display<br/>[ActivityPanel.tsx]"]
  node_memory_panel["Memory panel<br/>[MemoryPanel.tsx]"]
  node_memory_detail["Memory details"]
  node_memory_shared["Memory formatting<br/>[memoryShared.ts]"]
end

subgraph group_http["HTTP API"]
  node_api_app["API application<br/>[main.py]"]
  node_auth_route["Login route<br/>[auth.py]"]
  node_chat_route["Chat routes<br/>[chat.py]"]
  node_thread_route["Thread routes<br/>[threads.py]"]
  node_memory_route["Memory route<br/>[memory.py]"]
  node_health_route["Health route<br/>[health.py]"]
  node_dependencies["Request dependencies<br/>[deps.py]"]
  node_schemas["API schemas<br/>[api.py]"]
end

subgraph group_domain["Backend services"]
  node_chat_service["Chat service<br/>[chat.py]"]
  node_thread_service["Thread service<br/>[threads.py]"]
  node_user_service["User service<br/>[users.py]"]
end

subgraph group_storage["Persistence"]
  node_thread_repo["Thread repository<br/>[threads.py]"]
  node_user_repo["User repository<br/>[users.py]"]
  node_pool["Database pool<br/>[pool.py]"]
end

subgraph group_agent["Agent runtime"]
  node_runtime["Agent runtime<br/>[runtime.py]"]
  node_agent_build["Agent builder<br/>[build.py]"]
  node_agent_utils["Agent utilities<br/>[utils.py]"]
  node_memory_runtime["Memory runtime<br/>[memory_runtime.py]"]
end

node_person(("Chat user"))
node_database[("PostgreSQL")]

node_person -->|"uses"| node_app
node_app -->|"requests"| node_api_client
node_app -->|"renders"| node_message_view
node_app -->|"renders"| node_activity_view
node_app -->|"renders"| node_memory_panel
node_memory_panel -->|"opens"| node_memory_detail
node_memory_panel -->|"formats"| node_memory_shared
node_memory_detail -->|"formats"| node_memory_shared
node_memory_shared -->|"uses types"| node_api_client
node_api_client -->|"HTTP requests"| node_auth_route
node_api_client -->|"HTTP requests"| node_thread_route
node_api_client -->|"HTTP requests"| node_chat_route
node_api_client -->|"HTTP requests"| node_memory_route
node_api_app -->|"registers"| node_auth_route
node_api_app -->|"registers"| node_chat_route
node_api_app -->|"registers"| node_thread_route
node_api_app -->|"registers"| node_memory_route
node_api_app -->|"registers"| node_health_route
node_auth_route -->|"uses"| node_dependencies
node_auth_route -->|"validates"| node_schemas
node_auth_route -->|"calls"| node_user_service
node_thread_route -->|"uses"| node_dependencies
node_thread_route -->|"validates"| node_schemas
node_thread_route -->|"calls"| node_thread_service
node_chat_route -->|"uses"| node_dependencies
node_chat_route -->|"validates"| node_schemas
node_chat_route -->|"calls"| node_chat_service
node_chat_route -->|"touches thread"| node_thread_repo
node_thread_service -->|"calls"| node_thread_repo
node_thread_service -->|"calls"| node_user_repo
node_user_service -->|"uses"| node_user_repo
node_dependencies -->|"creates"| node_pool
node_pool -.->|"connects"| node_database
node_thread_repo -.->|"reads and writes"| node_database
node_user_repo -.->|"reads and writes"| node_database
node_runtime -->|"uses"| node_agent_build
node_runtime -->|"uses"| node_agent_utils
node_agent_build -.->|"builds for"| node_runtime

click node_app "https://github.com/singhsanket143/chatupai/blob/main/frontend/src/App.tsx"
click node_api_client "https://github.com/singhsanket143/chatupai/blob/main/frontend/src/api.ts"
click node_message_view "https://github.com/singhsanket143/chatupai/blob/main/frontend/src/MessageContent.tsx"
click node_activity_view "https://github.com/singhsanket143/chatupai/blob/main/frontend/src/ActivityPanel.tsx"
click node_memory_panel "https://github.com/singhsanket143/chatupai/blob/main/frontend/src/MemoryPanel.tsx"
click node_memory_detail "https://github.com/singhsanket143/chatupai/blob/main/frontend/src/MemoryDetailModal.tsx"
click node_memory_shared "https://github.com/singhsanket143/chatupai/blob/main/frontend/src/memoryShared.ts"
click node_api_app "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/api/main.py"
click node_auth_route "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/api/routers/auth.py"
click node_chat_route "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/api/routers/chat.py"
click node_thread_route "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/api/routers/threads.py"
click node_memory_route "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/api/routers/memory.py"
click node_health_route "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/api/routers/health.py"
click node_dependencies "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/api/deps.py"
click node_schemas "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/schemas/api.py"
click node_chat_service "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/services/chat.py"
click node_thread_service "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/services/threads.py"
click node_user_service "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/services/users.py"
click node_thread_repo "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/repositories/threads.py"
click node_user_repo "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/repositories/users.py"
click node_pool "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/repositories/pool.py"
click node_runtime "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/agents/runtime.py"
click node_agent_build "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/agents/build.py"
click node_agent_utils "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/agents/utils.py"
click node_memory_runtime "https://github.com/singhsanket143/chatupai/blob/main/src/chatup/agents/memory_runtime.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_app,node_api_client,node_message_view,node_activity_view,node_memory_panel,node_memory_detail,node_memory_shared,node_person toneBlue
class node_api_app,node_auth_route,node_chat_route,node_thread_route,node_memory_route,node_health_route,node_dependencies,node_schemas,node_database toneAmber
class node_chat_service,node_thread_service,node_user_service toneMint
class node_thread_repo,node_user_repo,node_pool toneRose
class node_runtime,node_agent_build,node_agent_utils,node_memory_runtime toneIndigo
```

## Components

### Chat interface

- [Chat workspace](https://github.com/singhsanket143/chatupai/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API client](https://github.com/singhsanket143/chatupai/blob/main/frontend/src/api.ts): `frontend/src/api.ts`
- [Message display](https://github.com/singhsanket143/chatupai/blob/main/frontend/src/MessageContent.tsx): `frontend/src/MessageContent.tsx`
- [Activity display](https://github.com/singhsanket143/chatupai/blob/main/frontend/src/ActivityPanel.tsx): `frontend/src/ActivityPanel.tsx`
- [Memory panel](https://github.com/singhsanket143/chatupai/blob/main/frontend/src/MemoryPanel.tsx): `frontend/src/MemoryPanel.tsx`
- [Memory details](https://github.com/singhsanket143/chatupai/blob/main/frontend/src/MemoryDetailModal.tsx): `frontend/src/MemoryDetailModal.tsx`
- [Memory formatting](https://github.com/singhsanket143/chatupai/blob/main/frontend/src/memoryShared.ts): `frontend/src/memoryShared.ts`

### HTTP API

- [API application](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/api/main.py): `src/chatup/api/main.py`
- [Login route](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/api/routers/auth.py): `src/chatup/api/routers/auth.py`
- [Chat routes](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/api/routers/chat.py): `src/chatup/api/routers/chat.py`
- [Thread routes](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/api/routers/threads.py): `src/chatup/api/routers/threads.py`
- [Memory route](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/api/routers/memory.py): `src/chatup/api/routers/memory.py`
- [Health route](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/api/routers/health.py): `src/chatup/api/routers/health.py`
- [Request dependencies](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/api/deps.py): `src/chatup/api/deps.py`
- [API schemas](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/schemas/api.py): `src/chatup/schemas/api.py`

### Backend services

- [Chat service](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/services/chat.py): `src/chatup/services/chat.py`
- [Thread service](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/services/threads.py): `src/chatup/services/threads.py`
- [User service](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/services/users.py): `src/chatup/services/users.py`

### Persistence

- [Thread repository](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/repositories/threads.py): `src/chatup/repositories/threads.py`
- [User repository](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/repositories/users.py): `src/chatup/repositories/users.py`
- [Database pool](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/repositories/pool.py): `src/chatup/repositories/pool.py`

### Agent runtime

- [Agent runtime](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/agents/runtime.py): `src/chatup/agents/runtime.py`
- [Agent builder](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/agents/build.py): `src/chatup/agents/build.py`
- [Agent utilities](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/agents/utils.py): `src/chatup/agents/utils.py`
- [Memory runtime](https://github.com/singhsanket143/chatupai/blob/main/src/chatup/agents/memory_runtime.py): `src/chatup/agents/memory_runtime.py`

### Other components

- **Chat user**
- **PostgreSQL**

## Connections

- Chat user → Chat workspace: uses
- Chat workspace → API client: requests (evidence: `frontend/src/App.tsx`)
- Chat workspace → Message display: renders (evidence: `frontend/src/App.tsx`)
- Chat workspace → Activity display: renders (evidence: `frontend/src/App.tsx`)
- Chat workspace → Memory panel: renders (evidence: `frontend/src/App.tsx`)
- Memory panel → Memory details: opens (evidence: `frontend/src/MemoryPanel.tsx`)
- Memory panel → Memory formatting: formats (evidence: `frontend/src/MemoryPanel.tsx`)
- Memory details → Memory formatting: formats (evidence: `frontend/src/MemoryDetailModal.tsx`)
- Memory formatting → API client: uses types (evidence: `frontend/src/memoryShared.ts`)
- API client → Login route: HTTP requests (evidence: `frontend/src/api.ts`)
- API client → Thread routes: HTTP requests (evidence: `frontend/src/api.ts`)
- API client → Chat routes: HTTP requests (evidence: `frontend/src/api.ts`)
- API client → Memory route: HTTP requests (evidence: `frontend/src/api.ts`)
- API application → Login route: registers (evidence: `src/chatup/api/main.py`)
- API application → Chat routes: registers (evidence: `src/chatup/api/main.py`)
- API application → Thread routes: registers (evidence: `src/chatup/api/main.py`)
- API application → Memory route: registers (evidence: `src/chatup/api/main.py`)
- API application → Health route: registers (evidence: `src/chatup/api/main.py`)
- Login route → Request dependencies: uses (evidence: `src/chatup/api/routers/auth.py`)
- Login route → API schemas: validates (evidence: `src/chatup/api/routers/auth.py`)
- Login route → User service: calls (evidence: `src/chatup/api/routers/auth.py`)
- Thread routes → Request dependencies: uses (evidence: `src/chatup/api/routers/threads.py`)
- Thread routes → API schemas: validates (evidence: `src/chatup/api/routers/threads.py`)
- Thread routes → Thread service: calls (evidence: `src/chatup/api/routers/threads.py`)
- Chat routes → Request dependencies: uses (evidence: `src/chatup/api/routers/chat.py`)
- Chat routes → API schemas: validates (evidence: `src/chatup/api/routers/chat.py`)
- Chat routes → Chat service: calls (evidence: `src/chatup/api/routers/chat.py`)
- Chat routes → Thread repository: touches thread (evidence: `src/chatup/api/routers/chat.py`)
- Thread service → Thread repository: calls (evidence: `src/chatup/services/threads.py`)
- Thread service → User repository: calls (evidence: `src/chatup/services/threads.py`)
- User service → User repository: uses (evidence: `src/chatup/services/users.py`)
- Request dependencies → Database pool: creates (evidence: `src/chatup/api/deps.py`)
- Database pool → PostgreSQL: connects
- Thread repository → PostgreSQL: reads and writes
- User repository → PostgreSQL: reads and writes
- Agent runtime → Agent builder: uses (evidence: `src/chatup/agents/runtime.py`)
- Agent runtime → Agent utilities: uses (evidence: `src/chatup/agents/runtime.py`)
- Agent builder → Agent runtime: builds for (evidence: `src/chatup/agents/runtime.py`)
