# pavankbhat/chat-bot architecture

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

- Interactive diagram: https://gitdiagram.com/pavankbhat/chat-bot
- Repository: https://github.com/pavankbhat/chat-bot

## Overview

This is a React/Django conversational AI app: users register or sign in, select or create a conversation, send a message, and see a Gemini response saved with conversation history. The frontend also supports history browsing, renaming, and deletion; the backend scopes chat data to authenticated users and includes recent conversation context in prompts. Edges among sampled modules follow explicit imports and calls. Frontend-to-backend HTTP links are dashed because the excerpts do not show the server routing/configuration that connects them.

Main entry points: [`backend/api/views.py`](https://github.com/pavankbhat/chat-bot/blob/main/backend/api/views.py) (Conversation endpoints), [`frontend/src/pages/chatLayout.tsx`](https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/pages/chatLayout.tsx) (Chat layout), [`frontend/src/App.tsx`](https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/App.tsx) (App session gate), [`frontend/src/api/chatApi.ts`](https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/api/chatApi.ts) (Chat API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_app["App session gate<br/>[App.tsx]"]
  node_login["Login and signup<br/>[login.tsx]"]
  node_auth_client["Auth API client<br/>[authApi.ts]"]
  node_chat_layout["Chat layout<br/>[chatLayout.tsx]"]
  node_top_nav["Top navigation<br/>[topNav.tsx]"]
  node_history_ui["History controls<br/>[sideNav.tsx]"]
  node_chat_ui["Chat window<br/>[chatWindow.tsx]"]
  node_chat_client["Chat API client<br/>[chatApi.ts]"]
end

subgraph group_identity["Identity and access"]
  node_user_views["User endpoints<br/>[views.py]"]
  node_user_serializers["User serializers<br/>[serializers.py]"]
  node_user_model[("User records<br/>[models.py]")]
  node_user_routes["User routes<br/>[urls.py]"]
end

subgraph group_conversation["Conversation services"]
  node_chat_views["Conversation endpoints<br/>[views.py]"]
  node_chat_serializers["Conversation serializers<br/>[serializers.py]"]
  node_chat_models[("Conversation and messages<br/>[models.py]")]
  node_chat_routes["Chat routes<br/>[urls.py]"]
end

subgraph group_external["External systems"]
  node_gemini{{"Gemini API"}}
  node_postgres[("PostgreSQL")]
end

node_user(("User"))

node_user -->|"opens app"| node_app
node_app -->|"shows when unauthenticated"| node_login
node_app -->|"shows when signed in"| node_chat_layout
node_login -->|"submits credentials"| node_auth_client
node_auth_client -.->|"posts auth requests"| node_user_views
node_user_routes -->|"routes requests"| node_user_views
node_user_views -->|"validates credentials"| node_user_serializers
node_user_serializers -->|"creates users"| node_user_model
node_chat_layout -->|"renders"| node_top_nav
node_chat_layout -->|"renders"| node_history_ui
node_chat_layout -->|"renders"| node_chat_ui
node_history_ui -->|"manages history through"| node_chat_client
node_chat_ui -->|"loads and sends through"| node_chat_client
node_chat_client -.->|"requests chat operations"| node_chat_views
node_chat_routes -->|"routes requests"| node_chat_views
node_chat_views -->|"reads and writes"| node_chat_models
node_chat_views -->|"serializes responses"| node_chat_serializers
node_chat_views -->|"sends prompt"| node_gemini
node_chat_models -.->|"persists chat history"| node_postgres

click node_app "https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/App.tsx"
click node_login "https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/pages/login.tsx"
click node_auth_client "https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/api/authApi.ts"
click node_chat_layout "https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/pages/chatLayout.tsx"
click node_top_nav "https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/components/topNav.tsx"
click node_history_ui "https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/components/sideNav.tsx"
click node_chat_ui "https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/components/chatWindow.tsx"
click node_chat_client "https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/api/chatApi.ts"
click node_user_views "https://github.com/pavankbhat/chat-bot/blob/main/backend/users/views.py"
click node_user_serializers "https://github.com/pavankbhat/chat-bot/blob/main/backend/users/serializers.py"
click node_user_model "https://github.com/pavankbhat/chat-bot/blob/main/backend/users/models.py"
click node_user_routes "https://github.com/pavankbhat/chat-bot/blob/main/backend/users/urls.py"
click node_chat_views "https://github.com/pavankbhat/chat-bot/blob/main/backend/api/views.py"
click node_chat_serializers "https://github.com/pavankbhat/chat-bot/blob/main/backend/api/serializers.py"
click node_chat_models "https://github.com/pavankbhat/chat-bot/blob/main/backend/api/models.py"
click node_chat_routes "https://github.com/pavankbhat/chat-bot/blob/main/backend/api/urls.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_login,node_auth_client,node_chat_layout,node_top_nav,node_history_ui,node_chat_ui,node_chat_client,node_user toneBlue
class node_user_views,node_user_serializers,node_user_model,node_user_routes toneAmber
class node_chat_views,node_chat_serializers,node_chat_models,node_chat_routes toneMint
class node_gemini,node_postgres toneRose
```

## Components

### Frontend experience

- [App session gate](https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Login and signup](https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/pages/login.tsx): `frontend/src/pages/login.tsx`
- [Auth API client](https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/api/authApi.ts): `frontend/src/api/authApi.ts`
- [Chat layout](https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/pages/chatLayout.tsx): `frontend/src/pages/chatLayout.tsx`
- [Top navigation](https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/components/topNav.tsx): `frontend/src/components/topNav.tsx`
- [History controls](https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/components/sideNav.tsx): `frontend/src/components/sideNav.tsx`
- [Chat window](https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/components/chatWindow.tsx): `frontend/src/components/chatWindow.tsx`
- [Chat API client](https://github.com/pavankbhat/chat-bot/blob/main/frontend/src/api/chatApi.ts): `frontend/src/api/chatApi.ts`

### Identity and access

- [User endpoints](https://github.com/pavankbhat/chat-bot/blob/main/backend/users/views.py): `backend/users/views.py`
- [User serializers](https://github.com/pavankbhat/chat-bot/blob/main/backend/users/serializers.py): `backend/users/serializers.py`
- [User records](https://github.com/pavankbhat/chat-bot/blob/main/backend/users/models.py): `backend/users/models.py`
- [User routes](https://github.com/pavankbhat/chat-bot/blob/main/backend/users/urls.py): `backend/users/urls.py`

### Conversation services

- [Conversation endpoints](https://github.com/pavankbhat/chat-bot/blob/main/backend/api/views.py): `backend/api/views.py`
- [Conversation serializers](https://github.com/pavankbhat/chat-bot/blob/main/backend/api/serializers.py): `backend/api/serializers.py`
- [Conversation and messages](https://github.com/pavankbhat/chat-bot/blob/main/backend/api/models.py): `backend/api/models.py`
- [Chat routes](https://github.com/pavankbhat/chat-bot/blob/main/backend/api/urls.py): `backend/api/urls.py`

### External systems

- **Gemini API**
- **PostgreSQL**

### Other components

- **User**

## Connections

- User → App session gate: opens app
- App session gate → Login and signup: shows when unauthenticated (evidence: `frontend/src/App.tsx`)
- App session gate → Chat layout: shows when signed in (evidence: `frontend/src/App.tsx`)
- Login and signup → Auth API client: submits credentials (evidence: `frontend/src/pages/login.tsx`)
- Auth API client → User endpoints: posts auth requests
- User routes → User endpoints: routes requests (evidence: `backend/users/urls.py`)
- User endpoints → User serializers: validates credentials (evidence: `backend/users/views.py`)
- User serializers → User records: creates users (evidence: `backend/users/serializers.py`)
- Chat layout → Top navigation: renders (evidence: `frontend/src/pages/chatLayout.tsx`)
- Chat layout → History controls: renders (evidence: `frontend/src/pages/chatLayout.tsx`)
- Chat layout → Chat window: renders (evidence: `frontend/src/pages/chatLayout.tsx`)
- History controls → Chat API client: manages history through (evidence: `frontend/src/components/sideNav.tsx`)
- Chat window → Chat API client: loads and sends through (evidence: `frontend/src/components/chatWindow.tsx`)
- Chat API client → Conversation endpoints: requests chat operations
- Chat routes → Conversation endpoints: routes requests (evidence: `backend/api/urls.py`)
- Conversation endpoints → Conversation and messages: reads and writes (evidence: `backend/api/views.py`)
- Conversation endpoints → Conversation serializers: serializes responses (evidence: `backend/api/views.py`)
- Conversation endpoints → Gemini API: sends prompt (evidence: `backend/api/views.py`)
- Conversation and messages → PostgreSQL: persists chat history (evidence: `Readme.md`)
