# hari-vignesh214/personal-chatbot architecture

> Architecture diagram of the GitHub repository hari-vignesh214/personal-chatbot, 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/hari-vignesh214/personal-chatbot
- Repository: https://github.com/hari-vignesh214/personal-chatbot

## Overview

This is a small Flask chatbot: the browser submits messages and optional files, the backend restores conversation context, calls Gemini, and saves the reply for later turns. Users can reload history or clear memory. File extraction and history-to-model formatting are distinct backend stages; persistent state is a local JSON file. The map follows the sampled backend and JavaScript plus README-documented storage and UI behavior; template and styling internals were not sampled.

Main entry points: [`app.py`](https://github.com/hari-vignesh214/personal-chatbot/blob/main/app.py) (Flask routes), [`templates/index.html`](https://github.com/hari-vignesh214/personal-chatbot/blob/main/templates/index.html) (Chat page), [`static/script.js`](https://github.com/hari-vignesh214/personal-chatbot/blob/main/static/script.js) (Chat interactions), [`static/style.css`](https://github.com/hari-vignesh214/personal-chatbot/blob/main/static/style.css) (Dark-mode styling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Chat interface"]
  node_page["Chat page<br/>[index.html]"]
  node_chat_ui["Chat interactions<br/>[script.js]"]
  node_chat_styles["Dark-mode styling<br/>[style.css]"]
end

subgraph group_backend["Chat backend"]
  node_flask["Flask routes<br/>[app.py]"]
  node_file_extract["Attachment extraction<br/>[app.py]"]
  node_context["History formatting<br/>[app.py]"]
end

subgraph group_state["Conversation state"]
  node_memory[("JSON conversation memory")]
end

node_user(("Chat user"))
node_browser["Browser"]
node_gemini["Gemini API"]

node_user -->|"uses"| node_browser
node_browser -->|"opens"| node_page
node_page -.->|"hosts"| node_chat_ui
node_chat_ui -->|"sends chat requests"| node_flask
node_flask -->|"renders"| node_page
node_flask -->|"extracts uploads"| node_file_extract
node_flask -->|"loads and saves"| node_memory
node_flask -->|"formats history"| node_context
node_context -->|"provides context"| node_gemini
node_flask -->|"requests reply"| node_gemini
node_chat_ui -->|"loads or clears memory"| node_flask
node_chat_styles -.->|"styles"| node_page

click node_page "https://github.com/hari-vignesh214/personal-chatbot/blob/main/templates/index.html"
click node_chat_ui "https://github.com/hari-vignesh214/personal-chatbot/blob/main/static/script.js"
click node_chat_styles "https://github.com/hari-vignesh214/personal-chatbot/blob/main/static/style.css"
click node_flask "https://github.com/hari-vignesh214/personal-chatbot/blob/main/app.py"
click node_file_extract "https://github.com/hari-vignesh214/personal-chatbot/blob/main/app.py"
click node_context "https://github.com/hari-vignesh214/personal-chatbot/blob/main/app.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_page,node_chat_ui,node_chat_styles,node_user,node_browser toneBlue
class node_flask,node_file_extract,node_context toneAmber
class node_memory,node_gemini toneMint
```

## Components

### Chat interface

- [Chat page](https://github.com/hari-vignesh214/personal-chatbot/blob/main/templates/index.html): `templates/index.html`
- [Chat interactions](https://github.com/hari-vignesh214/personal-chatbot/blob/main/static/script.js): `static/script.js`
- [Dark-mode styling](https://github.com/hari-vignesh214/personal-chatbot/blob/main/static/style.css): `static/style.css`

### Chat backend

- [Flask routes](https://github.com/hari-vignesh214/personal-chatbot/blob/main/app.py): `app.py`
- [Attachment extraction](https://github.com/hari-vignesh214/personal-chatbot/blob/main/app.py): `app.py`
- [History formatting](https://github.com/hari-vignesh214/personal-chatbot/blob/main/app.py): `app.py`

### Conversation state

- **JSON conversation memory**

### Other components

- **Chat user**
- **Browser**
- **Gemini API**

## Connections

- Chat user → Browser: uses (evidence: `README.md`)
- Browser → Chat page: opens (evidence: `README.md`)
- Chat page → Chat interactions: hosts
- Chat interactions → Flask routes: sends chat requests (evidence: `static/script.js`)
- Flask routes → Chat page: renders (evidence: `app.py`)
- Flask routes → Attachment extraction: extracts uploads (evidence: `app.py`)
- Flask routes → JSON conversation memory: loads and saves (evidence: `app.py`)
- Flask routes → History formatting: formats history (evidence: `app.py`)
- History formatting → Gemini API: provides context (evidence: `app.py`)
- Flask routes → Gemini API: requests reply (evidence: `app.py`)
- Chat interactions → Flask routes: loads or clears memory (evidence: `static/script.js`)
- Dark-mode styling → Chat page: styles
