# sarthakdhabale2006-dev/chatbot-app architecture

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

- Interactive diagram: https://gitdiagram.com/sarthakdhabale2006-dev/chatbot-app
- Repository: https://github.com/sarthakdhabale2006-dev/chatbot-app

## Overview

Local AI Chat is a chat interface with conversation management, configurable backend/model settings, streaming responses, and export controls. The main workflow is user prompt → frontend request → inference service → streamed or complete reply. The repository also contains a standalone vanilla-JavaScript interface alongside the React interface, a TypeScript API gateway with optional Gemini fallback, and a Python FastAPI backend that forwards chat requests to local Ollama. The React excerpt is partial, so its request wiring is shown as unverified; no README was provided.

Main entry points: [`server.ts`](https://github.com/sarthakdhabale2006-dev/chatbot-app/blob/main/server.ts) (Express API), [`src/App.tsx`](https://github.com/sarthakdhabale2006-dev/chatbot-app/blob/main/src/App.tsx) (React chat UI), [`frontend/script.js`](https://github.com/sarthakdhabale2006-dev/chatbot-app/blob/main/frontend/script.js) (Vanilla chat UI), [`backend/main.py`](https://github.com/sarthakdhabale2006-dev/chatbot-app/blob/main/backend/main.py) (FastAPI chat API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_react["React Chat"]
  node_react_app["React chat UI<br/>[App.tsx]"]
  node_react_settings["Settings and export<br/>[App.tsx]"]
  node_browser_settings[("Browser settings")]
end

subgraph group_vanilla["Standalone Chat"]
  node_vanilla_app["Vanilla chat UI<br/>[script.js]"]
  node_vanilla_storage[("Browser chat storage<br/>[script.js]")]
end

subgraph group_gateway["API Gateway"]
  node_express_api["Express API<br/>[server.ts]"]
end

subgraph group_python["Python Backend"]
  node_python_api["FastAPI chat API<br/>[main.py]"]
end

subgraph group_inference["Inference Services"]
  node_ollama["Local Ollama"]
  node_gemini["Google GenAI"]
end

node_user(("Chat user"))

node_user -->|"sends prompts"| node_react_app
node_react_app -->|"opens controls"| node_react_settings
node_react_settings -.->|"reads settings"| node_browser_settings
node_react_app -.->|"requests chat"| node_express_api
node_user -->|"sends prompts"| node_vanilla_app
node_vanilla_app -.->|"persists chats"| node_vanilla_storage
node_vanilla_app -.->|"requests chat"| node_express_api
node_express_api -->|"probes and chats"| node_ollama
node_express_api -->|"generates fallback"| node_gemini
node_express_api -->|"probes health"| node_python_api
node_python_api -->|"checks and chats"| node_ollama

click node_react_app "https://github.com/sarthakdhabale2006-dev/chatbot-app/blob/main/src/App.tsx"
click node_react_settings "https://github.com/sarthakdhabale2006-dev/chatbot-app/blob/main/src/App.tsx"
click node_vanilla_app "https://github.com/sarthakdhabale2006-dev/chatbot-app/blob/main/frontend/script.js"
click node_vanilla_storage "https://github.com/sarthakdhabale2006-dev/chatbot-app/blob/main/frontend/script.js"
click node_express_api "https://github.com/sarthakdhabale2006-dev/chatbot-app/blob/main/server.ts"
click node_python_api "https://github.com/sarthakdhabale2006-dev/chatbot-app/blob/main/backend/main.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_react_app,node_react_settings,node_browser_settings,node_user toneBlue
class node_vanilla_app,node_vanilla_storage toneAmber
class node_express_api toneMint
class node_python_api toneRose
class node_ollama,node_gemini toneIndigo
```

## Components

### React Chat

- [React chat UI](https://github.com/sarthakdhabale2006-dev/chatbot-app/blob/main/src/App.tsx): `src/App.tsx`
- [Settings and export](https://github.com/sarthakdhabale2006-dev/chatbot-app/blob/main/src/App.tsx): `src/App.tsx`
- **Browser settings**

### Standalone Chat

- [Vanilla chat UI](https://github.com/sarthakdhabale2006-dev/chatbot-app/blob/main/frontend/script.js): `frontend/script.js`
- [Browser chat storage](https://github.com/sarthakdhabale2006-dev/chatbot-app/blob/main/frontend/script.js): `frontend/script.js`

### API Gateway

- [Express API](https://github.com/sarthakdhabale2006-dev/chatbot-app/blob/main/server.ts): `server.ts`

### Python Backend

- [FastAPI chat API](https://github.com/sarthakdhabale2006-dev/chatbot-app/blob/main/backend/main.py): `backend/main.py`

### Inference Services

- **Local Ollama**
- **Google GenAI**

### Other components

- **Chat user**

## Connections

- Chat user → React chat UI: sends prompts (evidence: `src/App.tsx`)
- React chat UI → Settings and export: opens controls (evidence: `src/App.tsx`)
- Settings and export → Browser settings: reads settings
- React chat UI → Express API: requests chat
- Chat user → Vanilla chat UI: sends prompts (evidence: `frontend/script.js`)
- Vanilla chat UI → Browser chat storage: persists chats (evidence: `frontend/script.js`)
- Vanilla chat UI → Express API: requests chat
- Express API → Local Ollama: probes and chats (evidence: `server.ts`)
- Express API → Google GenAI: generates fallback (evidence: `server.ts`)
- Express API → FastAPI chat API: probes health (evidence: `server.ts`)
- FastAPI chat API → Local Ollama: checks and chats (evidence: `backend/main.py`)
