# harkit07/ai-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/harkit07/ai-assistant
- Repository: https://github.com/harkit07/ai-assistant

## Overview

AI Assistant is a full-stack chat product: users authenticate, manage conversation threads, submit prompts, and receive streamed model replies, with account and thread state persisted in MongoDB. The graph separates the React interaction layer, backend identity and chat domains, and external services. Relationships are limited to excerpted calls/imports or README-documented capabilities; some frontend and deployment details were not sampled.

Main entry points: [`Backend/routes/user.js`](https://github.com/harkit07/ai-assistant/blob/main/Backend/routes/user.js) (Account routes), [`Backend/routes/chat.js`](https://github.com/harkit07/ai-assistant/blob/main/Backend/routes/chat.js) (Thread and chat routes), [`Frontend/src/App.jsx`](https://github.com/harkit07/ai-assistant/blob/main/Frontend/src/App.jsx) (Application shell), [`Frontend/src/ChatWindow.jsx`](https://github.com/harkit07/ai-assistant/blob/main/Frontend/src/ChatWindow.jsx) (Chat interaction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Chat interface"]
  node_app["Application shell<br/>[App.jsx]"]
  node_auth_context["Auth state<br/>[AuthContext.jsx]"]
  node_login["Signup and login UI<br/>[Login.jsx]"]
  node_chat_window["Chat interaction<br/>[ChatWindow.jsx]"]
  node_chat_view["Message rendering<br/>[Chat.jsx]"]
  node_sidebar["Thread navigation<br/>[Sidebar.jsx]"]
  node_chat_context["Chat state<br/>[ChatContext.jsx]"]
end

subgraph group_identity["Identity and access"]
  node_user_routes["Account routes<br/>[user.js]"]
  node_auth_middleware["JWT authorization<br/>[middleware.js]"]
  node_user_model[("User records<br/>[user.js]")]
  node_token_blacklist[("Revoked tokens<br/>[blacklistToken.js]")]
  node_validation["Request validation"]
  node_user_service["User creation<br/>[user.js]"]
end

subgraph group_conversation["Conversation backend"]
  node_api_server["Express API<br/>[server.js]"]
  node_chat_routes["Thread and chat routes<br/>[chat.js]"]
  node_thread_model[("Thread records<br/>[Thread.js]")]
  node_ai_client["AI inference client<br/>[openai.js]"]
end

subgraph group_external["External services"]
  node_mongo[("MongoDB")]
  node_model_api["NVIDIA inference API"]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"provides"| node_auth_context
node_app -->|"provides"| node_chat_context
node_app -->|"renders"| node_chat_window
node_app -->|"renders"| node_sidebar
node_login -->|"uses"| node_auth_context
node_chat_window -->|"uses"| node_chat_context
node_chat_window -->|"renders"| node_chat_view
node_chat_window -->|"renders"| node_login
node_login -->|"calls signup and login"| node_user_routes
node_chat_window -->|"requests chat and history"| node_chat_routes
node_sidebar -->|"manages threads"| node_chat_routes
node_api_server -->|"mounts API"| node_chat_routes
node_api_server -->|"mounts API"| node_user_routes
node_user_routes -->|"validates input"| node_validation
node_user_routes -->|"protects routes"| node_auth_middleware
node_user_routes -->|"reads and creates"| node_user_model
node_user_routes -->|"creates account"| node_user_service
node_user_service -->|"creates record"| node_user_model
node_user_routes -->|"revokes token"| node_token_blacklist
node_auth_middleware -->|"checks revocation"| node_token_blacklist
node_auth_middleware -->|"loads user"| node_user_model
node_chat_routes -->|"protects endpoints"| node_auth_middleware
node_chat_routes -->|"reads and saves"| node_thread_model
node_chat_routes -->|"requests completion"| node_ai_client
node_ai_client -->|"streams inference"| node_model_api
node_api_server -->|"connects"| node_mongo
node_user_model -->|"persists user data"| node_mongo
node_thread_model -->|"persists threads"| node_mongo

click node_app "https://github.com/harkit07/ai-assistant/blob/main/Frontend/src/App.jsx"
click node_auth_context "https://github.com/harkit07/ai-assistant/blob/main/Frontend/src/AuthContext.jsx"
click node_login "https://github.com/harkit07/ai-assistant/blob/main/Frontend/src/Login.jsx"
click node_chat_window "https://github.com/harkit07/ai-assistant/blob/main/Frontend/src/ChatWindow.jsx"
click node_chat_view "https://github.com/harkit07/ai-assistant/blob/main/Frontend/src/Chat.jsx"
click node_sidebar "https://github.com/harkit07/ai-assistant/blob/main/Frontend/src/Sidebar.jsx"
click node_chat_context "https://github.com/harkit07/ai-assistant/blob/main/Frontend/src/ChatContext.jsx"
click node_api_server "https://github.com/harkit07/ai-assistant/blob/main/Backend/server.js"
click node_user_routes "https://github.com/harkit07/ai-assistant/blob/main/Backend/routes/user.js"
click node_auth_middleware "https://github.com/harkit07/ai-assistant/blob/main/Backend/middleware.js"
click node_user_model "https://github.com/harkit07/ai-assistant/blob/main/Backend/models/user.js"
click node_token_blacklist "https://github.com/harkit07/ai-assistant/blob/main/Backend/models/blacklistToken.js"
click node_validation "https://github.com/harkit07/ai-assistant/blob/main/Backend/services/validationResult.js"
click node_user_service "https://github.com/harkit07/ai-assistant/blob/main/Backend/services/user.js"
click node_chat_routes "https://github.com/harkit07/ai-assistant/blob/main/Backend/routes/chat.js"
click node_thread_model "https://github.com/harkit07/ai-assistant/blob/main/Backend/models/Thread.js"
click node_ai_client "https://github.com/harkit07/ai-assistant/blob/main/Backend/utils/openai.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_app,node_auth_context,node_login,node_chat_window,node_chat_view,node_sidebar,node_chat_context,node_user toneBlue
class node_user_routes,node_auth_middleware,node_user_model,node_token_blacklist,node_validation,node_user_service toneAmber
class node_api_server,node_chat_routes,node_thread_model,node_ai_client toneMint
class node_mongo,node_model_api toneRose
```

## Components

### Chat interface

- [Application shell](https://github.com/harkit07/ai-assistant/blob/main/Frontend/src/App.jsx): `Frontend/src/App.jsx`
- [Auth state](https://github.com/harkit07/ai-assistant/blob/main/Frontend/src/AuthContext.jsx): `Frontend/src/AuthContext.jsx`
- [Signup and login UI](https://github.com/harkit07/ai-assistant/blob/main/Frontend/src/Login.jsx): `Frontend/src/Login.jsx`
- [Chat interaction](https://github.com/harkit07/ai-assistant/blob/main/Frontend/src/ChatWindow.jsx): `Frontend/src/ChatWindow.jsx`
- [Message rendering](https://github.com/harkit07/ai-assistant/blob/main/Frontend/src/Chat.jsx): `Frontend/src/Chat.jsx`
- [Thread navigation](https://github.com/harkit07/ai-assistant/blob/main/Frontend/src/Sidebar.jsx): `Frontend/src/Sidebar.jsx`
- [Chat state](https://github.com/harkit07/ai-assistant/blob/main/Frontend/src/ChatContext.jsx): `Frontend/src/ChatContext.jsx`

### Identity and access

- [Account routes](https://github.com/harkit07/ai-assistant/blob/main/Backend/routes/user.js): `Backend/routes/user.js`
- [JWT authorization](https://github.com/harkit07/ai-assistant/blob/main/Backend/middleware.js): `Backend/middleware.js`
- [User records](https://github.com/harkit07/ai-assistant/blob/main/Backend/models/user.js): `Backend/models/user.js`
- [Revoked tokens](https://github.com/harkit07/ai-assistant/blob/main/Backend/models/blacklistToken.js): `Backend/models/blacklistToken.js`
- [Request validation](https://github.com/harkit07/ai-assistant/blob/main/Backend/services/validationResult.js): `Backend/services/validationResult.js`
- [User creation](https://github.com/harkit07/ai-assistant/blob/main/Backend/services/user.js): `Backend/services/user.js`

### Conversation backend

- [Express API](https://github.com/harkit07/ai-assistant/blob/main/Backend/server.js): `Backend/server.js`
- [Thread and chat routes](https://github.com/harkit07/ai-assistant/blob/main/Backend/routes/chat.js): `Backend/routes/chat.js`
- [Thread records](https://github.com/harkit07/ai-assistant/blob/main/Backend/models/Thread.js): `Backend/models/Thread.js`
- [AI inference client](https://github.com/harkit07/ai-assistant/blob/main/Backend/utils/openai.js): `Backend/utils/openai.js`

### External services

- **MongoDB**
- **NVIDIA inference API**

### Other components

- **User**

## Connections

- User → Application shell: uses (evidence: `README.md`)
- Application shell → Auth state: provides (evidence: `Frontend/src/App.jsx`)
- Application shell → Chat state: provides (evidence: `Frontend/src/App.jsx`)
- Application shell → Chat interaction: renders (evidence: `Frontend/src/App.jsx`)
- Application shell → Thread navigation: renders (evidence: `Frontend/src/App.jsx`)
- Signup and login UI → Auth state: uses (evidence: `Frontend/src/Login.jsx`)
- Chat interaction → Chat state: uses (evidence: `Frontend/src/ChatWindow.jsx`)
- Chat interaction → Message rendering: renders (evidence: `Frontend/src/ChatWindow.jsx`)
- Chat interaction → Signup and login UI: renders (evidence: `Frontend/src/ChatWindow.jsx`)
- Signup and login UI → Account routes: calls signup and login (evidence: `README.md`)
- Chat interaction → Thread and chat routes: requests chat and history (evidence: `Frontend/src/ChatWindow.jsx`)
- Thread navigation → Thread and chat routes: manages threads (evidence: `README.md`)
- Express API → Thread and chat routes: mounts API (evidence: `Backend/server.js`)
- Express API → Account routes: mounts API (evidence: `Backend/server.js`)
- Account routes → Request validation: validates input (evidence: `Backend/routes/user.js`)
- Account routes → JWT authorization: protects routes (evidence: `Backend/routes/user.js`)
- Account routes → User records: reads and creates (evidence: `Backend/routes/user.js`)
- Account routes → User creation: creates account (evidence: `Backend/routes/user.js`)
- User creation → User records: creates record (evidence: `Backend/services/user.js`)
- Account routes → Revoked tokens: revokes token (evidence: `Backend/routes/user.js`)
- JWT authorization → Revoked tokens: checks revocation (evidence: `Backend/middleware.js`)
- JWT authorization → User records: loads user (evidence: `Backend/middleware.js`)
- Thread and chat routes → JWT authorization: protects endpoints (evidence: `Backend/routes/chat.js`)
- Thread and chat routes → Thread records: reads and saves (evidence: `Backend/routes/chat.js`)
- Thread and chat routes → AI inference client: requests completion (evidence: `Backend/routes/chat.js`)
- AI inference client → NVIDIA inference API: streams inference (evidence: `README.md`)
- Express API → MongoDB: connects (evidence: `Backend/server.js`)
- User records → MongoDB: persists user data (evidence: `README.md`)
- Thread records → MongoDB: persists threads (evidence: `README.md`)
