# excessgone/fooddonationsystem architecture

> Architecture diagram of the GitHub repository excessgone/fooddonationsystem, 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/excessgone/fooddonationsystem
- Repository: https://github.com/excessgone/fooddonationsystem

## Overview

##### Main Components
- User Interface Layer:
- Activities: MainActivity, FormActivity, DetailActivity, AppearanceActivity, ProductionActivity, TechStackActivity.
- Fragments: MapFragment (displays nearby shelters using Google Maps API), HistoryFragment (shows a list of past donations), and AboutFragment.
- Layouts and menus defined in the res folder.
- Presentation Layer:
- This includes the Presentation package which handles the navigation among activities/fragments. It may also manage theming or other display-specific concerns.
- Data/Business Logic Layer:
- ViewModels and Models: Under Form_Models, you have FormViewModel and Forms classes that help bind UI data and manage state.
- Repository: Inside the Repository package, there’s FormRepository and FirebaseStorageManager. This layer abstracts volatile data flows to and from Firebase.
- External Services and APIs:
- Google Maps and Places API: Used in the MapFragment to locate nearby homeless shelters.
- Firebase: For storing and retrieving donation forms along with images.
- (Optionally SQLite is mentioned in the product spec for local persistence, though the repository currently focuses on remote data.)
- Utility & Configuration:
- Gradle build files, proguard rules, and manifest configurations that help manage dependencies and app behavior at runtime.

##### Relationships and Interactions
- The UI layer (activities and fragments) directly communicates with the Presentation and ViewModel layers to retrieve and display data.
- The FormViewModel mediates input from the UI, processing donations or fetching past records.
- The Repository interacts with Firebase (and possibly SQLite) to perform data operations.
- The MapFragment integrates with Google Maps/Places APIs to show real-time location data and nearby shelters.
- All layers are interconnected such that user interactions (e.g., submitting a form, tapping a list item) trigger a flow from UI → ViewModel → Repository → External Service, with data and responses flowing back along the same path.

##### Architectural Patterns and Design Principles
- MVVM (Model-View-ViewModel) Pattern: Evident from the use of FormViewModel and the separation between UI (activities/fragments) and data logic (repository and models).
- Repository Pattern: Centralized data access through FirebaseStorageManager and FormRepository.
- Clear Separation of Concerns: Dividing presentation, data handling, and external service integration into distinct packages.
- Modularization: The distinct packages (Presentation, Form_Models, Repository) suggest a design that encourages modularity and potential scalability.

##### Relevant Technologies and Frameworks
- Android SDK components (Activities, Fragments, Layouts, Resources)
- Gradle for build management and dependency handling.
- Google Maps API (and by extension, Google Places API) for location-based features.
- Firebase for data storage, image uploads, and realtime updates.
- (Possibly SQLite if implemented as per the product spec, though Firebase seems central.)

##### Instructing the Principal Software Engineer
- Use clear component labels for each module (e.g., “MainActivity”, “MapFragment”, “FormViewModel”, “FirebaseStorageManager”).
- Dependencies and interactions:
- How user interactions pass through the UI layer, leverage the ViewModel for state management, and then use repository components for data persistence and integration with Firebase.
- Major activities, fragments, view models, repository components, and external services.
- Optionally, include configuration/build components if relevant to overall understanding.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interface Layer"
        UI1("MainActivity"):::ui
        UI2("FormActivity"):::ui
        UI3("DetailActivity"):::ui
        UI4("MapFragment"):::ui
        UI5("HistoryFragment"):::ui
    end

    subgraph "Presentation Layer"
        PR1("AppearanceActivity"):::presentation
        PR2("ProductionActivity"):::presentation
        PR3("TechStackActivity"):::presentation
        PR4("AboutFragment"):::presentation
    end

    subgraph "Data/Business Logic Layer"
        BL1("FormViewModel"):::business
        BL2("Forms"):::business
        BL3("FormRepository"):::repository
        BL4("FirebaseStorageManager"):::repository
    end

    subgraph "External Services & APIs"
        EX1("Google Maps API"):::external
        EX2("Firebase"):::external
    end

    subgraph "Utility & Configuration"
        UT1("Gradle Build & Config Files"):::config
    end

    %% UI Layer interactions with Business Layer
    UI1 -->|"triggers"| BL1
    UI2 -->|"submitsData"| BL1
    UI3 -->|"viewsData"| BL1
    UI5 -->|"loadsRecords"| BL1
    UI4 -->|"requestsLocation"| EX1

    %% UI Layer navigates to Presentation components
    UI1 -->|"navigatesTo"| PR1
    UI1 -->|"navigatesTo"| PR2
    UI1 -->|"navigatesTo"| PR3
    UI1 -->|"navigatesTo"| PR4

    %% Business Logic interactions
    BL1 -->|"bindsData"| BL2
    BL1 -->|"fetchUpdate"| BL3
    BL3 -->|"managesDataVia"| BL4
    BL4 -->|"storesRetrieves"| EX2

    %% Utility & Configuration connections
    UT1 --- UI1
    UT1 --- PR1
    UT1 --- BL1
    UT1 --- BL3

    %% Click Events
    click UI1 "https://github.com/excessgone/fooddonationsystem/blob/main/app/src/main/java/com/example/excessgone/MainActivity.kt"
    click UI2 "https://github.com/excessgone/fooddonationsystem/blob/main/app/src/main/java/com/example/excessgone/FormActivity.kt"
    click UI3 "https://github.com/excessgone/fooddonationsystem/blob/main/app/src/main/java/com/example/excessgone/DetailActivity.kt"
    click PR1 "https://github.com/excessgone/fooddonationsystem/blob/main/app/src/main/java/com/example/excessgone/Presentation/AppearanceActivity.kt"
    click PR2 "https://github.com/excessgone/fooddonationsystem/blob/main/app/src/main/java/com/example/excessgone/Presentation/ProductionActivity.kt"
    click PR3 "https://github.com/excessgone/fooddonationsystem/blob/main/app/src/main/java/com/example/excessgone/Presentation/TechStackActivity.kt"
    click UI4 "https://github.com/excessgone/fooddonationsystem/blob/main/app/src/main/java/com/example/excessgone/MapFragment.kt"
    click UI5 "https://github.com/excessgone/fooddonationsystem/blob/main/app/src/main/java/com/example/excessgone/HistoryFragment.kt"
    click PR4 "https://github.com/excessgone/fooddonationsystem/blob/main/app/src/main/java/com/example/excessgone/Presentation/AboutFragment.kt"
    click BL1 "https://github.com/excessgone/fooddonationsystem/blob/main/app/src/main/java/com/example/excessgone/Form_Models/FormViewModel.kt"
    click BL2 "https://github.com/excessgone/fooddonationsystem/blob/main/app/src/main/java/com/example/excessgone/Form_Models/Forms.kt"
    click BL3 "https://github.com/excessgone/fooddonationsystem/blob/main/app/src/main/java/com/example/excessgone/Repository/FormRepository.kt"
    click BL4 "https://github.com/excessgone/fooddonationsystem/blob/main/app/src/main/java/com/example/excessgone/Repository/FirebaseStorageManager.kt"
    click UT1 "https://github.com/excessgone/fooddonationsystem/blob/main/app/build.gradle"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef presentation fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef business fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef repository fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef config fill:#D5DBDB,stroke:#566573,stroke-width:2px;
```
