# dadiya-harsh/cure-now architecture

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

- Interactive diagram: https://gitdiagram.com/dadiya-harsh/cure-now
- Repository: https://github.com/dadiya-harsh/cure-now

## Overview

##### Project type and purpose
- This is a full-stack web application (“Cure-Now Health Chatbot”) with a Python/Flask backend and a static HTML/JS/CSS frontend.
- Its purpose is to serve as a medical chatbot: it takes user queries, issues vector-search lookups against a medical knowledge base, calls Google’s Gemini AI for answer generation, and returns responses in real time.

##### File structure
- Top-level:
- alembic/ → database migration scripts (SQLAlchemy + Alembic)
- backend/ → Flask application
- research/ → Jupyter notebook for experiments
- requirements.txt, README.md, .env template
- backend/app/ subfolders:
- routes/ → Flask blueprints (auth_routes.py, chat_routes.py, session_routes.py)
- models.py + config.py → SQLAlchemy models and configuration
- utils/ → embedding generation (Hugging Face), Pinecone ops, Gemini AI ops
- static/ + templates/ → frontend assets and Jinja2 templates
- backend/run.py → Flask application entrypoint

##### Review README insights
- Tech stack: Python/Flask, LangChain, Hugging Face embeddings, Pinecone vector DB, Google Gemini AI, HTML/CSS/JS frontend
- Features & flow: user → chat UI → Flask endpoints → utils (vector search + AI) → external services → UI

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend" 
        direction TB
        Browser["User's Web Browser"]:::frontend
        CSS["style.css"]:::frontend
        JS["main.js"]:::frontend
        ChatHTML["chat.html"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend" 
        direction TB
        run["Flask Entrypoint (run.py)"]:::backend

        subgraph "Presentation Layer"
            direction TB
            AuthRoutes["Auth Module (auth_routes.py)"]:::backend
            AuthCSS["auth.css"]:::frontend
            AuthJS["auth.js"]:::frontend
            RegisterPage["register.html"]:::frontend
            ResetPage["reset_password.html"]:::frontend
            IndexPage["index.html"]:::frontend
        end

        subgraph "Business Layer"
            direction TB
            SessionRoute["Session Module (session_routes.py)"]:::backend
            ChatRoute["Chat Module (chat_routes.py)"]:::backend
            Embeddings["Embeddings Service"]:::backend
            PineconeOps["Vector Store Connector"]:::backend
            GeminiOps["AI Connector"]:::backend
        end

        subgraph "Data Layer"
            direction TB
            Models["Models (models.py)"]:::datastore
            Config["Config (config.py)"]:::datastore
            subgraph "Migration Layer"
                direction TB
                AlembicEnv["env.py"]:::datastore
                AlembicScript["script.py.mako"]:::datastore
                AlembicVersions["versions/*.py"]:::datastore
            end
        end
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        SQLDB["Relational DB"]:::datastore
        PineconeDB["Pinecone Vector DB"]:::datastore
    end

    %% External Services
    subgraph "External Services"
        direction TB
        HuggingFace["Hugging Face API"]:::external
        GeminiAPI["Google Gemini API"]:::external
    end

    %% Connections
    Browser -->|"HTTP(S) Request"| run
    run --> AuthRoutes
    run --> SessionRoute
    run --> ChatRoute
    AuthRoutes -->|"CRUD"| Models
    SessionRoute -->|"CRUD"| Models
    ChatRoute --> Embeddings
    ChatRoute --> PineconeOps
    ChatRoute --> GeminiOps
    Models --> SQLDB
    Config --> SQLDB
    AlembicEnv --> SQLDB
    AlembicScript --> SQLDB
    AlembicVersions --> SQLDB
    Embeddings --> HuggingFace
    PineconeOps --> PineconeDB
    GeminiOps --> GeminiAPI
    run -->|"JSON Response"| Browser
    Browser --> CSS
    Browser --> JS
    Browser --> ChatHTML
    AuthRoutes --> AuthCSS
    AuthRoutes --> AuthJS
    AuthRoutes --> RegisterPage
    AuthRoutes --> ResetPage
    AuthRoutes --> IndexPage

    %% Click Events
    click Browser "https://github.com/dadiya-harsh/cure-now/blob/main/backend/app/static/css/style.css"
    click CSS "https://github.com/dadiya-harsh/cure-now/blob/main/backend/app/static/css/style.css"
    click JS "https://github.com/dadiya-harsh/cure-now/blob/main/backend/app/static/js/main.js"
    click ChatHTML "https://github.com/dadiya-harsh/cure-now/blob/main/backend/app/templates/chat.html"
    click run "https://github.com/dadiya-harsh/cure-now/blob/main/backend/run.py"
    click AuthRoutes "https://github.com/dadiya-harsh/cure-now/blob/main/backend/app/auth_routes.py"
    click AuthCSS "https://github.com/dadiya-harsh/cure-now/blob/main/backend/app/static/css/auth.css"
    click AuthJS "https://github.com/dadiya-harsh/cure-now/blob/main/backend/app/static/js/auth.js"
    click RegisterPage "https://github.com/dadiya-harsh/cure-now/blob/main/backend/app/templates/register.html"
    click ResetPage "https://github.com/dadiya-harsh/cure-now/blob/main/backend/app/templates/reset_password.html"
    click IndexPage "https://github.com/dadiya-harsh/cure-now/blob/main/backend/app/templates/index.html"
    click SessionRoute "https://github.com/dadiya-harsh/cure-now/blob/main/backend/app/routes/session_routes.py"
    click ChatRoute "https://github.com/dadiya-harsh/cure-now/blob/main/backend/app/routes/chat_routes.py"
    click Models "https://github.com/dadiya-harsh/cure-now/blob/main/backend/app/models.py"
    click Config "https://github.com/dadiya-harsh/cure-now/blob/main/backend/app/config.py"
    click AlembicEnv "https://github.com/dadiya-harsh/cure-now/blob/main/alembic/env.py"
    click AlembicScript "https://github.com/dadiya-harsh/cure-now/blob/main/alembic/script.py.mako"
    click AlembicVersions "https://github.com/dadiya-harsh/cure-now/blob/main/alembic/versions/*.py"
    click Embeddings "https://github.com/dadiya-harsh/cure-now/blob/main/backend/app/utils/embeddings.py"
    click PineconeOps "https://github.com/dadiya-harsh/cure-now/blob/main/backend/app/utils/pinecone_ops.py"
    click GeminiOps "https://github.com/dadiya-harsh/cure-now/blob/main/backend/app/utils/gemini_ops.py"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px;
    classDef datastore fill:#FFFF99,stroke:#333,stroke-width:1px;
    classDef external fill:#FFCC99,stroke:#333,stroke-width:1px;
```
