# ps428/amy architecture

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

- Interactive diagram: https://gitdiagram.com/ps428/amy
- Repository: https://github.com/ps428/amy

## Overview

##### Project Type and Purpose
- AMY is clearly a full-stack mobile (and web) application built in Flutter.
- Its purpose is to allow students to donate their unused mess card balance as meals to people in need (e.g., gardeners, guards).
- The README and file structure show two distinct sections for users and administrators, along with backend Firebase integration (authentication, database, etc.).

##### File Structure
- Top-Level Directories:
– “Flutter/amy” and “amy” directories contain similar structures for Flutter application code (Android, iOS, web).
– Assets such as fonts, images, and logos are stored in the “Assets” directory and in each app’s assets folder.
- Code Organization:
– The “lib” directory holds the main Dart source files.
– Inside “lib”, separate routing directories for “admin” and “user” flows indicate a clean separation of concerns (e.g., AHomeScreen vs. UHomeScreen, donation flows, etc.).
– Shared services and utilities include files like authentication_service.dart, firebase_options.dart, constants.dart, and validator.dart.
- Environmental and Build Configurations:
– Standard Flutter configurations (pubspec.yaml, android/ and ios/ projects, firebase.json) are present.
– The presence of directories for web (public and Flutter/amy/web) means that web targets are supported too.

##### Extract Architectural Insights From the README
- The README explains the purpose and gives details on the different UI pages (loading, login, signup, user home, donation confirmation, admin screens such as billing, inventory, etc.).
- It describes the navigation flow for both user and admin sides and emphasizes Firebase for authentication and data handling.
- The layout of the file structure and the provided screenshots hint at a layered architecture: UI presentation, routing & navigation, business logic (services like authentication), and backend integration (Firebase).

a. Main Components
– Flutter Mobile & Web Client: Represented by the UI modules/screens.
- User Interface: Login, Signup, Home, Donation, Confirmation, My Account, etc.
- Admin Interface: Admin home, Serve Meal, Billing, Inventory.
– Backend / Cloud Services:
- Firebase Authentication
- Firebase Database/Firestore (for donation records, user data, admin actions)
- Firebase Hosting/Storage (if used for assets)
– Supporting Assets: Fonts, images, and other media assets stored locally and potentially served via Firebase or CDN.

b. Relationships and Interactions
– The Flutter client (both user and admin channels) communicates with the Firebase backend.
– Requests for authentication, donation submissions, and admin actions are sent from the UI to the authentication service and Firebase services.
– Navigation components (routed via the “lib/routes” directories) direct flows between screens.
– The Firebase configuration (via firebase_options.dart) acts as a connector between the app and Firebase’s services.

c. Architectural Patterns and Design Principles
– Separation of Concerns: Distinguish between UI (screens and widgets), routing logic (organized in separate route folders), and service layers (authentication, Firebase integrations).
– MVC/MVVM-like Pattern: Although Flutter inherently uses a widget-based architecture, logically separate the presentation (UI screens) and business logic (services, validators).
– Modular Routing: Clear division of user and admin flows simplifies mapping and maintenance.
– Use of External Services: Dependency on Firebase for authentication and database operations is central.

d. Of Relevant Technologies, Frameworks, and Libraries
– Flutter (for cross-platform mobile, web, and desktop UI)
– Firebase (Auth, Database/Firestore, Storage, Hosting)
– Dart (programming language)
– Standard Flutter libraries and any additional packages from pubspec.yaml (for charts, animations like confetti, etc.)

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["App Entry Point"]:::routing
    R["Routing & Navigation"]:::routing
    U["Flutter Client (User Interface)"]:::client
    subgraph "User Screens"
        U1["Home Screen"]
        U2["Donation Page"]
        U3["Account Screen"]
        U4["Confirmation Screen"]
    end
    AD["Flutter Client (Admin Interface)"]:::client
    subgraph "Admin Screens"
        AD1["Home Screen"]
        AD2["Billing"]
        AD3["Inventory"]
        AD4["Meal Serving"]
    end
    AS["Authentication Service"]:::backend
    FI["Firebase Integration"]:::backend
    FB["Firebase Backend"]:::backend
    subgraph "Firebase Services"
        FA["Firebase Authentication"]
        FD["Cloud Firestore/Database"]
    end
    AM["Asset Management"]:::asset

    A --> R
    R --> U
    U --> U1
    U1 --> U2
    U2 --> U3
    U3 --> U4
    R --> AD
    AD --> AD1
    AD1 --> AD2
    AD2 --> AD3
    AD3 --> AD4
    U4 --> AS
    AD4 --> AS
    AS --> FI
    FI --> FB
    FB --> FA
    FB --> FD
    U --- AM
    AD --- AM

    click A "https://github.com/ps428/amy/blob/master/amy/lib/main.dart"
    click R "https://github.com/ps428/amy/tree/master/amy/lib/routes/"
    click U "https://github.com/ps428/amy/tree/master/amy/lib/routes/user/"
    click AD "https://github.com/ps428/amy/tree/master/amy/lib/routes/admin/"
    click AS "https://github.com/ps428/amy/blob/master/amy/lib/authentication_service.dart"
    click FI "https://github.com/ps428/amy/blob/master/amy/lib/firebase_options.dart"
    click AM "https://github.com/ps428/amy/tree/master/Assets"

    classDef client fill:#f9c,stroke:#333,stroke-width:2px;
    classDef backend fill:#bbf,stroke:#333,stroke-width:2px;
    classDef routing fill:#dfd,stroke:#333,stroke-width:2px;
    classDef asset fill:#ffd,stroke:#333,stroke-width:2px;
```
