# aakash-jha3903/sanjeevni_ai__hack_191 architecture

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

- Interactive diagram: https://gitdiagram.com/aakash-jha3903/sanjeevni_ai__hack_191
- Repository: https://github.com/aakash-jha3903/sanjeevni_ai__hack_191

## Overview

##### Project Type & Purpose
- This is a monolithic, full-stack web application built with Python Django. It integrates AI/ML-based disease prediction, user authentication & role management, appointment booking, video consultations, and payment processing into one healthcare platform.

##### High-Level Architecture
- The system follows the classic three-tier pattern:
- Presentation Layer (Frontend: HTML, CSS, JS, Bootstrap/Tailwind)
- Application Layer (Backend: Django MVC apps)
- Data Layer (Database + File Storage)
- In addition, it interfaces with several external services (ML libraries, payment gateway, Jitsi, email/TTS).

##### Main Components
a. Client Browsers & Mobile (Patients, Doctors, Admins)
- Interact via web UI; static assets served from Django’s static file server (or a CDN in production).
b. Django Web Server
- URL Routing (appoint/urls.py)
- Apps:
- ML (disease prediction endpoints, model training scripts)
- account (user registration, authentication, profile, signals)
- appoint_app (appointment CRUD, video call orchestration)
- payments (Paystack integration, transaction models)
- theme (shared templates & CSS)
c. Database
- SQLite in development (db.sqlite3); replace with PostgreSQL/MySQL in production.
- Django ORM handles models in each app.
d. Media & Static File Storage
- Profile photos, uploads, ML static media (speech.mp3, video.mp4)
e. External Services
- ML/DL frameworks (Scikit-learn, TensorFlow)
- Text-to-Speech (gTTS)
- Video Conferencing (Jitsi)
- Payment Gateway (Paystack)
- Email/SMTP for password resets & prescriptions

##### Component Interactions & Data Flow
1. User → HTTP(S) Request → Web Server
- Static content (CSS/JS/images) served directly
- Dynamic pages handled via Django views
2. View Logic → Business Logic
- Authentication & session management (account app)
- Appointment logic & scheduling (appoint_app) → May trigger Jitsi URL generation
- Payment initiation (payments) → Redirect to Paystack, webhook callbacks
- ML inference (ML app) → Loads pre-trained model, processes input (symptoms CSV or MRI upload), returns predictions and precaution data
3. Business Logic → Data Layer
- Reads/writes to DB models (users, appointments, prescriptions, payments)
- Stores uploaded files in media folder or cloud storage
4. External API Calls
- TTS engine (gTTS) for nurse avatar voice
- SMTP for emails
- Paystack for payment confirmation
- Jitsi for video call sessions

##### Architectural Patterns & Principles
- Monolithic MVC: Clear separation between Models, Views, Templates.
- Modular Django apps: Each domain area encapsulated in its own app.
- Reusable templates via “theme” app.
- Asynchronous model training separated from inference (training scripts vs. real-time API).
- Use of signals for decoupled events (e.g., send email after prescription creation).

##### Detail Checklist
- User → Web Server → DB
- Web Server → ML inference → Web Server
- Web Server → Paystack ↔ Web Server (webhook)
- Web Server → Jitsi (video call) → Clients
- Web Server → SMTP/gTTS

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Clients(("Clients<br/>(Browser/Mobile)")):::client
        CDN(("CDN/Static Assets")):::client
    end

    %% Application Layer
    subgraph "Application Server" 
        direction TB
        WebServer["Django Web Server"]:::internal

        subgraph "Django Apps"
            direction TB
            MLApp["ML App"]:::internal
            AccountApp["Account App"]:::internal
            ApptApp["Appointment App"]:::internal
            PaymentsApp["Payments App"]:::internal
            ThemeApp["Theme App"]:::internal
        end

        URLs["Project URLs<br/>(appoint_master/appoint/urls.py)"]:::internal
    end

    %% Data & External Layer
    subgraph "Data & External Services"
        direction TB
        DB[(Database<br/>SQLite/PostgreSQL)]:::db
        MediaStorage["File Storage<br/>(Media)"]:::internal
        StaticStorage["Static Storage"]:::internal

        subgraph "External Services"
            direction TB
            Paystack["Paystack API"]:::external
            Jitsi["Jitsi Video"]:::external
            gTTS["gTTS TTS"]:::external
            SMTP["SMTP/Email"]:::external
            MLFrameworks["ML Frameworks<br/>(TensorFlow/Sklearn)"]:::external
        end
    end

    %% Connections
    Clients -->|"HTTPS"| WebServer
    CDN --> WebServer

    WebServer -->|routes via URLs| URLs
    URLs --> MLApp
    URLs --> AccountApp
    URLs --> ApptApp
    URLs --> PaymentsApp
    URLs --> ThemeApp

    MLApp -->|ORM read/write| DB
    AccountApp -->|ORM read/write| DB
    ApptApp -->|ORM read/write| DB
    PaymentsApp -->|ORM read/write| DB
    ThemeApp -->|serves templates| StaticStorage

    WebServer -->|serves media| MediaStorage
    WebServer -->|serves static| StaticStorage

    MLApp -->|loads models / inference| MLFrameworks
    MLApp -->|training scripts| MLFrameworks

    WebServer -->|Paystack init| Paystack
    Paystack -->|webhook callback| WebServer

    ApptApp -->|Jitsi token| Jitsi
    Jitsi --> Clients

    MLApp -->|TTS request| gTTS
    WebServer -->|SMTP emails| SMTP

    %% Click Events
    click MLApp "https://github.com/aakash-jha3903/sanjeevni_ai__hack_191/tree/main/appoint_master/ML/"
    click AccountApp "https://github.com/aakash-jha3903/sanjeevni_ai__hack_191/tree/main/appoint_master/account/"
    click ApptApp "https://github.com/aakash-jha3903/sanjeevni_ai__hack_191/tree/main/appoint_master/appoint_app/"
    click PaymentsApp "https://github.com/aakash-jha3903/sanjeevni_ai__hack_191/tree/main/appoint_master/payments/"
    click ThemeApp "https://github.com/aakash-jha3903/sanjeevni_ai__hack_191/tree/main/appoint_master/theme/"
    click URLs "https://github.com/aakash-jha3903/sanjeevni_ai__hack_191/blob/main/appoint_master/appoint/urls.py"
    click StaticStorage "https://github.com/aakash-jha3903/sanjeevni_ai__hack_191/tree/main/appoint_master/static/"
    click MediaStorage "https://github.com/aakash-jha3903/sanjeevni_ai__hack_191/tree/main/appoint_master/media/"
    click DB "https://github.com/aakash-jha3903/sanjeevni_ai__hack_191/blob/main/appoint_master/db.sqlite3"

    %% Styles
    classDef internal fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef external fill:#DFFFD6,stroke:#28a745,color:#28a745;
    classDef db fill:#FFF5BA,stroke:#DBAB09,color:#DBAB09;
    classDef client fill:#FFF0B3,stroke:#D97706,color:#D97706;
```
