# akshay-gurav-31/chatbot-helath architecture

> Architecture diagram of the GitHub repository akshay-gurav-31/chatbot-helath, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/akshay-gurav-31/chatbot-helath
- Repository: https://github.com/akshay-gurav-31/chatbot-helath

## Overview

##### Project type and purpose
- This is a monolithic full-stack web application built with Flask (Python) serving a single-page UI.
- Purpose: AI-powered health assistant that supports chat, image uploads, speech input, theming, session-based memory, and multi-language script detection.

##### File structure
Top-level:
- app.py               – Flask app entry point, defines routes, session handling, file uploads, and Gemini API calls
- script_detector.py   – Language/script detection logic (e.g., Hindi vs Marathi, Devanagari vs Roman)
- test_script_detection.py – Unit tests for the detection module
- requirements.txt     – Python dependencies (Flask, Gemini client, etc.)
- .env                 – Environment variable (GEMINI_API_KEY)
Directories:
- templates/index.html – Jinja2 HTML template for the chat UI
- static/app.js        – Vanilla JS: chat UI logic, Web Speech API integration, markdown rendering, theme toggle
- static/style.css     – CSS with variables for dark/light modes
- __pycache__          – Compiled Python bytecode

##### README for additional insights
- Backend: Flask sessions (UUID-based chat IDs), in-memory file handling, CSRF protection
- AI: Google Gemini 2.0 Flash via REST
- Frontend: Single-page chat interface, image attachments, voice input, markdown support, responsive design
- No persistent database—state lives in Flask session

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Browser)"
        direction TB
        HTML["index.html"]:::frontend
        JS["app.js"]:::frontend
        CSS["style.css"]:::frontend
        Browser["Client Browser UI"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Flask Server)"
        direction TB
        Flask["Flask Web Server"]:::backend
        Detector["script_detector.py"]:::backend
        Env[".env"]:::config
        Req["requirements.txt"]:::config
    end

    %% Session Store
    Session["Session Store"]:::datastore

    %% External AI Service
    subgraph "External Services"
        direction TB
        AI["Google Gemini API"]:::external
    end

    %% Testing and Documentation
    subgraph "Testing & Docs"
        direction TB
        Tests["test_script_detection.py"]:::testing
        Docs["README.md"]:::docs
    end

    %% Data Flows
    Browser -->|"HTTP GET /\nAJAX POST /chat,/upload"| Flask
    Flask -->|"calls analyze()"| Detector
    Detector --> Flask
    Flask -->|"read/write context"| Session
    Flask -->|"REST API call"| AI
    AI --> Flask
    Flask -->|"JSON response"| Browser
    Tests -->|"unit tests for"| Detector

    %% Click Events
    click HTML "https://github.com/akshay-gurav-31/chatbot-helath/blob/master/templates/index.html"
    click JS "https://github.com/akshay-gurav-31/chatbot-helath/blob/master/static/app.js"
    click CSS "https://github.com/akshay-gurav-31/chatbot-helath/blob/master/static/style.css"
    click Flask "https://github.com/akshay-gurav-31/chatbot-helath/blob/master/app.py"
    click Detector "https://github.com/akshay-gurav-31/chatbot-helath/blob/master/script_detector.py"
    click Env "https://github.com/akshay-gurav-31/chatbot-helath/blob/master/.env"
    click Req "https://github.com/akshay-gurav-31/chatbot-helath/blob/master/requirements.txt"
    click Tests "https://github.com/akshay-gurav-31/chatbot-helath/blob/master/test_script_detection.py"
    click Docs "https://github.com/akshay-gurav-31/chatbot-helath/blob/master/README.md"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#0366d6;
    classDef backend fill:#C8E6C9,stroke:#2e7d32;
    classDef datastore fill:#FFE0B2,stroke:#ef6c00,shape:cylinder;
    classDef external fill:#E1BEE7,stroke:#6a1b9a,shape:cloud;
    classDef config fill:#FFF9C4,stroke:#f9a825;
    classDef testing fill:#FFCDD2,stroke:#c62828;
    classDef docs fill:#E0E0E0,stroke:#424242;
```
