# priyanshidongre/ai-healthcare-chatbot architecture

> Architecture diagram of the GitHub repository priyanshidongre/ai-healthcare-chatbot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/priyanshidongre/ai-healthcare-chatbot
- Repository: https://github.com/priyanshidongre/ai-healthcare-chatbot

## Overview

##### Project type and purpose
- This is a lightweight, single-module AI-powered healthcare chatbot implemented in Python (app.py), intended to run as a web service (likely with Flask or FastAPI).
- It serves as a text-based interface for users to ask general health questions, leveraging an NLP pipeline.

##### File structure
- Top-level files only:
- app.py – the main web server and request-handling logic
- requirements.txt – Python dependencies (e.g., Flask/FastAPI, transformers, spaCy, etc.)
- README.md – project overview and roadmap
- No dedicated frontend folder—UI likely rendered via simple HTML templates or an API to a separate client.
- No database folder/config—persistence is not yet implemented.

##### README for additional insights
- Current scope: conversational chatbot with basic medical guidance
- Future features hint at: user-history storage, third-party appointment/medicine APIs, multilingual/voice support, video-chat service.

##### Core components
a. User Interface (Chat Client)
- Web browser or mobile app sending/receiving JSON or rendered HTML.
b. Web Server (app.py)
- HTTP endpoints for chat messages.
- Input validation, session management.
c. NLP Engine
- Local models or calls to external ML/AI services (e.g., Hugging Face, OpenAI API).
- Tokenization → Intent classification → Response generation.
d. Data Store (future)
- Conversation logs, user profiles, medical history.
- Could be a relational DB (PostgreSQL) or NoSQL (MongoDB).
e. External Services (future)
- Disease prediction API
- Appointment booking API
- Medicine suggestion API
- Translation/voice-processing service
- Video-chat platform

##### Relationships and interactions
- User → HTTP(S) → Web Server
- Web Server → NLP Engine (local or external)
- Web Server ↔ Data Store (for logging & history)
- Web Server → External Healthcare APIs (for booking, suggestions)
- Future: Web Server ↔ Voice/Translation Service; Web Server ↔ Video Chat Service

##### Architectural patterns/principles
- Layered architecture: Presentation (UI) → Application logic (Flask) → NLP/Service integrations → Data
- Separation of concerns: keep chat logic, NLP pipeline, and external/service integrations in distinct modules.
- Plan for microservices as features grow (e.g., a standalone “Booking Service” or “VideoChat Service”).

Then Backend ↔ Data Store, Backend → Appointment API, etc.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Client["Chat Client\n(Web Browser/Mobile)\nHTTP/JSON"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        Backend["Web Server\n(Flask 2.0)\napp.py"]:::backend
        NLP["NLP Engine\nTokenization\nIntentClassification\nResponseGeneration\n(spaCy v3, Transformers)"]:::backend
        ExtModule["External Services Module"]:::backend
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        direction TB
        DataStore["Data Store\n(PostgreSQL/MongoDB)\nRelational/NoSQL"]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        ExtAPIs["External Healthcare APIs\nDiseasePrediction, Appointment, MedicineSuggestion"]:::external
        VoiceService["Voice/Translation Service"]:::external
        VideoChat["Video Chat Service"]:::external
    end

    %% Project Files
    subgraph "Project Files"
        direction TB
        Requirements["Dependencies\nrequirements.txt"]:::docs
        Readme["Project Docs\nREADME.md"]:::docs
    end

    %% Connections
    Client -->|"HTTP/JSON"| Backend
    Backend -->|"processRequest()"| NLP
    NLP -->|"nlpResult"| Backend
    Backend -->|"HTTP/JSON"| Client
    Backend <-->|"log/history"| DataStore
    Backend -->|"REST API"| ExtAPIs
    Backend -->|"gRPC/REST"| VoiceService
    Backend -->|"WebRTC"| VideoChat

    %% Click Events
    click Backend "https://github.com/priyanshidongre/ai-healthcare-chatbot/blob/main/app.py"
    click Requirements "https://github.com/priyanshidongre/ai-healthcare-chatbot/blob/main/requirements.txt"
    click Readme "https://github.com/priyanshidongre/ai-healthcare-chatbot/blob/main/README.md"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px
    classDef data fill:#FFA500,stroke:#000,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef docs fill:#FFD700,stroke:#000,stroke-width:1px
```
