# yashendra767/pulsesync architecture

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

- Interactive diagram: https://gitdiagram.com/yashendra767/pulsesync
- Repository: https://github.com/yashendra767/pulsesync

## Overview

##### Project type and purpose
- From the file tree and README, PulseSync is a full-stack Android hospital management application.
- It consists of an Android (Kotlin) client (“app/” directory) and a Firebase-based backend (Firestore, Authentication, Cloud Functions in “functions/”).
- Its purpose is to support four user roles (Admin, Doctor, Nurse, Pharmacist) for admissions, bed management, inventory, dispensing, reporting, and notifications.

##### File structure
- Top-level:
- app/ – Android Studio project (Gradle, Kotlin sources, resources, layouts, navigation graph, tests, google-services.json)
- functions/ – Node.js Cloud Functions for notifications or business-logic hooks
- firebase.json/.firebaserc – Firebase CLI config
- build scripts and Gradle settings
- app/src/main/java/com/example/pulsesync – separated by feature and by user role packages (beds/, doctor/, nurse/, pharmacist/, reports/, user_manage/) indicating a modular, MVVM-style layering in code.
- app/src/main/res – Material Design layouts, drawables, menus, navigation graph.
- Presence of MyFirebaseMessagingService.kt for FCM and various adapters for lists.

##### README for additional insights
- Firebase collections: users, beds, admissions, inventory, tasks, alerts, dispensing_history, doctors, reports
- Uses Firebase Auth, Firestore, planned Cloud Functions for notifications, plus third-party libs (MPAndroidChart, ZXing, Glide, Cloudinary, OkHTTP3).
- Architecture stated as “Modular architecture with separate Activities and Fragments per user role” and “MVVM architecture (partially implemented).”

## Diagram (Mermaid)

```mermaid
graph TB
    %% Android Client
    subgraph "Android Client App"
        direction TB
        subgraph "UI Layer"
            direction TB
            MA["MainActivity"]:::ui
            HM["Home"]:::ui
            PR["Profile"]:::ui
            ST["Settings"]:::ui
            LI["login"]:::ui
            SU["SignUp"]:::ui
            FP["ForgotPass"]:::ui
            NG["nav_graph.xml"]:::ui
        end
        subgraph "Feature Modules"
            direction TB
            BEDS["Beds Feature Module"]:::ui
            DOCT["Doctor Feature Module"]:::ui
            NURS["Nurse Feature Module"]:::ui
            PHAR["Pharmacist Feature Module"]:::ui
            REPT["Reports Feature Module"]:::ui
            USRM["User Management Module"]:::ui
        end
        subgraph "ViewModel & Controllers"
            direction TB
            VM["ViewModel Layer"]:::viewmodel
        end
        subgraph "Data Layer"
            direction TB
            AR["AuthRepository"]:::data
            FR["FirestoreRepository"]:::data
            SR["StorageRepository"]:::data
            NC["NetworkClient"]:::data
            MS["MyFirebaseMessagingService"]:::data
        end
        %% Data flow client
        MA -->|uses| VM
        HM -->|uses| VM
        PR -->|uses| VM
        ST -->|uses| VM
        LI -->|auth via| AR
        SU -->|auth via| AR
        FP -->|auth via| AR
        BEDS -->|repo calls| FR
        DOCT -->|repo calls| FR
        NURS -->|repo calls| FR
        PHAR -->|repo calls| FR
        REPT -->|repo calls| FR
        USRM -->|repo calls| FR
        MS -->|receives FCM| VM
        VM -->|calls| AR
        VM -->|calls| FR
        VM -->|calls| SR
        VM -->|calls| NC
        VM -->|listens| MS
    end

    %% Firebase Backend
    subgraph "Firebase Backend"
        direction TB
        AUTH["Authentication Service"]:::cloud
        subgraph "Firestore Database"
            direction TB
            COL1["users"]:::database
            COL2["beds"]:::database
            COL3["admissions"]:::database
            COL4["inventory"]:::database
            COL5["tasks"]:::database
            COL6["alerts"]:::database
            COL7["dispensing_history"]:::database
            COL8["doctors"]:::database
            COL9["reports"]:::database
        end
        CF["Cloud Functions"]:::cloud
        FCM["Cloud Messaging (FCM)"]:::cloud
        STG["Storage/Cloudinary"]:::cloud
    end

    %% External Libraries
    subgraph "External Libraries & Services"
        direction TB
        ZX["ZXing (QR Scanner)"]:::external
        MP["MPAndroidChart"]:::external
        GL["Glide"]:::external
        CLD["Cloudinary"]:::external
        OK["OkHTTP3"]:::external
    end

    %% Flows between client and backend
    AR -->|authenticate| AUTH
    FR -->|read/write| COL1
    FR -->|read/write| COL2
    FR -->|read/write| COL3
    FR -->|read/write| COL4
    FR -->|read/write| COL5
    FR -->|read/write| COL6
    FR -->|read/write| COL7
    FR -->|read/write| COL8
    FR -->|read/write| COL9
    COL* -->|trigger| CF
    CF -->|push notifications via| FCM
    FCM -->|deliver| MS
    SR -->|upload/download| STG

    ZX -->|scans QR| VM
    MP -->|charts data from| FR
    GL -->|loads images via| SR
    CLD -->|media uploads via| SR
    OK -->|network calls| VM

    %% Styles
    classDef ui fill:#cce5ff,stroke:#005cbf,color:#000;
    classDef viewmodel fill:#99ccff,stroke:#004085,color:#000;
    classDef data fill:#66b2ff,stroke:#003366,color:#000;
    classDef backend fill:#d4edda,stroke:#155724,color:#000;
    classDef database fill:#c3e6cb,stroke:#19692c,color:#000;
    classDef cloud fill:#ffe5b4,stroke:#a85b00,color:#000;
    classDef external fill:#e2d6f0,stroke:#5b4177,color:#000;

    %% Click Events
    click BEDS "https://github.com/yashendra767/pulsesync/tree/origin/app/src/main/java/com/example/pulsesync/beds"
    click DOCT "https://github.com/yashendra767/pulsesync/tree/origin/app/src/main/java/com/example/pulsesync/doctor"
    click NURS "https://github.com/yashendra767/pulsesync/tree/origin/app/src/main/java/com/example/pulsesync/nurse"
    click PHAR "https://github.com/yashendra767/pulsesync/tree/origin/app/src/main/java/com/example/pulsesync/pharmacist"
    click REPT "https://github.com/yashendra767/pulsesync/tree/origin/app/src/main/java/com/example/pulsesync/reports"
    click USRM "https://github.com/yashendra767/pulsesync/tree/origin/app/src/main/java/com/example/pulsesync/user_manage"
    click MA "https://github.com/yashendra767/pulsesync/blob/origin/app/src/main/java/com/example/pulsesync/MainActivity.kt"
    click HM "https://github.com/yashendra767/pulsesync/blob/origin/app/src/main/java/com/example/pulsesync/Home.kt"
    click PR "https://github.com/yashendra767/pulsesync/blob/origin/app/src/main/java/com/example/pulsesync/Profile.kt"
    click ST "https://github.com/yashendra767/pulsesync/blob/origin/app/src/main/java/com/example/pulsesync/Settings.kt"
    click LI "https://github.com/yashendra767/pulsesync/blob/origin/app/src/main/java/com/example/pulsesync/login.kt"
    click SU "https://github.com/yashendra767/pulsesync/blob/origin/app/src/main/java/com/example/pulsesync/SignUp.kt"
    click FP "https://github.com/yashendra767/pulsesync/blob/origin/app/src/main/java/com/example/pulsesync/ForgotPass.kt"
    click NG "https://github.com/yashendra767/pulsesync/blob/origin/app/src/main/res/navigation/nav_graph.xml"
    click MS "https://github.com/yashendra767/pulsesync/blob/origin/app/src/main/java/com/example/pulsesync/MyFirebaseMessagingService.kt"
    click CF "https://github.com/yashendra767/pulsesync/blob/origin/functions/index.js"
    click CF "https://github.com/yashendra767/pulsesync/blob/origin/functions/package.json"
    click CF "https://github.com/yashendra767/pulsesync/blob/origin/functions/package-lock.json"
    click AUTH "https://github.com/yashendra767/pulsesync/blob/origin/.firebaserc"
    click AUTH "https://github.com/yashendra767/pulsesync/blob/origin/firebase.json"
    click STG "https://github.com/yashendra767/pulsesync/blob/origin/app/google-services.json"
    click AR "https://github.com/yashendra767/pulsesync/blob/origin/settings.gradle.kts"
    click AR "https://github.com/yashendra767/pulsesync/blob/origin/app/build.gradle.kts"
    click AR "https://github.com/yashendra767/pulsesync/blob/origin/gradle/libs.versions.toml"
```
