# seifmahmoud63/cto-copilot architecture

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

- Interactive diagram: https://gitdiagram.com/seifmahmoud63/cto-copilot
- Repository: https://github.com/seifmahmoud63/cto-copilot

## Overview

CTO Watch is an engineering-leadership dashboard backed by a FastAPI service. Users pass a password/TOTP access gate, then view GitHub pull-request intelligence and engineer impact, chat with a database-aware copilot, use a voice agent, or preview scheduled executive PDF reports. The graph preserves those documented product branches and the storage and AI layers. Some routes and service implementations were only sampled or indexed, so those links are limited to relationships shown in excerpts or stated in the README.

Main entry points: [`app/api/routes.py`](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/api/routes.py) (HTTP and WebSocket API), [`app/services/github_service.py`](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/github_service.py) (GitHub PR intelligence), [`app/services/report_service.py`](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/report_service.py) (Daily report generation), [`app/services/llm_service.py`](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/llm_service.py) (Summary LLM routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access"]
  node_auth_gate["Private-route gate<br/>[auth_gate.py]"]
  node_auth_api["Login endpoints<br/>[auth.py]"]
  node_auth_service["Password and TOTP<br/>[auth_service.py]"]
end

subgraph group_insight["PR Intelligence"]
  node_github["GitHub PR intelligence<br/>[github_service.py]"]
  node_jev["JEV impact model<br/>[jev_service.py]"]
  node_llm["Summary LLM routing<br/>[llm_service.py]"]
  node_breaker["LLM circuit breaker<br/>[circuit_breaker.py]"]
end

subgraph group_copilot["AI Copilots"]
  node_chat["LangGraph chat agent<br/>[chat_service.py]"]
  node_voice["Live voice agent<br/>[voice_service.py]"]
end

subgraph group_reports["Executive Reports"]
  node_celery["Report task scheduler<br/>[celery_app.py]"]
  node_report["Daily report generation<br/>[report_service.py]"]
  node_pdf["Report PDF<br/>[report_service.py]"]
end

subgraph group_data["Data Layer"]
  node_db_service["Persistence operations<br/>[db_service.py]"]
  node_session["Async DB sessions<br/>[session.py]"]
  node_mysql[("MySQL records")]
end

node_leaders(("Engineering leaders"))
node_web["CTO Watch dashboard<br/>[app.js]"]
node_api["HTTP and WebSocket API<br/>[routes.py]"]
node_bedrock{{"Amazon Bedrock"}}
node_groq{{"Groq fallback"}}
node_github_external{{"GitHub API"}}
node_deepgram{{"Deepgram agent"}}
node_redis["Redis task broker"]

node_leaders -->|"uses"| node_web
node_web -->|"calls API"| node_api
node_api -->|"guards routes"| node_auth_gate
node_auth_gate -->|"verifies cookies"| node_auth_service
node_api -->|"serves login"| node_auth_api
node_auth_api -->|"handles auth"| node_auth_service
node_auth_service -->|"opens sessions"| node_session
node_api -->|"requests PR data"| node_github
node_github -.->|"fetches PRs"| node_github_external
node_github -->|"generates summaries"| node_llm
node_github -.->|"uses impact model"| node_jev
node_github -->|"persists PRs"| node_db_service
node_github -->|"requests summaries"| node_llm
node_llm -->|"checks availability"| node_breaker
node_llm -->|"calls primary"| node_bedrock
node_llm -->|"falls back"| node_groq
node_api -->|"dispatches messages"| node_chat
node_chat -.->|"queries live data"| node_db_service
node_api -->|"opens session"| node_voice
node_voice -.->|"streams audio"| node_deepgram
node_api -->|"checks task status"| node_celery
node_celery -->|"schedules generation"| node_report
node_celery -.->|"queues tasks"| node_redis
node_api -.->|"serves report features"| node_report
node_report -->|"loads PR metrics"| node_github
node_report -->|"loads engineer data"| node_db_service
node_report -->|"generates analysis"| node_llm
node_report -->|"renders report"| node_pdf
node_db_service -->|"opens sessions"| node_session
node_session -->|"reads and writes"| node_mysql

click node_web "https://github.com/seifmahmoud63/cto-copilot/blob/main/web/app.js"
click node_api "https://github.com/seifmahmoud63/cto-copilot/blob/main/app/api/routes.py"
click node_auth_gate "https://github.com/seifmahmoud63/cto-copilot/blob/main/app/core/auth_gate.py"
click node_auth_api "https://github.com/seifmahmoud63/cto-copilot/blob/main/app/api/auth.py"
click node_auth_service "https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/auth_service.py"
click node_github "https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/github_service.py"
click node_jev "https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/jev_service.py"
click node_llm "https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/llm_service.py"
click node_breaker "https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/circuit_breaker.py"
click node_chat "https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/chat_service.py"
click node_voice "https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/voice_service.py"
click node_celery "https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/celery_app.py"
click node_report "https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/report_service.py"
click node_pdf "https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/report_service.py"
click node_db_service "https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/db_service.py"
click node_session "https://github.com/seifmahmoud63/cto-copilot/blob/main/app/db/session.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_auth_gate,node_auth_api,node_auth_service toneBlue
class node_github,node_jev,node_llm,node_breaker,node_redis toneAmber
class node_chat,node_voice,node_api,node_github_external toneMint
class node_celery,node_report,node_pdf toneRose
class node_db_service,node_session,node_mysql,node_leaders,node_bedrock,node_groq,node_deepgram toneIndigo
class node_web toneTeal
```

## Components

### Access

- [Private-route gate](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/core/auth_gate.py): `app/core/auth_gate.py`
- [Login endpoints](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/api/auth.py): `app/api/auth.py`
- [Password and TOTP](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/auth_service.py): `app/services/auth_service.py`

### PR Intelligence

- [GitHub PR intelligence](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/github_service.py): `app/services/github_service.py`
- [JEV impact model](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/jev_service.py): `app/services/jev_service.py`
- [Summary LLM routing](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/llm_service.py): `app/services/llm_service.py`
- [LLM circuit breaker](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/circuit_breaker.py): `app/services/circuit_breaker.py`

### AI Copilots

- [LangGraph chat agent](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/chat_service.py): `app/services/chat_service.py`
- [Live voice agent](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/voice_service.py): `app/services/voice_service.py`

### Executive Reports

- [Report task scheduler](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/celery_app.py): `app/services/celery_app.py`
- [Daily report generation](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/report_service.py): `app/services/report_service.py`
- [Report PDF](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/report_service.py): `app/services/report_service.py`

### Data Layer

- [Persistence operations](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/services/db_service.py): `app/services/db_service.py`
- [Async DB sessions](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/db/session.py): `app/db/session.py`
- **MySQL records**

### Other components

- **Engineering leaders**
- [CTO Watch dashboard](https://github.com/seifmahmoud63/cto-copilot/blob/main/web/app.js): `web/app.js`
- [HTTP and WebSocket API](https://github.com/seifmahmoud63/cto-copilot/blob/main/app/api/routes.py): `app/api/routes.py`
- **Amazon Bedrock**
- **Groq fallback**
- **GitHub API**
- **Deepgram agent**
- **Redis task broker**

## Connections

- Engineering leaders → CTO Watch dashboard: uses (evidence: `README.md`)
- CTO Watch dashboard → HTTP and WebSocket API: calls API (evidence: `README.md`)
- HTTP and WebSocket API → Private-route gate: guards routes (evidence: `app/main.py`)
- Private-route gate → Password and TOTP: verifies cookies (evidence: `app/core/auth_gate.py`)
- HTTP and WebSocket API → Login endpoints: serves login (evidence: `app/main.py`)
- Login endpoints → Password and TOTP: handles auth (evidence: `app/api/auth.py`)
- Password and TOTP → Async DB sessions: opens sessions (evidence: `app/services/auth_service.py`)
- HTTP and WebSocket API → GitHub PR intelligence: requests PR data (evidence: `app/api/routes.py`)
- GitHub PR intelligence → GitHub API: fetches PRs
- GitHub PR intelligence → Summary LLM routing: generates summaries (evidence: `app/services/github_service.py`)
- GitHub PR intelligence → JEV impact model: uses impact model (evidence: `app/services/github_service.py`)
- GitHub PR intelligence → Persistence operations: persists PRs (evidence: `app/services/github_service.py`)
- GitHub PR intelligence → Summary LLM routing: requests summaries (evidence: `app/services/github_service.py`)
- Summary LLM routing → LLM circuit breaker: checks availability (evidence: `app/services/llm_service.py`)
- Summary LLM routing → Amazon Bedrock: calls primary (evidence: `app/services/llm_service.py`)
- Summary LLM routing → Groq fallback: falls back (evidence: `app/services/llm_service.py`)
- HTTP and WebSocket API → LangGraph chat agent: dispatches messages (evidence: `app/api/routes.py`)
- LangGraph chat agent → Persistence operations: queries live data (evidence: `app/services/chat_service.py`)
- HTTP and WebSocket API → Live voice agent: opens session (evidence: `app/api/routes.py`)
- Live voice agent → Deepgram agent: streams audio
- HTTP and WebSocket API → Report task scheduler: checks task status (evidence: `app/api/routes.py`)
- Report task scheduler → Daily report generation: schedules generation (evidence: `app/services/celery_app.py`)
- Report task scheduler → Redis task broker: queues tasks
- HTTP and WebSocket API → Daily report generation: serves report features (evidence: `app/api/routes.py`)
- Daily report generation → GitHub PR intelligence: loads PR metrics (evidence: `app/services/report_service.py`)
- Daily report generation → Persistence operations: loads engineer data (evidence: `app/services/report_service.py`)
- Daily report generation → Summary LLM routing: generates analysis (evidence: `app/services/report_service.py`)
- Daily report generation → Report PDF: renders report (evidence: `app/services/report_service.py`)
- Persistence operations → Async DB sessions: opens sessions (evidence: `app/services/db_service.py`)
- Async DB sessions → MySQL records: reads and writes (evidence: `app/db/session.py`)
