# dhruva-n-l-choudhary/quit_for_good architecture

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

- Interactive diagram: https://gitdiagram.com/dhruva-n-l-choudhary/quit_for_good
- Repository: https://github.com/dhruva-n-l-choudhary/quit_for_good

## Overview

##### Project Type and Purpose
- This is a full-stack, cross-platform mobile application built with Flutter (Dart) for the front-end and Firebase for the back-end.
- Purpose: Help users quit smoking by tracking progress, facilitating community chat, scheduling doctor appointments, and donating saved cigarette money to charities.

##### File Structure
- Top-level “android”, “ios”, “linux”, “macos”, “windows”, “web”: Platform-specific embedding of the Flutter app.
- “assets”: Fonts & images used by the UI.
- “lib/” directory:
- controllers/ — business-logic layer (ChatController, DonationController, etc.)
- models/ — data structures (ChatMessage, DonationPaymentModel, etc.)
- services/ — API/data-persistence layer interacting with Firebase (auth_services.dart, data_base_service.dart, db.dart)
- views/ — UI screens organized by feature (login, dashboard, chat, donation, profile, doctor appointments)
- widgets/ — reusable UI components (buttons, input fields, cards, tiles)
- Configuration:
- firebase_options.dart — Firebase project settings
- pubspec.yaml — dependencies (Flutter SDK, Firebase packages)

##### Insights from README
- Features include Registration/Login, Dashboard, Chat, Profile, Donation, Graphs, Doctor Appointment.
- Back-end: Firebase Authentication, Firestore (or Realtime DB), Cloud Messaging.
- No custom server; all data and messaging flows through Firebase services.

a. Main Components
- Mobile Front-end (Flutter app)
- UI Layer (Views & Widgets)
- Business Logic Layer (Controllers)
- Data Layer (Services & Models)
- Firebase Back-end
- Authentication Service
- Firestore Database
- Cloud Messaging (chat push notifications)
- (Optional) Cloud Functions for payment/email triggers
- External Payment/Donation Gateway (if used)
b. Relationships and Interactions
- UI → invokes Controllers
- Controllers → call Services
- Services ↔ Firebase Auth & Firestore
- Firestore ↔ Controllers (data stream for Dashboard, Chat)
- Cloud Messaging → delivers chat notifications to Flutter app
- Donation flow: Service → Payment Gateway → Service → Firestore
c. Architectural Patterns/Design Principles
- Layered architecture: Presentation → Business Logic → Data Access
- MVC-like separation: Views (UI), Controllers (logic), Models (data)
- Dependency injection (via passing services into controllers)
- Reactive streams: Firestore snapshots update UI automatically
d. Key Technologies/Frameworks
- Flutter (Dart)
- Firebase Auth, Firestore, Cloud Messaging, optionally Cloud Functions
- State management via Controllers (e.g., GetX, Provider, or you may choose another)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile App Layers
    subgraph "Mobile App (Flutter)"
        direction TB
        Main["Main (lib/main.dart)"]:::frontend
        subgraph "UI Layer"
            direction TB
            Views["Views (lib/views)"]:::frontend
            Widgets["Widgets (lib/widgets)"]:::frontend
        end
        subgraph "Business Logic (Controllers)"
            direction TB
            GlobalControllers["Controllers (lib/controllers)"]:::controller
            ChatCtrl["ChatController"]:::controller
            HomeCtrl["HomePageController"]:::controller
            DonationCtrl["DonationController"]:::controller
            SavingsCtrl["SavingsPaymentController"]:::controller
            GroupCtrl["GroupController"]:::controller
        end
        subgraph "Data Layer"
            direction TB
            ServicesSub["Services"]:::serviceGroup
            AuthService["AuthService (auth_services.dart)"]:::service
            DBService["DataBaseService (data_base_service.dart)"]:::service
            DBHelper["DB Helper (db.dart)"]:::service
            ModelsSub["Models"]:::modelGroup
            ChatModel["ChatMessage (ChatMessage.dart)"]:::model
            DonationModel["DonationPaymentModel (Donation_payment_model.dart)"]:::model
            SavingsModel["SavingsPaymentModel (Savings_payment_model.dart)"]:::model
            DoctorModel["DoctorDetailsModel (Doctor_details_model.dart)"]:::model
            CallModel["CallRequestModel (call_request_model.dart)"]:::model
        end
    end

    %% Firebase Back-end
    subgraph "Firebase Services"
        direction TB
        Auth["Authentication Service"]:::firebase
        Firestore["Firestore Database"]:::db
        Messaging["Cloud Messaging"]:::firebase
    end

    %% External Payment
    PaymentGW["Payment Gateway"]:::external

    %% Data Flows
    Main -->|initializes| Views
    Views -->|invokes| GlobalControllers
    GlobalControllers -->|calls| AuthService
    GlobalControllers -->|calls| DBService
    AuthService -->|auth operations| Auth
    AuthService -->|config| Firestore
    DBService -->|read/write| Firestore
    DBHelper -->|helpers| Firestore
    Firestore -->|data stream| GlobalControllers
    Messaging -->|push notifications| Views

    %% Donation Flow
    DonationCtrl -->|initiate payment| PaymentGW
    PaymentGW -->|confirmation| DBService
    DBService -->|store donation| Firestore

    %% Class Definitions
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef controller fill:#E6F7E6,stroke:#28A745,color:#1B5E20;
    classDef service fill:#FFF4CC,stroke:#FFB400,color:#665C00;
    classDef serviceGroup fill:#FFF8E1,stroke:#FFB400,color:#665C00;
    classDef model fill:#F0F0F0,stroke:#BDBDBD,color:#424242;
    classDef modelGroup fill:#F5F5F5,stroke:#BDBDBD,color:#424242;
    classDef firebase fill:#FFE8CC,stroke:#FB8C00,color:#E65100;
    classDef db fill:#E0F2F1,stroke:#00796B,color:#004D40;
    classDef external stroke-dasharray: 5 5,fill:#ECEFF1,stroke:#607D8B,color:#263238;

    %% Click Events
    click Main "https://github.com/dhruva-n-l-choudhary/quit_for_good/blob/main/lib/main.dart"
    click Views "https://github.com/dhruva-n-l-choudhary/quit_for_good/tree/main/lib/views"
    click Widgets "https://github.com/dhruva-n-l-choudhary/quit_for_good/tree/main/lib/widgets"
    click GlobalControllers "https://github.com/dhruva-n-l-choudhary/quit_for_good/tree/main/lib/controllers"
    click ChatCtrl "https://github.com/dhruva-n-l-choudhary/quit_for_good/blob/main/lib/views/chating/controller/chat_controller.dart"
    click HomeCtrl "https://github.com/dhruva-n-l-choudhary/quit_for_good/blob/main/lib/views/homepage/controller/home_page_controller.dart"
    click DonationCtrl "https://github.com/dhruva-n-l-choudhary/quit_for_good/blob/main/lib/controllers/donation_controller.dart"
    click SavingsCtrl "https://github.com/dhruva-n-l-choudhary/quit_for_good/blob/main/lib/controllers/savings_payment_controller.dart"
    click GroupCtrl "https://github.com/dhruva-n-l-choudhary/quit_for_good/blob/main/lib/controllers/group_controller.dart"
    click AuthService "https://github.com/dhruva-n-l-choudhary/quit_for_good/blob/main/lib/services/auth_services.dart"
    click DBService "https://github.com/dhruva-n-l-choudhary/quit_for_good/blob/main/lib/services/data_base_service.dart"
    click DBHelper "https://github.com/dhruva-n-l-choudhary/quit_for_good/blob/main/lib/services/db.dart"
    click ChatModel "https://github.com/dhruva-n-l-choudhary/quit_for_good/blob/main/lib/models/ChatMessage.dart"
    click DonationModel "https://github.com/dhruva-n-l-choudhary/quit_for_good/blob/main/lib/models/Donation_payment_model.dart"
    click SavingsModel "https://github.com/dhruva-n-l-choudhary/quit_for_good/blob/main/lib/models/Savings_payment_model.dart"
    click DoctorModel "https://github.com/dhruva-n-l-choudhary/quit_for_good/blob/main/lib/models/Doctor_details_model.dart"
    click CallModel "https://github.com/dhruva-n-l-choudhary/quit_for_good/blob/main/lib/models/call_request_model.dart"
```
