# osammmakhan/ezhealth-flutter architecture

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

- Interactive diagram: https://gitdiagram.com/osammmakhan/ezhealth-flutter
- Repository: https://github.com/osammmakhan/ezhealth-flutter

## Overview

##### Project Type & Purpose
- ezHealth is a cross-platform, full-stack mobile application built with Flutter.
- Its primary goal is to streamline healthcare appointment scheduling and management, offering separate modules for patients, doctors, and administrators.
- Key functionalities include appointment booking, real-time notifications, schedule management, payment processing, and Firebase integration for authentication and database operations.

##### Analyzing the File Structure
- The project features platform-specific directories (android, ios, linux, macos, windows, web) which indicate that the Flutter codebase is deployed across multiple platforms.
- The core application logic and UI are located in the lib/ directory. Within lib, there are subdirectories that denote clear separation of concerns:
- lib/patient, lib/doctor, and lib/admin: each contains screen and UI components specific to their roles.
- lib/providers: Implements state management (using Provider) for handling appointment and payment states.
- lib/services: Contains Firebase integration and service communication methods.
- lib/assets: Houses constants, images, and even a demo video illustrating the app features.
- Additional files like pubspec.yaml and project-specific configuration files indicate dependency management and build settings.

##### Key Components
a. Frontend (Flutter Client):
- UI Layer: Screens for onboarding, authentication, patient appointment booking, patient home, doctor home, admin home, and notifications.
- Cross-platform support: Indicate that the same Flutter code is deployed on Android, iOS, Web, Linux, Windows, and MacOS.
b. State Management Layer:
- Provider modules (appointment_provider.dart and payment_provider.dart) that manage data flow and state across the application.
c. Firebase Backend:
- Authentication: Handles secure login/registration.
- Firestore (Real-time Database): Manages appointments, notifications, and other dynamic data.
- Firebase Services: Represented by the firebase_service.dart which abstracts the Firebase operations.
d. External Integrations:
- Firebase notifications and messaging for real-time updates.
- Payment gateway components within the patient module (payment_methods_screen, payment_details_screen).

##### Relationships & Interactions
- The UI components (screens) interact with the Provider state management components to update and retrieve the state.
- Providers make service calls to the Firebase module for authentication, database reads/writes, and real-time notifications.
- Multiple user roles (Patient, Doctor, Admin) are clearly separated in both UI and logical modules, with the main entry point defined in lib/main.dart.

##### Architectural Patterns & Design Principles
- Separation of Concerns: Different directories clearly separate UI, state management, and services.
- MVVM/MVC-ish Pattern: UI screens (Views), Providers (ViewModels/Controllers) and Firebase services (Models/Backend integration) can be illustrated.
- Cross-platform Development: One codebase (Flutter) targets multiple operating systems.
- Secure & Scalable: Use of Firebase for secure authentication and real-time data operations is an important design aspect.

##### Relevant Technologies & Frameworks
- Flutter: For building the cross-platform UI.
- Provider: For state management across modules.
- Firebase (Authentication, Firestore, Notifications): Serves as the cloud backend.
- Native platform folders (android, ios, etc.) emphasize the deployment targets.

##### Specific Elements
- Clear labels: Each component (e.g., “Flutter UI – Patient Home Screen”, “Provider – Appointment”, “Firebase Authentication”, “Firestore Database”) should be clearly marked.
- Modular Sections: Separate modules for Patient, Doctor, and Admin along with shared services like authentication and notifications.

## Diagram (Mermaid)

```mermaid
flowchart TD
    U["User Interaction"]:::user
    M["Main Entry (Flutter Entry)"]:::main
    OB["Onboarding Screen"]:::ui
    AU["Authentication Module"]:::ui
    PT["Flutter UI – Patient Screens"]:::ui
    DT["Flutter UI – Doctor Screens"]:::ui
    AD["Flutter UI – Admin Screens"]:::ui
    NT["Notification Screen"]:::ui
    AS["UI & Asset Resources"]:::asset
    AP["Appointment Provider"]:::provider
    PP["Payment Provider"]:::provider
    FB["Firebase Integration/Services"]:::backend
    DP["Deployment Platforms&#10;(Android, iOS, Web, Linux, Windows, MacOS)"]:::platform

    subgraph "Client - Flutter UI"
        M
        OB
        AU
        PT
        DT
        AD
        NT
        AS
    end

    subgraph "State Management"
        AP
        PP
    end

    subgraph "Firebase Backend"
        FB
    end

    subgraph "Deployment"
        DP
    end

    U -->|"starts"| M
    M -->|"shows"| OB
    M -->|"shows"| AU
    OB -->|"leads_to"| AU
    AU -->|"routes_to"| PT
    AU -->|"routes_to"| DT
    AU -->|"routes_to"| AD
    PT -->|"updates"| AP
    PT -->|"updates"| PP
    DT -->|"updates"| AP
    AD -->|"updates"| AP
    AP -->|"calls"| FB
    PP -->|"calls"| FB
    FB -->|"pushes"| NT
    M -->|"uses"| AS
    M -->|"deployed_on"| DP

    click M "https://github.com/osammmakhan/ezhealth-flutter/blob/main/lib/main.dart"
    click OB "https://github.com/osammmakhan/ezhealth-flutter/blob/main/lib/onboarding_screen.dart"
    click AU "https://github.com/osammmakhan/ezhealth-flutter/blob/main/lib/auth.dart"
    click PT "https://github.com/osammmakhan/ezhealth-flutter/tree/main/lib/patient"
    click DT "https://github.com/osammmakhan/ezhealth-flutter/tree/main/lib/doctor"
    click AD "https://github.com/osammmakhan/ezhealth-flutter/tree/main/lib/admin"
    click AP "https://github.com/osammmakhan/ezhealth-flutter/blob/main/lib/providers/appointment_provider.dart"
    click PP "https://github.com/osammmakhan/ezhealth-flutter/blob/main/lib/providers/payment_provider.dart"
    click FB "https://github.com/osammmakhan/ezhealth-flutter/blob/main/lib/services/firebase_service.dart"
    click AS "https://github.com/osammmakhan/ezhealth-flutter/tree/main/lib/assets"
    click NT "https://github.com/osammmakhan/ezhealth-flutter/blob/main/lib/notification_screen.dart"

    classDef ui fill:#D1E8FF,stroke:#333,stroke-width:2px;
    classDef provider fill:#FFEEAD,stroke:#333,stroke-width:2px;
    classDef backend fill:#C1FFC1,stroke:#333,stroke-width:2px;
    classDef asset fill:#FFD1DC,stroke:#333,stroke-width:2px;
    classDef main fill:#FFE4B5,stroke:#333,stroke-width:2px;
    classDef user fill:#E6E6FA,stroke:#333,stroke-width:2px;
    classDef platform fill:#E0FFFF,stroke:#333,stroke-width:2px;
```
