# nirajkumardangi/food-donation architecture

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

- Interactive diagram: https://gitdiagram.com/nirajkumardangi/food-donation
- Repository: https://github.com/nirajkumardangi/food-donation

## Overview

##### Project Type and Purpose
- Type: Full-stack SPA (Single Page Application)
- Purpose: Allow donors to list food donations and recipients (shelters, food banks) to browse, request, and schedule pickups.
- Backend: Serverless (Firebase for Auth, Database, Hosting)
- External APIs: Google Maps for geolocation and directions

##### Main Components
A. Client / Frontend
- Browser / User Device
- React Application (built with Vite + Tailwind CSS)
- UI Component Library (src/Ui)
- Pages & Route Components (src/pages)
- Feature Components (src/components: Dashboard, Donation, Home, etc.)
- State Management & Utilities (ReduxStore.jsx, Storage.jsx)
B. Backend / Serverless Services
- Firebase Authentication
- Firebase Firestore (or Realtime Database)
- Firebase Hosting
C. External Services
- Google Maps API
D. Third-Party Integrations
- Browser Local Storage (via Storage.jsx)

##### Relationships and Data Flows
- User → React App:
– Authentication flows (login/register) call Firebase Auth SDK
– Navigation between pages triggers data fetches
- React App → Firebase Database:
– CRUD operations for donations, requests, user profiles
– Real-time listeners for notifications and status updates
- React App → Google Maps API:
– Geocoding addresses, displaying maps, plotting donation drop-off points
- React App (Redux Store) manages global state (authenticated user, donation listings, notifications)

##### Architectural Patterns and Design Principles
- Component-based UI: Broken into reusable “Ui” primitives and feature-specific components
- Container-presentational split: Pages orchestrate data; UI components handle rendering
- Unidirectional data flow: React → Redux → Components → Firebase
- Serverless micro-services: No custom backend servers; Firebase handles all backend concerns
- Real-time updates: Observer pattern via Firebase listeners

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Hosting
    User["User Browser"]:::external
    HostingNode["Firebase Hosting"]:::backend
    User -->|HTTPS| HostingNode
    HostingNode -->|serves index.html| ReactApp["React SPA"]:::frontend

    %% React Application Core
    subgraph "React Application Core"
        Index["index.html"]:::frontend
        Main["src/main.jsx"]:::frontend
        App["src/App.jsx"]:::frontend
    end
    ReactApp --> Index
    ReactApp --> Main
    ReactApp --> App

    %% Frontend Application Layers
    subgraph "Frontend Application"
        subgraph "Presentation Layer"
            UiLib["UI Component Library"]:::frontend
            Pages["Pages & Routes"]:::frontend
        end
        Redux["Redux Store & Utilities"]:::state
        LocalStorage["Local Storage (Storage.jsx)"]:::state
    end
    ReactApp --> UiLib
    ReactApp --> Pages
    ReactApp --> Redux
    ReactApp --> LocalStorage

    %% Serverless Backend
    subgraph "Serverless Backend (Firebase)"
        Auth["AuthService (Firebase Auth)"]:::backend
        DB["Firestore (Firebase Database)"]:::backend
        FirebaseSetup["firebaseSetUp.jsx"]:::backend
    end
    ReactApp -->|Firebase Auth SDK| Auth
    ReactApp -->|Firestore SDK| DB
    ReactApp --> FirebaseSetup
    Auth -->|Realtime Events| ReactApp
    DB -->|Realtime Listeners| ReactApp

    %% External API
    GoogleMaps["Google Maps API"]:::external
    ReactApp -->|HTTPS REST| GoogleMaps

    %% Click Events
    click Index "https://github.com/nirajkumardangi/food-donation/blob/main/index.html"
    click Main "https://github.com/nirajkumardangi/food-donation/blob/main/src/main.jsx"
    click App "https://github.com/nirajkumardangi/food-donation/blob/main/src/App.jsx"
    click UiLib "https://github.com/nirajkumardangi/food-donation/tree/main/src/Ui"
    click Pages "https://github.com/nirajkumardangi/food-donation/tree/main/src/pages"
    click Redux "https://github.com/nirajkumardangi/food-donation/blob/main/src/utility/ReduxStore.jsx"
    click LocalStorage "https://github.com/nirajkumardangi/food-donation/blob/main/src/utility/Storage.jsx"
    click FirebaseSetup "https://github.com/nirajkumardangi/food-donation/blob/main/src/utility/firebaseSetUp.jsx"

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#90CAF9,stroke-width:1px
    classDef state fill:#FFF3E0,stroke:#FFB74D,stroke-width:1px
    classDef backend fill:#E8F5E9,stroke:#66BB6A,stroke-width:1px
    classDef external fill:#F3E5F5,stroke:#AB47BC,stroke-width:1px
```
