# md-ahmodullah/lifedrops architecture

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

- Interactive diagram: https://gitdiagram.com/md-ahmodullah/lifedrops
- Repository: https://github.com/md-ahmodullah/lifedrops

## Overview

##### Project Type and Purpose
- LifeDrops is a full-stack, MERN-style blood donation platform with a React single-page application (SPA) frontend, a Node/Express backend (not included in this repo but described in the README), MongoDB for data storage, Firebase for authentication and hosting, plus a Stripe (or similar) payment gateway for funding/donations.
- The React code is structured under `src/`, static JSON catalogs live in `public/`, and Firebase hosting configuration sits at the repo root.

##### File Structure Analysis
- Top-level files:
- `firebase.json`, `.firebaserc` → Firebase hosting & auth setup
- `vite.config.js`, `postcss.config.js`, `tailwind.config.js` → build/tooling
- `index.html`, `public/…` → entry point + static assets/data
- `src/Components`, `src/Pages`, `src/Layout` → UI components, page views, layout wrappers
- `src/Hooks` → custom data-fetching hooks (axios over public or secure API endpoints)
- `src/Provider` → React Context providers (Auth, Fund)
- `src/Router` → route definitions & guards (AdminRouter, PrivateRoute)
- `src/PaymentGateWay` → payment-related components (checkout form, funding flows)
- No backend code here—calls target externally hosted Express/Mongo API.

##### README Insights
- Core stack: React + TailwindCSS frontend, Node/Express API, MongoDB, Firebase Auth, Firebase Hosting.
- User roles: Admin, Donor, Volunteer
- Key features: authentication flows, role-based dashboards, CRUD on donation requests, blog CMS with Jodit, user management, status tracking, statistics dashboard, payment processing.

a. Main Components
- React SPA (Vite) deployed on Firebase Hosting
- Firebase Authentication service
- Node.js/Express REST API (hosted on e.g. Heroku, AWS, or GCP)
- MongoDB database (Atlas cluster)
- Stripe (or chosen payment gateway)
- Static JSON data store (served from Firebase Hosting)
- Third-party district/upazila JSON sources (public)
b. Relationships & Interactions
- User’s browser ↔ React SPA ↔ Firebase Auth (token flows)
- React SPA ↔ Express API (axiosPublic for open endpoints, axiosSecure for auth’d calls)
- Express API ↔ MongoDB (CRUD operations on users, requests, blogs, stats)
- React SPA ↔ Stripe (via CheckoutForm component)
- React SPA ↔ static JSON in `public/` (to populate district/upazila dropdowns)
c. Architectural Patterns
- SPA with client-side routing (React Router)
- Context-driven state management (AuthProvider, FundProvider)
- Custom hooks for data fetching and caching
- Role-based route protection (PrivateRoute, AdminRouter)
- Separation of concerns: Components / Pages / Layout / Hooks / Providers / Router
d. Key Technologies
- React + React Router + Context API
- Axios for HTTP clients (`useAxiosPublic`, `useAxiosSecure`)
- TailwindCSS for styling, Jodit for rich-text editing
- Firebase Auth & Hosting
- Node.js + Express + MongoDB for backend
- Stripe (or equivalent) for payments

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Browser
    Browser["User's Browser"]:::external

    %% SPA Subgraph
    subgraph "React SPA (Vite)" 
        direction TB
        Entry["src/main.jsx"]:::frontend
        Providers["AuthProvider & FundProvider"]:::frontend
        Hooks["useAxiosPublic & useAxiosSecure"]:::frontend
        Router["Client-Side Routing & Guards"]:::frontend
        Layouts["HomeLayout & DashboardLayout"]:::frontend
        Pages["Page Views & Components"]:::frontend
    end

    %% Cloud Services Subgraph
    subgraph "Cloud Services"
        direction TB
        Hosting["Firebase Hosting"]:::external
        AuthService["Firebase Auth"]:::external
        StaticJSON["Static JSON (/public/*.json)"]:::external
        Stripe["Stripe Payment Gateway"]:::external
    end

    %% Backend Subgraph
    subgraph "Backend Services"
        direction TB
        API["Node.js/Express API"]:::backend
        DB["MongoDB Atlas"]:::backend
    end

    %% Connections
    Browser -->|"loads SPA"| Entry
    Hosting -->|"serves SPA & static JSON"| Entry
    Hosting -->|serves| StaticJSON
    Entry -->|"initializes auth"| AuthService
    Entry -->|"wraps with providers"| Providers
    Providers -->|useContext| Router
    Router -->|renders layouts| Layouts
    Layouts -->|renders pages| Pages
    Pages -->|use hooks| Hooks
    Hooks -->|axiosPublic/axiosSecure| API
    Entry -->|"fetch geo-data"| StaticJSON
    Entry -->|"checkout flow"| Stripe
    Stripe -->|"webhook"| API
    API -->|"CRUD operations"| DB

    %% Click events
    click Entry "https://github.com/md-ahmodullah/lifedrops/blob/main/src/main.jsx"
    click Hosting "https://github.com/md-ahmodullah/lifedrops/blob/main/firebase.json"
    click AuthService "https://github.com/md-ahmodullah/lifedrops/blob/main/src/Firebase/firebase.init.js"
    click StaticJSON "https://github.com/md-ahmodullah/lifedrops/blob/main/public/index.html"
    click Hooks "https://github.com/md-ahmodullah/lifedrops/blob/main/src/Hooks/useAxiosPublic.jsx"
    click Hooks "https://github.com/md-ahmodullah/lifedrops/blob/main/src/Hooks/useAxiosSecure.jsx"
    click Providers "https://github.com/md-ahmodullah/lifedrops/blob/main/src/Provider/AuthProvider.jsx"
    click Providers "https://github.com/md-ahmodullah/lifedrops/blob/main/src/Provider/FundProvider.jsx"
    click Router "https://github.com/md-ahmodullah/lifedrops/blob/main/src/Router/Router.jsx"
    click Router "https://github.com/md-ahmodullah/lifedrops/blob/main/src/Router/PrivateRoute.jsx"
    click Router "https://github.com/md-ahmodullah/lifedrops/blob/main/src/Router/AdminRouter.jsx"
    click Layouts "https://github.com/md-ahmodullah/lifedrops/blob/main/src/Layout/HomeLayout.jsx"
    click Layouts "https://github.com/md-ahmodullah/lifedrops/blob/main/src/Layout/DashboardLayout.jsx"

    %% Styles
    classDef frontend fill:#e0f7fa,stroke:#006064,color:#006064
    classDef backend fill:#e8f5e9,stroke:#2e7d32,color:#2e7d32
    classDef external fill:#fff3e0,stroke:#ef6c00,color:#ef6c00
```
