# tashfeenahmed/circlechat architecture

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

- Interactive diagram: https://gitdiagram.com/tashfeenahmed/circlechat
- Repository: https://github.com/tashfeenahmed/circlechat

## Overview

CircleChat is a team chat where people and sandboxed CLI agents collaborate, with tools mediated by a gateway and risky actions subject to approval. The main workflow is a person messaging in the web chat, the client calling the server API, and the server runtime coordinating agent work, tool access, and shared state. The README also documents substantial side capabilities including tasks and memory, pages, files, browser automation, integrations, mailbox bridges, and schedules. Some feature implementations were not sampled; their placement follows the repository tree and documented capabilities, and uncertain links are omitted or marked dashed.

Main entry points: [`server/src/app.ts`](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/app.ts) (Application wiring), [`server/src/agents/runtime.ts`](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/agents/runtime.ts) (Agent runtime), [`server/src/gateway.ts`](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/gateway.ts) (Tool gateway), [`server/src/api.ts`](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/api.ts) (API routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web experience"]
  node_webapp["Web app and screens<br/>[App.tsx]"]
  node_chat["Group chat<br/>[Chats.tsx]"]
  node_clientstate["Client state<br/>[store.tsx]"]
  node_apiclient["JSON API client<br/>[api.ts]"]
end

subgraph group_server["Application core"]
  node_server["HTTP server<br/>[server.ts]"]
  node_api["API routes<br/>[api.ts]"]
  node_app["Application wiring<br/>[app.ts]"]
  node_services["Team services<br/>[services.ts]"]
  node_database[("SQLite store<br/>[db.ts]")]
  node_vault["Encrypted vault<br/>[crypto.ts]"]
  node_bus["Live event bus<br/>[bus.ts]"]
end

subgraph group_agents["Agent execution"]
  node_runtime["Agent runtime<br/>[runtime.ts]"]
  node_engines["Agent engines<br/>[engines.ts]"]
  node_gateway["Tool gateway<br/>[gateway.ts]"]
  node_approvals["Action approvals<br/>[approvals.ts]"]
end

subgraph group_capabilities["Team capabilities"]
  node_files["Shared files<br/>[files.ts]"]
  node_pages["Living pages<br/>[pages.ts]"]
  node_triggers["Schedules and watches<br/>[triggers.ts]"]
  node_browser["Sandboxed browser<br/>[manager.ts]"]
  node_tasks["Task board<br/>[Tasks.tsx]"]
  node_memory["Team memory<br/>[Memory.tsx]"]
end

subgraph group_integrations["External connections"]
  node_apps["App integrations<br/>[apps.ts]"]
  node_composio["Composio catalog<br/>[composio.ts]"]
  node_mailbox["Agent mailboxes<br/>[mailbox.ts]"]
  node_bridges["Slack and Telegram<br/>[slack.ts]"]
end

node_person(("Team member"))
node_external{{"External tools and services"}}

node_person -->|"sends message"| node_chat
node_chat -->|"updates state"| node_clientstate
node_clientstate -->|"calls API"| node_apiclient
node_apiclient -.->|"sends requests"| node_api
node_server -->|"routes requests"| node_api
node_server -->|"starts app"| node_app
node_app -->|"constructs runtime"| node_runtime
node_runtime -->|"selects engines"| node_engines
node_runtime -->|"requests tools"| node_gateway
node_runtime -->|"uses services"| node_services
node_runtime -->|"checks actions"| node_approvals
node_app -->|"constructs gateway"| node_gateway
node_app -->|"constructs services"| node_services
node_app -->|"opens database"| node_database
node_app -->|"constructs vault"| node_vault
node_app -->|"constructs bus"| node_bus
node_services -->|"reads and writes"| node_database
node_services -.->|"publishes events"| node_bus
node_gateway -.->|"uses secrets"| node_vault
node_gateway -.->|"requests approval"| node_approvals
node_runtime -->|"handles agent files"| node_files
node_app -->|"constructs page store"| node_pages
node_app -->|"wires triggers"| node_triggers
node_app -->|"wires browser"| node_browser
node_api -.->|"serves task features"| node_tasks
node_api -.->|"serves memory features"| node_memory
node_gateway -.->|"dispatches app tools"| node_apps
node_apps -.->|"offers extended catalog"| node_composio
node_mailbox -.->|"connects mail"| node_external
node_bridges -.->|"bridges messaging"| node_external
node_gateway -.->|"mediates tool access"| node_external

click node_webapp "https://github.com/tashfeenahmed/circlechat/blob/main/web/src/App.tsx"
click node_chat "https://github.com/tashfeenahmed/circlechat/blob/main/web/src/screens/Chats.tsx"
click node_clientstate "https://github.com/tashfeenahmed/circlechat/blob/main/web/src/store.tsx"
click node_apiclient "https://github.com/tashfeenahmed/circlechat/blob/main/web/src/api.ts"
click node_server "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/server.ts"
click node_api "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/api.ts"
click node_app "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/app.ts"
click node_runtime "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/agents/runtime.ts"
click node_engines "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/agents/engines.ts"
click node_gateway "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/gateway.ts"
click node_approvals "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/approvals.ts"
click node_services "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/services.ts"
click node_database "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/db.ts"
click node_vault "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/crypto.ts"
click node_bus "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/bus.ts"
click node_files "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/files.ts"
click node_pages "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/pages.ts"
click node_triggers "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/triggers.ts"
click node_browser "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/browser/manager.ts"
click node_tasks "https://github.com/tashfeenahmed/circlechat/blob/main/web/src/screens/Tasks.tsx"
click node_memory "https://github.com/tashfeenahmed/circlechat/blob/main/web/src/screens/Memory.tsx"
click node_apps "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/apps.ts"
click node_composio "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/composio.ts"
click node_mailbox "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/bridges/mailbox.ts"
click node_bridges "https://github.com/tashfeenahmed/circlechat/blob/main/server/src/bridges/slack.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_webapp,node_chat,node_clientstate,node_apiclient toneBlue
class node_server,node_api,node_app,node_services,node_database,node_vault,node_bus toneAmber
class node_runtime,node_engines,node_gateway,node_approvals toneMint
class node_files,node_pages,node_triggers,node_browser,node_tasks,node_memory toneRose
class node_apps,node_composio,node_mailbox,node_bridges,node_person,node_external toneIndigo
```

## Components

### Web experience

- [Web app and screens](https://github.com/tashfeenahmed/circlechat/blob/main/web/src/App.tsx): `web/src/App.tsx`
- [Group chat](https://github.com/tashfeenahmed/circlechat/blob/main/web/src/screens/Chats.tsx): `web/src/screens/Chats.tsx`
- [Client state](https://github.com/tashfeenahmed/circlechat/blob/main/web/src/store.tsx): `web/src/store.tsx`
- [JSON API client](https://github.com/tashfeenahmed/circlechat/blob/main/web/src/api.ts): `web/src/api.ts`

### Application core

- [HTTP server](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/server.ts): `server/src/server.ts`
- [API routes](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/api.ts): `server/src/api.ts`
- [Application wiring](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/app.ts): `server/src/app.ts`
- [Team services](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/services.ts): `server/src/services.ts`
- [SQLite store](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/db.ts): `server/src/db.ts`
- [Encrypted vault](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/crypto.ts): `server/src/crypto.ts`
- [Live event bus](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/bus.ts): `server/src/bus.ts`

### Agent execution

- [Agent runtime](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/agents/runtime.ts): `server/src/agents/runtime.ts`
- [Agent engines](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/agents/engines.ts): `server/src/agents/engines.ts`
- [Tool gateway](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/gateway.ts): `server/src/gateway.ts`
- [Action approvals](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/approvals.ts): `server/src/approvals.ts`

### Team capabilities

- [Shared files](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/files.ts): `server/src/files.ts`
- [Living pages](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/pages.ts): `server/src/pages.ts`
- [Schedules and watches](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/triggers.ts): `server/src/triggers.ts`
- [Sandboxed browser](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/browser/manager.ts): `server/src/browser/manager.ts`
- [Task board](https://github.com/tashfeenahmed/circlechat/blob/main/web/src/screens/Tasks.tsx): `web/src/screens/Tasks.tsx`
- [Team memory](https://github.com/tashfeenahmed/circlechat/blob/main/web/src/screens/Memory.tsx): `web/src/screens/Memory.tsx`

### External connections

- [App integrations](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/apps.ts): `server/src/apps.ts`
- [Composio catalog](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/composio.ts): `server/src/composio.ts`
- [Agent mailboxes](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/bridges/mailbox.ts): `server/src/bridges/mailbox.ts`
- [Slack and Telegram](https://github.com/tashfeenahmed/circlechat/blob/main/server/src/bridges/slack.ts): `server/src/bridges/slack.ts`

### Other components

- **Team member**
- **External tools and services**

## Connections

- Team member → Group chat: sends message
- Group chat → Client state: updates state (evidence: `web/src/screens/Chats.tsx`)
- Client state → JSON API client: calls API (evidence: `web/src/store.tsx`)
- JSON API client → API routes: sends requests (evidence: `web/src/api.ts`)
- HTTP server → API routes: routes requests (evidence: `server/src/server.ts`)
- HTTP server → Application wiring: starts app (evidence: `server/src/server.ts`)
- Application wiring → Agent runtime: constructs runtime (evidence: `server/src/app.ts`)
- Agent runtime → Agent engines: selects engines (evidence: `server/src/agents/runtime.ts`)
- Agent runtime → Tool gateway: requests tools (evidence: `server/src/agents/runtime.ts`)
- Agent runtime → Team services: uses services (evidence: `server/src/agents/runtime.ts`)
- Agent runtime → Action approvals: checks actions (evidence: `server/src/agents/runtime.ts`)
- Application wiring → Tool gateway: constructs gateway (evidence: `server/src/app.ts`)
- Application wiring → Team services: constructs services (evidence: `server/src/app.ts`)
- Application wiring → SQLite store: opens database (evidence: `server/src/app.ts`)
- Application wiring → Encrypted vault: constructs vault (evidence: `server/src/app.ts`)
- Application wiring → Live event bus: constructs bus (evidence: `server/src/app.ts`)
- Team services → SQLite store: reads and writes (evidence: `server/src/services.ts`)
- Team services → Live event bus: publishes events (evidence: `server/src/services.ts`)
- Tool gateway → Encrypted vault: uses secrets
- Tool gateway → Action approvals: requests approval
- Agent runtime → Shared files: handles agent files (evidence: `server/src/agents/runtime.ts`)
- Application wiring → Living pages: constructs page store (evidence: `server/src/app.ts`)
- Application wiring → Schedules and watches: wires triggers (evidence: `server/src/app.ts`)
- Application wiring → Sandboxed browser: wires browser (evidence: `server/src/app.ts`)
- API routes → Task board: serves task features
- API routes → Team memory: serves memory features
- Tool gateway → App integrations: dispatches app tools
- App integrations → Composio catalog: offers extended catalog
- Agent mailboxes → External tools and services: connects mail
- Slack and Telegram → External tools and services: bridges messaging
- Tool gateway → External tools and services: mediates tool access
