# syedshafinahmed/bloodlink-client architecture

> Architecture diagram of the GitHub repository syedshafinahmed/bloodlink-client, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/syedshafinahmed/bloodlink-client
- Repository: https://github.com/syedshafinahmed/bloodlink-client

## Overview

1. **Overall shape**
   - BloodLink is a **React 19 single-page application** built with **Vite**. It is a client-side UI for a blood donation platform rather than a full-stack repo.
   - The app is organized around three major user surfaces: **public marketing/browsing pages**, a **protected user dashboard**, and **admin management views**.

2. **App bootstrap and routing**
   - `src/main.jsx` is the entry point and mounts the app with global styles from `src/index.css`.
   - `src/routes/router.jsx` defines the route map, and `src/routes/PrivateRoute.jsx` guards authenticated areas.
   - Layout components split the UI shell by concern: `RootLayout` for the public site, `AuthLayout` for login/register screens, and `DashboardLayout` for authenticated dashboard pages.

3. **Authentication boundary**
   - Auth state is centralized in `src/context/AuthContext.jsx` / `AuthProvider.jsx` and consumed through `src/hooks/useAuth.jsx`.
   - Firebase is the authentication provider (`src/firebase/firebase.init.js`), so login/registration are client-side flows that establish the user session before protected routes and dashboard features become available.

4. **Public site and content pages**
   - `src/pages/home/*` contains the homepage sections: banner, feature blocks, impact stats, how-it-works, testimonials, donor-related promos, etc.
   - Other public pages include `AboutUs`, `Services`, donor search, and donation-request browsing/detail views.
   - `src/pages/shared/Navbar.jsx` and `Footer.jsx` provide the global site chrome across public routes.

5. **Donor discovery and location data**
   - Donor search is a core flow: the app lets users filter by **blood group** and **location**.
   - Location data is shipped as static JSON in `public/location.json`, and there are also `public/donors.json` and `public/serviceCenters.json` for reference data shown or consumed by the UI.
   - This means the donor-search experience is not purely dynamic; it has a built-in data layer for geographic filtering and directory-style browsing.

6. **Donation-request workflow**
   - The donation-request subsystem lives in `src/pages/HomeDonationRequests.jsx`, `src/pages/HomeDonationRequestsDetails.jsx`, and the dashboard counterparts under `src/dashboard/`.
   - Users can create, edit, inspect, and track requests; the README describes request states such as pending, in progress, done, and canceled.
   - This is one of the main business flows and likely talks to the backend via API calls rather than local state only.

7. **Dashboard subsystem**
   - `src/dashboard/DashboardHome.jsx`, `Profile.jsx`, `DonationRequests.jsx`, `CreateDonationRequest.jsx`, `EditDonationRequest.jsx`, and `DonationRequestDetails.jsx` form the authenticated user workspace.
   - `DashboardSkeleton.jsx` suggests shared loading/placeholder handling for dashboard views.
   - The dashboard is the main boundary where user-specific data, request management, and profile state are concentrated.

8. **Admin subsystem**
   - `src/dashboard/admin/AllUsers.jsx` and `AllDonationRequests.jsx` are the administrative views.
   - These pages indicate role-based authorization on top of authentication: normal users get their own dashboard, while admins can inspect or manage all users and all requests.
   - The admin area is therefore a second security boundary beyond simple login.

9. **Backend/API integration**
   - `src/hooks/useAxiosSecure.jsx` indicates a configured Axios client for authenticated backend calls.
   - The README references `VITE_API_URL`, so the frontend is designed to consume a separate API service for operational data such as requests, user records, and possibly funding history.
   - In architecture terms, the React app is a presentation layer that delegates business data operations to an external backend.

10. **Funding and payments**
   - `src/pages/FundingPage.jsx`, `FundingSuccess.jsx`, and `FundingCancel.jsx` show a separate payment flow with success/cancel return states.
   - The README says Stripe is used, so payment processing is an external checkout flow with callback/redirect handling in the SPA.
   - This funding path is distinct from the donation-request flow: one is a support/payment mechanism for the platform, the other is blood-request management.

11. **Cross-cutting UI concerns**
   - `src/loading/Loading.jsx` and `src/components/ScrollToTop.jsx` handle app-wide behavior rather than feature logic.
   - `src/toggle/Switch.jsx` suggests a theme or mode toggle, while `src/pages/shared/Navbar.jsx` likely exposes the primary navigation and user actions.
   - Styling is driven by TailwindCSS, with DaisyUI/MUI used for component-level UI patterns.

12. **Hosting and deployment behavior**
   - `public/_redirects` indicates the app is deployed as a static SPA on a host that needs client-side route fallback support.
   - `vite.config.js` and the Vite build pipeline shape the frontend deployment artifact.
   - The app is therefore packaged as static assets, with runtime dependencies on Firebase, Stripe, and the external API backend.

13. **Key architectural boundaries to draw**
   - **Unauthenticated public experience**: landing pages, search, service info, donor/request browsing.
   - **Authentication layer**: Firebase-backed login/register and route protection.
   - **User dashboard**: personal profile and donation-request lifecycle.
   - **Admin console**: global moderation and oversight.
   - **External services**: Firebase Auth, Stripe payments, and a backend API accessed through Axios.

Main entry points: [`src/layouts/DashboardLayout.jsx`](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/layouts/DashboardLayout.jsx) (Dashboard layout), [`src/layouts/RootLayout.jsx`](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/layouts/RootLayout.jsx) (Root layout), [`src/hooks/useAxiosSecure.jsx`](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/hooks/useAxiosSecure.jsx) (Secure API client), [`src/routes/router.jsx`](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/routes/router.jsx) (Router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bootstrap["Bootstrap & routing"]
  node_main["App entry<br/>bootstrap<br/>[main.jsx]"]
  node_router["Router<br/>routes<br/>[router.jsx]"]
  node_private_route{{"Private route<br/>guard<br/>[PrivateRoute.jsx]"}}
  node_root_layout["Root layout<br/>[RootLayout.jsx]"]
  node_auth_layout["Auth layout<br/>[AuthLayout.jsx]"]
  node_dashboard_layout["Dashboard layout"]
end

subgraph group_public["Public experience"]
  node_navbar["Navbar<br/>site chrome<br/>[Navbar.jsx]"]
  node_footer["Footer<br/>site chrome<br/>[Footer.jsx]"]
  node_home["Home<br/>landing page<br/>[Home.jsx]"]
  node_search_donors["Search donors<br/>discovery page<br/>[SearchDonors.jsx]"]
  node_donation_requests["Request browse<br/>public requests"]
  node_request_details["Request details"]
end

subgraph group_dashboard["Dashboard"]
  node_dashboard_home["Dashboard home<br/>dashboard page<br/>[DashboardHome.jsx]"]
  node_profile["Profile<br/>dashboard page<br/>[Profile.jsx]"]
  node_my_requests["My requests<br/>dashboard page"]
  node_create_request["Create request<br/>dashboard page"]
  node_edit_request["Edit request<br/>dashboard page"]
  node_request_detail_dash["Request detail<br/>dashboard page"]
  node_admin_users["All users<br/>admin page<br/>[AllUsers.jsx]"]
  node_admin_requests["All requests<br/>admin page"]
end

subgraph group_auth["Authentication"]
  node_login["Login<br/>auth page<br/>[Login.jsx]"]
  node_register["Register<br/>auth page<br/>[Register.jsx]"]
  node_auth_context["Auth context<br/>state<br/>[AuthContext.jsx]"]
  node_auth_provider["Auth provider<br/>[AuthProvider.jsx]"]
  node_use_auth["useAuth<br/>hook<br/>[useAuth.jsx]"]
end

subgraph group_external["External services"]
  node_firebase_init["Firebase auth<br/>auth backend<br/>[firebase.init.js]"]
  node_api_client["Secure API client<br/>http client<br/>[useAxiosSecure.jsx]"]
  node_funding["Funding<br/>payment flow<br/>[FundingPage.jsx]"]
end

node_main -->|"boots"| node_router
node_main -->|"wraps"| node_auth_provider
node_router -->|"public shell"| node_root_layout
node_router -->|"auth shell"| node_auth_layout
node_router -->|"dashboard shell"| node_dashboard_layout
node_router -->|"protects"| node_private_route
node_root_layout -->|"contains"| node_navbar
node_root_layout -->|"contains"| node_footer
node_root_layout -->|"shows"| node_home
node_root_layout -->|"shows"| node_search_donors
node_root_layout -->|"shows"| node_donation_requests
node_donation_requests -->|"opens"| node_request_details
node_auth_layout -->|"shows"| node_login
node_auth_layout -->|"shows"| node_register
node_auth_provider -->|"supplies"| node_auth_context
node_auth_context -->|"consumed by"| node_use_auth
node_auth_context -->|"backs"| node_firebase_init
node_private_route -->|"checks"| node_use_auth
node_dashboard_layout -->|"contains"| node_dashboard_home
node_dashboard_layout -->|"contains"| node_profile
node_dashboard_layout -->|"contains"| node_my_requests
node_dashboard_layout -->|"contains"| node_create_request
node_dashboard_layout -->|"contains"| node_edit_request
node_dashboard_layout -->|"contains"| node_request_detail_dash
node_dashboard_layout -->|"contains"| node_admin_users
node_dashboard_layout -->|"contains"| node_admin_requests
node_dashboard_home -->|"loads data"| node_api_client
node_my_requests -->|"loads data"| node_api_client
node_create_request -->|"writes"| node_api_client
node_edit_request -->|"writes"| node_api_client
node_admin_users -->|"loads data"| node_api_client
node_admin_requests -->|"loads data"| node_api_client
node_funding -->|"starts checkout"| node_api_client

click node_main "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/main.jsx"
click node_router "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/routes/router.jsx"
click node_private_route "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/routes/PrivateRoute.jsx"
click node_root_layout "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/layouts/RootLayout.jsx"
click node_auth_layout "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/layouts/AuthLayout.jsx"
click node_dashboard_layout "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/layouts/DashboardLayout.jsx"
click node_navbar "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/shared/Navbar.jsx"
click node_footer "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/shared/Footer.jsx"
click node_home "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/home/Home.jsx"
click node_search_donors "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/SearchDonors.jsx"
click node_donation_requests "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/HomeDonationRequests.jsx"
click node_request_details "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/HomeDonationRequestsDetails.jsx"
click node_login "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/auth/Login.jsx"
click node_register "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/auth/Register.jsx"
click node_auth_context "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/context/AuthContext.jsx"
click node_auth_provider "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/context/AuthProvider.jsx"
click node_use_auth "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/hooks/useAuth.jsx"
click node_firebase_init "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/firebase/firebase.init.js"
click node_api_client "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/hooks/useAxiosSecure.jsx"
click node_funding "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/FundingPage.jsx"
click node_dashboard_home "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/dashboard/DashboardHome.jsx"
click node_profile "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/dashboard/Profile.jsx"
click node_my_requests "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/dashboard/DonationRequests.jsx"
click node_create_request "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/dashboard/CreateDonationRequest.jsx"
click node_edit_request "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/dashboard/EditDonationRequest.jsx"
click node_request_detail_dash "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/dashboard/DonationRequestDetails.jsx"
click node_admin_users "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/dashboard/admin/AllUsers.jsx"
click node_admin_requests "https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/dashboard/admin/AllDonationRequests.jsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_router,node_private_route,node_root_layout,node_auth_layout,node_dashboard_layout toneBlue
class node_navbar,node_footer,node_home,node_search_donors,node_donation_requests,node_request_details toneAmber
class node_dashboard_home,node_profile,node_my_requests,node_create_request,node_edit_request,node_request_detail_dash,node_admin_users,node_admin_requests toneMint
class node_login,node_register,node_auth_context,node_auth_provider,node_use_auth toneRose
class node_firebase_init,node_api_client,node_funding toneIndigo
```

## Components

### Bootstrap & routing

App entry, routing, layouts, and global shell

- [App entry](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/main.jsx): bootstrap · Mounts the React app and global styles · `src/main.jsx`
- [Router](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/routes/router.jsx): routes · Defines the application route map · `src/routes/router.jsx`
- [Private route](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/routes/PrivateRoute.jsx): guard · Protects authenticated and role-based areas · `src/routes/PrivateRoute.jsx`
- [Root layout](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/layouts/RootLayout.jsx): layout · Shell for the public site · `src/layouts/RootLayout.jsx`
- [Auth layout](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/layouts/AuthLayout.jsx): layout · Shell for login and register screens · `src/layouts/AuthLayout.jsx`
- [Dashboard layout](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/layouts/DashboardLayout.jsx): layout · Shell for authenticated dashboard pages · `src/layouts/DashboardLayout.jsx`

### Public experience

Marketing pages, discovery pages, and shared site chrome

- [Navbar](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/shared/Navbar.jsx): site chrome · Primary navigation and user actions · `src/pages/shared/Navbar.jsx`
- [Footer](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/shared/Footer.jsx): site chrome · Global footer across public pages · `src/pages/shared/Footer.jsx`
- [Home](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/home/Home.jsx): landing page · Homepage assembly of public sections · `src/pages/home/Home.jsx`
- [Search donors](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/SearchDonors.jsx): discovery page · Browse and filter donors by blood group and location · `src/pages/SearchDonors.jsx`
- [Request browse](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/HomeDonationRequests.jsx): public requests · Public donation-request listing · `src/pages/HomeDonationRequests.jsx`
- [Request details](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/HomeDonationRequestsDetails.jsx): request detail · Public donation-request details view · `src/pages/HomeDonationRequestsDetails.jsx`

### Dashboard

Authenticated user workspace and admin views

- [Dashboard home](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/dashboard/DashboardHome.jsx): dashboard page · Authenticated landing view · `src/dashboard/DashboardHome.jsx`
- [Profile](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/dashboard/Profile.jsx): dashboard page · User profile management · `src/dashboard/Profile.jsx`
- [My requests](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/dashboard/DonationRequests.jsx): dashboard page · User donation-request list and tracking · `src/dashboard/DonationRequests.jsx`
- [Create request](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/dashboard/CreateDonationRequest.jsx): dashboard page · Create a donation request · `src/dashboard/CreateDonationRequest.jsx`
- [Edit request](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/dashboard/EditDonationRequest.jsx): dashboard page · Edit an existing donation request · `src/dashboard/EditDonationRequest.jsx`
- [Request detail](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/dashboard/DonationRequestDetails.jsx): dashboard page · Authenticated donation-request detail view · `src/dashboard/DonationRequestDetails.jsx`
- [All users](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/dashboard/admin/AllUsers.jsx): admin page · Admin oversight of users · `src/dashboard/admin/AllUsers.jsx`
- [All requests](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/dashboard/admin/AllDonationRequests.jsx): admin page · Admin oversight of all donation requests · `src/dashboard/admin/AllDonationRequests.jsx`

### Authentication

Auth state, route protection, and Firebase session setup

- [Login](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/auth/Login.jsx): auth page · User sign-in screen · `src/pages/auth/Login.jsx`
- [Register](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/auth/Register.jsx): auth page · User sign-up screen · `src/pages/auth/Register.jsx`
- [Auth context](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/context/AuthContext.jsx): state · Centralized authentication state · `src/context/AuthContext.jsx`
- [Auth provider](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/context/AuthProvider.jsx): provider · Supplies auth state to the app · `src/context/AuthProvider.jsx`
- [useAuth](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/hooks/useAuth.jsx): hook · Consumer hook for auth state · `src/hooks/useAuth.jsx`

### External services

Backend API, Firebase auth, and payment provider integration

- [Firebase auth](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/firebase/firebase.init.js): auth backend · Client-side Firebase authentication setup · `src/firebase/firebase.init.js`
- [Secure API client](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/hooks/useAxiosSecure.jsx): http client · Authenticated Axios client for backend calls · `src/hooks/useAxiosSecure.jsx`
- [Funding](https://github.com/syedshafinahmed/bloodlink-client/blob/main/src/pages/FundingPage.jsx): payment flow · Stripe-backed funding entry page · `src/pages/FundingPage.jsx`

## Connections

- App entry → Router: boots · Application startup hands off to the route map
- App entry → Auth provider: wraps · Provides authentication state to the app
- Router → Root layout: public shell · Public routes render inside the main site layout
- Router → Auth layout: auth shell · Login and register routes use the auth layout
- Router → Dashboard layout: dashboard shell · Protected routes render inside the dashboard layout
- Router → Private route: protects · Authenticated areas are guarded by route checks
- Root layout → Navbar: contains · Public shell includes shared navigation
- Root layout → Footer: contains · Public shell includes shared footer
- Root layout → Home: shows · Root site surfaces the homepage
- Root layout → Search donors: shows · Public browsing includes donor search
- Root layout → Request browse: shows · Public browsing includes request listings
- Request browse → Request details: opens · Listing links to request detail pages
- Auth layout → Login: shows · Auth shell renders sign-in
- Auth layout → Register: shows · Auth shell renders sign-up
- Auth provider → Auth context: supplies · Provider publishes auth state
- Auth context → useAuth: consumed by · Components read auth through the hook
- Auth context → Firebase auth: backs · Auth state is established through Firebase
- Private route → useAuth: checks · Guard relies on current auth state
- Dashboard layout → Dashboard home: contains · Dashboard shell hosts the main overview
- Dashboard layout → Profile: contains · Dashboard shell hosts profile management
- Dashboard layout → My requests: contains · Dashboard shell hosts request tracking
- Dashboard layout → Create request: contains · Dashboard shell hosts request creation
- Dashboard layout → Edit request: contains · Dashboard shell hosts request editing
- Dashboard layout → Request detail: contains · Dashboard shell hosts request details
- Dashboard layout → All users: contains · Admin views are exposed in the authenticated workspace
- Dashboard layout → All requests: contains · Admin views are exposed in the authenticated workspace
- Dashboard home → Secure API client: loads data · Dashboard features fetch user-specific backend data
- My requests → Secure API client: loads data · Request management uses secured API calls
- Create request → Secure API client: writes · Creates requests through the backend API
- Edit request → Secure API client: writes · Updates requests through the backend API
- All users → Secure API client: loads data · Admin user management reads from the backend API
- All requests → Secure API client: loads data · Admin request oversight reads from the backend API
- Funding → Secure API client: starts checkout · Funding flow initiates payment-related backend interaction
