# ayushwant/blood-donation-app architecture

> Architecture diagram of the GitHub repository ayushwant/blood-donation-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ayushwant/blood-donation-app
- Repository: https://github.com/ayushwant/blood-donation-app

## Overview

##### Main Components
- Mobile Client (Android App): This is the bulk of the project and includes:
– UI Layer: Represented by a wide range of Activities (LoginActivity, SplashScreen, ProfileActivity, etc.), Fragments (FeedFragment, MapFragment, etc.), and layout resources.
– Presentation Components: Adapters (for displaying lists such as chats, feeds, and requests) and Admin-specific components (Admin Activities and Fragments).
– Domain Model: Model classes (Donor, Feed, RequestHistory, Notification, etc.) that encapsulate the business logic.
– Service Components: Utilities and classes handling location (LocationUtils, NearbyPlacesSearch), asynchronous responses, and the Cloud Messaging service (MyFirebaseMessagingService).
- Backend Services:
– Firebase: For handling user authentication, data storage (user profiles, donation requests, feed information), and cloud messaging.
– Google Maps API: Integrated for displaying maps, locating nearby hospitals, pharmacies, etc.
- External Services & APIs:
– Google Services (google-services.json)
– Gradle build configurations for managing dependencies and build settings

##### Interactions and Relationships
- User Interactions: Users (donors and seekers) interact with the app through various screens (activities and fragments). For example, the DonorRegistrationFormActivity allows donors to register, and the PostBloodRequestFormActivity manages blood request submissions.
- Data Flow:
– Data is captured via user input in activities/forms.
– Model classes transform this data to be communicated to Firebase.
– Firebase handles authentication and data storage and sends notifications via the MyFirebaseMessagingService.
– The UI listens for push notifications and real-time updates to refresh the feed, chat, or list of available requests.
- Module Separation:
– The application is neatly divided into social (feed and chat), administrative, map/location, and registration modules.
– Activities and Fragments are distinguished by functionalities (regular user flow vs. admin-side for verifying donors and request details).

##### Important Architectural Patterns and Design Principles
- Layered Architecture: The project separates UI (activities, fragments, layouts), business logic (ModelClasses, Utilities), and external service interactions (Firebase, Google Maps API).
- Modularization: Different functionalities (donor registration, chat, feed, and maps) are split into separate folders and packages, indicating good separation of concerns.
- Use of Adapters: To mediate between the data (ModelClasses) and UI components (RecyclerViews/ListViews), demonstrating adherence to the Model-View pattern.
- Cloud Messaging: Integration with Firebase Cloud Messaging to enable push notifications is an important dynamic aspect of the system design.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile Client
    subgraph "Mobile Client (Android App)"
        %% UI Layer
        subgraph "UI Layer"
            UA("User Activities"):::ui
            AA("Admin Activities"):::ui
            UF("UI Fragments"):::ui
            MA("Map Activity"):::ui
            MF("Map Fragment"):::ui
        end
        %% Business/Domain Layer
        subgraph "Business Layer"
            DM("Domain Models"):::business
            AD("Adapters"):::business
        end
        %% Service/Integration Layer
        subgraph "Service Layer"
            FCM("Firebase Messaging"):::service
            LU("Location Utilities"):::service
        end
    end

    %% External Services
    subgraph "Backend & External Services"
        FS("Firebase Services"):::external
        GM("Google Maps API"):::external
    end

    %% Project Setup / Build Configuration
    subgraph "Project Setup"
        GS("google-services.json"):::config
        BG("build.gradle"):::config
        SG("settings.gradle"):::config
        GP("gradle.properties"):::config
        GW("gradlew"):::config
        WB("gradlew.bat"):::config
    end

    %% Connections within Mobile Client
    UA -->|"triggers"| DM
    AA -->|"admin_verify"| DM
    UF -->|"populates"| AD
    UA -->|"initiates"| FCM
    DM -->|"updates"| FS
    AD -->|"fetches"| FS

    %% Map related connections
    MA -->|"requestsLocation"| GM
    MF -->|"displaysMap"| GM
    LU -->|"locationQuery"| GM

    %% Service Layer and External Services
    FCM <-->|"push_notify"| FS

    %% Project Setup linking to Firebase Services
    GS -->|"configures"| FS
    BG -->|"build_config"| FS
    SG -->|"build_config"| FS
    GP -->|"build_config"| FS
    GW -->|"build_config"| FS
    WB -->|"build_config"| FS

    %% Class Definitions for styling
    classDef ui fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef business fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef service fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef config fill:#fefefe,stroke:#6c757d,stroke-width:2px;

    %% Click Events for UI Layer
    click UA "https://github.com/ayushwant/blood-donation-app/tree/main/BloodDonationApp/app/src/main/java/com/example/blooddonationapp/Activities"
    click AA "https://github.com/ayushwant/blood-donation-app/tree/main/BloodDonationApp/app/src/main/java/com/example/blooddonationapp/ActivitiesAdmin"
    click UF "https://github.com/ayushwant/blood-donation-app/tree/main/BloodDonationApp/app/src/main/java/com/example/blooddonationapp/Fragments"
    click MA "https://github.com/ayushwant/blood-donation-app/blob/main/BloodDonationApp/app/src/main/java/com/example/blooddonationapp/Activities/MapActivity.java"
    click MF "https://github.com/ayushwant/blood-donation-app/blob/main/BloodDonationApp/app/src/main/java/com/example/blooddonationapp/Fragments/MapFragment.java"

    %% Click Events for Business and Presentation Components
    click AD "https://github.com/ayushwant/blood-donation-app/tree/main/BloodDonationApp/app/src/main/java/com/example/blooddonationapp/Adapters"
    click DM "https://github.com/ayushwant/blood-donation-app/tree/main/BloodDonationApp/app/src/main/java/com/example/blooddonationapp/ModelClasses"

    %% Click Events for Service Components
    click FCM "https://github.com/ayushwant/blood-donation-app/blob/main/BloodDonationApp/app/src/main/java/com/example/blooddonationapp/CloudMessaging/MyFirebaseMessagingService.java"
    click LU "https://github.com/ayushwant/blood-donation-app/tree/main/BloodDonationApp/app/src/main/java/com/example/blooddonationapp/Utilities"

    %% Click Event for Firebase Integration
    click FS "https://github.com/ayushwant/blood-donation-app/blob/main/BloodDonationApp/app/google-services.json"

    %% Click Events for Build and Configuration Artifacts
    click GS "https://github.com/ayushwant/blood-donation-app/blob/main/BloodDonationApp/app/google-services.json"
    click BG "https://github.com/ayushwant/blood-donation-app/blob/main/BloodDonationApp/app/build.gradle"
    click SG "https://github.com/ayushwant/blood-donation-app/blob/main/BloodDonationApp/settings.gradle"
    click GP "https://github.com/ayushwant/blood-donation-app/blob/main/BloodDonationApp/gradle.properties"
    click GW "https://github.com/ayushwant/blood-donation-app/tree/main/BloodDonationApp/gradlew"
    click WB "https://github.com/ayushwant/blood-donation-app/blob/main/BloodDonationApp/gradlew.bat"
```
