# elevate-skills/chat-ai architecture

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

- Interactive diagram: https://gitdiagram.com/elevate-skills/chat-ai
- Repository: https://github.com/elevate-skills/chat-ai

## Overview

ChatAI is a React application backed by FastAPI: a user submits a prompt, the chat UI requests a streamed completion, and the backend can enrich current-information queries with web results before forwarding them to OpenRouter. Authentication and chat-history retrieval are separate flows. The README also describes Firestore-backed projects and settings, but their implementation is not shown in the sampled source; the corresponding frontend pages appear to be product surfaces rather than demonstrated data workflows.

Main entry points: [`frontend/src/App.jsx`](https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/App.jsx) (App router), [`backend/app/api/chat.py`](https://github.com/elevate-skills/chat-ai/blob/main/backend/app/api/chat.py) (Chat completions), [`frontend/src/contexts/AuthContext.jsx`](https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/contexts/AuthContext.jsx) (Auth context), [`frontend/src/pages/Home.jsx`](https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/pages/Home.jsx) (Chat page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_app["App router<br/>[App.jsx]"]
  node_home["Chat page<br/>[Home.jsx]"]
  node_chatui["Chat interface<br/>[Chat.jsx]"]
  node_sidebar["Navigation<br/>[Sidebar.jsx]"]
  node_library["Chat library<br/>[Library.jsx]"]
  node_projects["Projects<br/>[Projects.jsx]"]
  node_scheduled["Scheduled tasks<br/>[Scheduled.jsx]"]
  node_apps["Apps and integrations<br/>[Apps.jsx]"]
  node_login["Sign in<br/>[Login.jsx]"]
  node_signup["Sign up<br/>[Signup.jsx]"]
  node_protected["Route guard<br/>[ProtectedRoute.jsx]"]
end

subgraph group_identity["Identity and preferences"]
  node_auth["Auth context<br/>[AuthContext.jsx]"]
  node_theme["Theme context<br/>[ThemeContext.jsx]"]
  node_firebasejs["Firebase client<br/>[firebase.js]"]
end

subgraph group_api["Backend API"]
  node_apiapp["FastAPI app<br/>[main.py]"]
  node_completion["Chat completions<br/>[chat.py]"]
  node_history["History endpoint<br/>[history.py]"]
  node_config["Backend settings<br/>[config.py]"]
  node_security["Token verification<br/>[security.py]"]
end

subgraph group_integrations["External services"]
  node_openrouter["OpenRouter"]
  node_ddg["Web search"]
  node_firebaseauth["Firebase Auth"]
  node_firestore[("Firestore")]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_library
node_app -->|"routes to"| node_projects
node_app -->|"routes to"| node_scheduled
node_app -->|"routes to"| node_apps
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_signup
node_app -->|"guards routes"| node_protected
node_app -->|"provides"| node_auth
node_app -->|"provides"| node_theme
node_home -->|"renders"| node_sidebar
node_home -->|"renders"| node_chatui
node_chatui -->|"requests stream"| node_apiapp
node_apiapp -->|"mounts route"| node_completion
node_apiapp -->|"mounts route"| node_history
node_completion -->|"reads settings"| node_config
node_completion -->|"streams completion"| node_openrouter
node_completion -->|"searches query"| node_ddg
node_history -->|"validates user"| node_security
node_history -->|"reads chat records"| node_firestore
node_security -->|"reads credentials"| node_config
node_security -->|"verifies token"| node_firebaseauth
node_auth -->|"uses client"| node_firebasejs
node_auth -->|"authenticates"| node_firebaseauth
node_sidebar -->|"uses theme"| node_theme
node_sidebar -->|"uses identity"| node_auth
node_projects -.->|"uses storage"| node_firestore
node_library -.->|"uses storage"| node_firestore

click node_app "https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/App.jsx"
click node_home "https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/pages/Home.jsx"
click node_chatui "https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/components/Chat.jsx"
click node_sidebar "https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/components/Sidebar.jsx"
click node_library "https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/pages/Library.jsx"
click node_projects "https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/pages/Projects.jsx"
click node_scheduled "https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/pages/Scheduled.jsx"
click node_apps "https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/pages/Apps.jsx"
click node_login "https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/pages/Login.jsx"
click node_signup "https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/pages/Signup.jsx"
click node_protected "https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/components/ProtectedRoute.jsx"
click node_auth "https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/contexts/AuthContext.jsx"
click node_theme "https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/contexts/ThemeContext.jsx"
click node_firebasejs "https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/services/firebase.js"
click node_apiapp "https://github.com/elevate-skills/chat-ai/blob/main/backend/app/main.py"
click node_completion "https://github.com/elevate-skills/chat-ai/blob/main/backend/app/api/chat.py"
click node_history "https://github.com/elevate-skills/chat-ai/blob/main/backend/app/api/history.py"
click node_config "https://github.com/elevate-skills/chat-ai/blob/main/backend/app/core/config.py"
click node_security "https://github.com/elevate-skills/chat-ai/blob/main/backend/app/core/security.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_home,node_chatui,node_sidebar,node_library,node_projects,node_scheduled,node_apps,node_login,node_signup,node_protected,node_user toneBlue
class node_auth,node_theme,node_firebasejs toneAmber
class node_apiapp,node_completion,node_history,node_config,node_security toneMint
class node_openrouter,node_ddg,node_firebaseauth,node_firestore toneRose
```

## Components

### Web application

- [App router](https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Chat page](https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/pages/Home.jsx): `frontend/src/pages/Home.jsx`
- [Chat interface](https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/components/Chat.jsx): `frontend/src/components/Chat.jsx`
- [Navigation](https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/components/Sidebar.jsx): `frontend/src/components/Sidebar.jsx`
- [Chat library](https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/pages/Library.jsx): `frontend/src/pages/Library.jsx`
- [Projects](https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/pages/Projects.jsx): `frontend/src/pages/Projects.jsx`
- [Scheduled tasks](https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/pages/Scheduled.jsx): `frontend/src/pages/Scheduled.jsx`
- [Apps and integrations](https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/pages/Apps.jsx): `frontend/src/pages/Apps.jsx`
- [Sign in](https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Sign up](https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/pages/Signup.jsx): `frontend/src/pages/Signup.jsx`
- [Route guard](https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/components/ProtectedRoute.jsx): `frontend/src/components/ProtectedRoute.jsx`

### Identity and preferences

- [Auth context](https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/contexts/AuthContext.jsx): `frontend/src/contexts/AuthContext.jsx`
- [Theme context](https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/contexts/ThemeContext.jsx): `frontend/src/contexts/ThemeContext.jsx`
- [Firebase client](https://github.com/elevate-skills/chat-ai/blob/main/frontend/src/services/firebase.js): `frontend/src/services/firebase.js`

### Backend API

- [FastAPI app](https://github.com/elevate-skills/chat-ai/blob/main/backend/app/main.py): `backend/app/main.py`
- [Chat completions](https://github.com/elevate-skills/chat-ai/blob/main/backend/app/api/chat.py): `backend/app/api/chat.py`
- [History endpoint](https://github.com/elevate-skills/chat-ai/blob/main/backend/app/api/history.py): `backend/app/api/history.py`
- [Backend settings](https://github.com/elevate-skills/chat-ai/blob/main/backend/app/core/config.py): `backend/app/core/config.py`
- [Token verification](https://github.com/elevate-skills/chat-ai/blob/main/backend/app/core/security.py): `backend/app/core/security.py`

### External services

- **OpenRouter**
- **Web search**
- **Firebase Auth**
- **Firestore**

### Other components

- **User**

## Connections

- User → App router: uses (evidence: `frontend/src/App.jsx`)
- App router → Chat page: routes to (evidence: `frontend/src/App.jsx`)
- App router → Chat library: routes to (evidence: `frontend/src/App.jsx`)
- App router → Projects: routes to (evidence: `frontend/src/App.jsx`)
- App router → Scheduled tasks: routes to (evidence: `frontend/src/App.jsx`)
- App router → Apps and integrations: routes to (evidence: `frontend/src/App.jsx`)
- App router → Sign in: routes to (evidence: `frontend/src/App.jsx`)
- App router → Sign up: routes to (evidence: `frontend/src/App.jsx`)
- App router → Route guard: guards routes (evidence: `frontend/src/App.jsx`)
- App router → Auth context: provides (evidence: `frontend/src/App.jsx`)
- App router → Theme context: provides (evidence: `frontend/src/App.jsx`)
- Chat page → Navigation: renders (evidence: `frontend/src/pages/Home.jsx`)
- Chat page → Chat interface: renders (evidence: `frontend/src/pages/Home.jsx`)
- Chat interface → FastAPI app: requests stream (evidence: `frontend/src/components/Chat.jsx`)
- FastAPI app → Chat completions: mounts route (evidence: `backend/app/main.py`)
- FastAPI app → History endpoint: mounts route (evidence: `backend/app/main.py`)
- Chat completions → Backend settings: reads settings (evidence: `backend/app/api/chat.py`)
- Chat completions → OpenRouter: streams completion (evidence: `backend/app/api/chat.py`)
- Chat completions → Web search: searches query (evidence: `backend/app/api/chat.py`)
- History endpoint → Token verification: validates user (evidence: `backend/app/api/history.py`)
- History endpoint → Firestore: reads chat records (evidence: `backend/app/api/history.py`)
- Token verification → Backend settings: reads credentials (evidence: `backend/app/core/security.py`)
- Token verification → Firebase Auth: verifies token (evidence: `backend/app/core/security.py`)
- Auth context → Firebase client: uses client (evidence: `frontend/src/contexts/AuthContext.jsx`)
- Auth context → Firebase Auth: authenticates (evidence: `README.md`)
- Navigation → Theme context: uses theme (evidence: `frontend/src/components/Sidebar.jsx`)
- Navigation → Auth context: uses identity (evidence: `frontend/src/components/Sidebar.jsx`)
- Projects → Firestore: uses storage
- Chat library → Firestore: uses storage
