# saiprashanth897/heathcare1 architecture

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

- Interactive diagram: https://gitdiagram.com/saiprashanth897/heathcare1
- Repository: https://github.com/saiprashanth897/heathcare1

## Overview

##### Project Components
- User Interface (Frontend) – This is evident from the large number of HTML files (e.g., landing page, login, doctor dashboard, patient dashboard, various reports, and trend pages) and associated CSS and JavaScript files. The “hackthon” directory consolidates these pages and static resources.
- Backend Services – Although there is no separate backend code repository, the README clearly explains that Firebase Firestore and Firebase Authentication serve as your backend, storing user details, patient records, rounds data, prescriptions, and ADR alerts.
- External Integrations – The project makes extensive use of third-party services:
- Chart.js for rendering data insights and trends.
- OpenAI API and the RxNav Interaction Checker for drug interaction and ADR detection.
- html2pdf.js for generating PDF reports.
- Data Storage – Firebase Firestore is used with specific collections such as users, patients, rounds, prescriptions, and adrAlerts.
- Authentication Module – Firebase Authentication manages secure access for doctors and patients, with additional workflows (e.g., admin approval for doctors).

- Frontend (Browser-based Application)
- Pages: Landing page, Login, Signup, Doctor Dashboard, Patient Dashboard, Reports, etc.
- Assets: HTML, CSS (found under multiple style folders), JavaScript files (organized in ‘js’ and ‘scripts’ directories).
- Interaction flows: Users perform authentication, access dashboards, view data insights (via Chart.js), and trigger ADR detection.
- Backend (Firebase Ecosystem)
- Authentication: Firebase Authentication handles the sign-in/up process.
- Database: Firestore collections storing user data, patients, rounds, prescriptions, and ADR alerts.
- Data Flow: The UI captures interactions (e.g., note additions and prescription updates) that create or update Firestore records.
- External Services
- ADR Detection: Integration with OpenAI API and RxNav API to check drug interactions, with JavaScript scripts (like adr.js) performing the logic.
- PDF Generation: html2pdf.js is used to convert end-of-day reports (likely rendered on a designated HTML page) into downloadable PDF documents.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The structure separates static UI pages and assets from backend functionality, even though the backend is largely managed via Firebase.
- Modular Components: Use of distinct directories for JS scripts, CSS styles, and HTML ensures that the UI codebase remains modular.
- API-Driven Integration: The application leverages multiple APIs to provide value-added features (ADR detection, charts, PDF generation).
- Client-Side Focused: Although the data and authentication layers are handled by Firebase, the majority of the logic appears to run client-side.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Subgraph
    subgraph "Frontend (UI)"
        LPage["Landing Page"]:::frontend
        Login["Login Page"]:::frontend
        Signup["Signup Page"]:::frontend
        DocDash["Doctor Dashboard UI"]:::frontend
        PatDash["Patient Dashboard UI"]:::frontend
        Reports["Reports Page UI"]:::frontend
        Trends["Symptom Trends UI"]:::frontend
        Assets["Static Assets (HTML/CSS/JS)"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend (Firebase)"
        FirebaseAuth["Firebase Authentication"]:::backend
        Firestore["Firestore Database"]:::backend
        FireUsers["Collection: users"]:::backend
        FirePatients["Collection: patients"]:::backend
        FireRounds["Collection: rounds"]:::backend
        FirePrescriptions["Collection: prescriptions"]:::backend
        FireADRs["Collection: adrAlerts"]:::backend
    end

    %% External Services Subgraph
    subgraph "External Services"
        ADRJS["ADR Detection (JS)"]:::external
        ADRScripts["ADR Detection (Scripts)"]:::external
        ChartJS["Chart.js (JS)"]:::external
        ChartScripts["Chart.js (Scripts)"]:::external
        PDFGen["html2pdf.js (PDF Generation)"]:::external
    end

    %% Relationships from Frontend to Backend
    Login -->|"auth"| FirebaseAuth
    Signup -->|"auth"| FirebaseAuth

    DocDash -->|"data"| Firestore
    PatDash -->|"data"| Firestore
    Reports -->|"data"| Firestore
    Trends -->|"data"| Firestore

    %% Relationships within Firestore (grouping collections)
    Firestore --> FireUsers
    Firestore --> FirePatients
    Firestore --> FireRounds
    Firestore --> FirePrescriptions
    Firestore --> FireADRs

    %% Relationships from Frontend to External Services
    DocDash -->|"ADRcheck"| ADRJS
    DocDash -->|"ADRcheck"| ADRScripts
    Trends -->|"chart"| ChartJS
    Trends -->|"chart"| ChartScripts
    Reports -->|"pdf"| PDFGen

    %% Click Events for Frontend Pages (User Interface)
    click LPage "https://github.com/saiprashanth897/heathcare1/blob/main/hackthon/landing page.html"
    click Login "https://github.com/saiprashanth897/heathcare1/blob/main/hackthon/login.html"
    click Signup "https://github.com/saiprashanth897/heathcare1/blob/main/hackthon/signup.html"
    click DocDash "https://github.com/saiprashanth897/heathcare1/blob/main/hackthon/doctor-dashboar.html"
    click PatDash "https://github.com/saiprashanth897/heathcare1/blob/main/hackthon/patient-dashboard.html"
    click Reports "https://github.com/saiprashanth897/heathcare1/blob/main/hackthon/reports.html"
    click Trends "https://github.com/saiprashanth897/heathcare1/blob/main/hackthon/symptom-trends.html"
    click Assets "https://github.com/saiprashanth897/heathcare1/tree/main/hackthon"

    %% Click Events for External Integrations (ADR Detection & Data Visualization)
    click ADRJS "https://github.com/saiprashanth897/heathcare1/blob/main/hackthon/js/adr.js"
    click ADRScripts "https://github.com/saiprashanth897/heathcare1/blob/main/hackthon/scripts/adr.js"
    click ChartJS "https://github.com/saiprashanth897/heathcare1/blob/main/hackthon/js/symptom-trends.js"
    click ChartScripts "https://github.com/saiprashanth897/heathcare1/blob/main/hackthon/scripts/symptom-trends.js"
    click PDFGen "https://github.com/saiprashanth897/heathcare1/blob/main/hackthon/reports.html"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#339,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#28a745,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#dc3545,stroke-width:2px;
```
