# singhaakashdeep/healthcaredbmsproject architecture

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

- Interactive diagram: https://gitdiagram.com/singhaakashdeep/healthcaredbmsproject
- Repository: https://github.com/singhaakashdeep/healthcaredbmsproject

## Overview

##### Project Type & Purpose
- This is a full-stack, data-driven healthcare application with a Streamlit frontend, a Python-based backend (app.py), a PostgreSQL database extended with pgvector, and AI/LLM integration (Groq LLaMA 3 70B).
- Purpose: allow users to import patient and medical Q&A data, generate and store embeddings, perform vector searches, run natural-language SQL queries, and answer medical questions via RAG.

##### File Structure Analysis
- Top-level files:
- app.py – main Streamlit UI and request handling
- healthcareapp.env – environment variables (DB credentials, API key)
- medquad.csv (pre-loaded Q&A pairs) and patients.csv (importable patient data)
- requirements.txt, run_healthcare_app.bat
- No separate “frontend” or “backend” folders: the app.py monolith implements both UI and backend logic in layers.
- External dependencies and config files (env, requirements) hint at 3rd-party services: PostgreSQL + pgvector, Groq API, ragas.

##### Key Architecture from README
- Streamlit UI

- Patient Import (CSV) ──> Batch Embedding ──┐
- Q&A Import (CSV) ──────> Batch Embedding ──┘
- ↓
- PostgreSQL (pgvector) <── Vector Search ── AI Retrieval
- ↓
- AI SQL Agent ──> SQL ↔ Query Execution ↔ Data
- RAG Answering ──> Groq LLaMA 3 70B
- ↑
- Context from QA pairs

##### Diagramming Conventions
- Use rectangles for compute components (Streamlit, embedding pipeline, SQL agent).
- Blue: user-facing/UI
- Green: data storage/search
- Orange: AI/ML services
- Gray: pipelines/imports

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    User["User"]:::frontend

    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["Streamlit Frontend"]:::frontend
    end

    %% Data & AI Layer
    subgraph "Data & AI Layer"
        subgraph "Data Ingestion & Embeddings"
            CSV1["patients.csv"]:::data
            CSV2["medquad.csv"]:::data
            ImportPipeline["Import & Embedding Pipeline"]:::pipeline
        end
        subgraph "Vector Search & Storage"
            VectorSearch["Vector Search Module"]:::search
        end
        subgraph "Natural-Language SQL Agent"
            SQLAgent["AI SQL Agent"]:::ai
        end
        subgraph "Retrieval-Augmented Generation"
            RAGModule["RAG Answering Module"]:::ai
        end
    end

    %% Data Storage
    DB["PostgreSQL + pgvector DB"]:::db

    %% External & Config
    Env["healthcareapp.env"]:::config
    Cloud["Groq API"]:::external
    Fallback["Local Fallback"]:::external
    RAGEval["RAG Evaluation (ragas)"]:::eval

    %% Data Flows
    User --> UI
    UI --> ImportPipeline
    CSV1 --> ImportPipeline
    CSV2 --> ImportPipeline
    ImportPipeline --> DB
    UI --> SQLAgent
    SQLAgent --> DB
    DB --> SQLAgent
    SQLAgent --> UI
    UI --> RAGModule
    RAGModule --> DB
    DB --> RAGModule
    RAGModule --> Cloud
    Cloud --> RAGModule
    Fallback -.-> RAGModule
    Env --> DB
    Env --> Cloud
    RAGEval -->|"evaluates"| RAGModule
    RAGEval --> DB

    %% Click Events
    click UI "https://github.com/singhaakashdeep/healthcaredbmsproject/blob/main/app.py"
    click ImportPipeline "https://github.com/singhaakashdeep/healthcaredbmsproject/blob/main/app.py"
    click CSV2 "https://github.com/singhaakashdeep/healthcaredbmsproject/blob/main/medquad.csv"
    click DB "https://github.com/singhaakashdeep/healthcaredbmsproject/blob/main/healthcareapp.env"
    click VectorSearch "https://github.com/singhaakashdeep/healthcaredbmsproject/blob/main/app.py"
    click SQLAgent "https://github.com/singhaakashdeep/healthcaredbmsproject/blob/main/app.py"
    click RAGModule "https://github.com/singhaakashdeep/healthcaredbmsproject/blob/main/app.py"
    click Cloud "https://github.com/singhaakashdeep/healthcaredbmsproject/blob/main/healthcareapp.env"
    click RAGEval "https://github.com/singhaakashdeep/healthcaredbmsproject/blob/main/requirements.txt"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef data fill:#90EE90,stroke:#000,stroke-width:1px
    classDef pipeline fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef db fill:#90EE90,stroke:#000,stroke-width:1px
    classDef search fill:#90EE90,stroke:#000,stroke-width:1px
    classDef ai fill:#FFA500,stroke:#000,stroke-width:1px
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5
    classDef config fill:#D3D3D3,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5
    classDef eval fill:#FFA500,stroke:#000,stroke-width:1px,stroke-dasharray: 2 2
```
