How farhadnuri/lifeflow-client works
1. What this repository is
- This is the client/front-end for LifeFlow, built with Next.js App Router and React 19.
- The repo is mostly a presentation and workflow layer; the core blood-request/business data appears to live in the separate Express/MongoDB backend referenced in the README.
2. Top-level architecture
- The app is organized around route-based features under src/app.
- It has three clear authenticated workspaces: Admin, Donor, and Volunteer, plus public user-facing pages for browsing requests, login/register, search, and funding.
3. Authentication and session boundary
- Authentication is handled through the src/app/api/auth/* routes and the shared auth helpers in src/lib/auth.js and src/lib/auth-client.js.
- src/context/AuthContext.jsx is the browser-side state layer that likely exposes the current user/session to the rest of the UI.
- The README indicates Better Auth + JWT semantics, so the app separates identity/session management from the domain backend.
4. Role-based navigation and layout isolation
- Role-specific layouts exist for admin, donor, and volunteer, each with its own sidebar component:
- src/components/admin/AdminSidebar.jsx
- src/components/donor/DonorSidebar.jsx
- src/components/volunteer/VolunteerSidebar.jsx
- src/components/ConditionalLayout.jsx, Navbar.jsx, and Footer.jsx provide shared shell behavior for public vs authenticated sections.
5. Public request discovery flow
- Public entry points include src/app/page.jsx, src/app/requests/page.jsx, src/app/search/page.jsx, and the login/register screens.
- These pages are the discovery layer for blood requests: browsing, searching, and filtering before a user authenticates or acts on a request.
6. Donor workflow
- The donor area contains pages for:
- profile management
- creating a blood request
- viewing “my requests”
- This suggests donors can both maintain their profile and participate in request creation/tracking, not just browse.
7. Volunteer workflow
- The volunteer area mirrors the donor workspace but is oriented around operational response:
- creating requests
- listing “all blood donation requests”
- tracking “my requests”
- profile management
- The RespondButton component indicates a direct action path for volunteers to answer an emergency request.
8. Admin control plane
- The admin section contains dedicated pages for:
- user management
- request management
- admin profile
- This is the administrative boundary for moderation and platform oversight, likely backed by privileged API access and role checks.
9. Funding / payment flow
- src/app/funding/* contains separate success and cancel landing pages, which is a strong indicator of an external payment redirect flow.
- The README says the app uses Stripe.js, so payment processing is handled client-side with Stripe redirect/confirmation pages as the return boundary.
10. Static reference data and location filtering
- public/districts.json, public/divisions.json, and public/upazilas.json provide static geography data.
- src/hooks/useLocationData.js likely combines those files into cascading location selectors for request forms and filters.
- This is an important data boundary because location data is served locally rather than fetched from the main backend.
11. Backend integration boundary
- The README points to an external backend repo and exposes NEXT_PUBLIC_API_URL, so UI pages likely call the Express API for:
- authentication state and credentials
- blood request CRUD
- user/role management
- responses and request status
- The frontend is therefore a thin client over a domain API, with the app router pages acting as feature shells around backend data.
12. Likely persistence model behind the UI
- The backend data model mentioned in the README centers on users, bloodRequests, and responses.
- Those collections map cleanly to the app’s major screens: auth/user profile, request browsing/management, and volunteer response tracking.
13. Runtime and tooling
- Styling is done with Tailwind CSS v4 via globals.css and PostCSS.
- The app uses Lucide React for icons.
- eslint.config.mjs, next.config.mjs, and the App Router layout files indicate a standard Next.js deployment model, likely on Vercel as noted in the README.
14. Architecture summary for a diagram
- Think of this repo as:
- a public marketing/discovery layer
- three role-based authenticated dashboards
- a small auth API layer inside Next.js
- and a backend API/payment service boundary for all real domain state.
Main entry points: ConditionalLayout.jsx Conditional layout · page.jsx Discovery pages · layout.js App shell · layout.jsx Admin layout
Components 23
Public
Discovery, authentication entry points, and funding return pages.
- Discovery pages · Homepage, requests browser, search, login, and register entry points.
src/app/page.jsx - Funding flow · Donation funding page and Stripe success/cancel return screens.
src/app/funding/page.jsx - Stripe gateway · External payment flow reached from the funding pages.
Auth
Session helpers and Next.js auth API routes.
- Auth context · Browser-side session and user state layer.
src/context/AuthContext.jsx - Auth API · Next.js auth gateway for login, register, and session checks.
src/app/api/auth/[...all]/route.js - Auth routes · Concrete login, register, and me endpoints.
src/app/api/auth/login/route.js - Auth helpers · Server-side auth utilities and client helpers.
src/lib/auth.js - Domain API · Separate Express/MongoDB service providing users, requests, and responses.
Dashboards
Role-based workspaces for admin, donor, and volunteer users.
- Admin layout · Admin area layout and navigation container.
src/app/admin/layout.jsx - Admin sidebar · Admin workspace navigation.
src/components/admin/AdminSidebar.jsx - Admin pages · User, request, and profile management screens.
src/app/admin/page.jsx - Donor layout · Donor area layout and navigation container.
src/app/donor/layout.jsx - Donor sidebar · Donor workspace navigation.
src/components/donor/DonorSidebar.jsx - Donor pages · Profile, create-request, and my-requests screens.
src/app/donor/page.jsx - Volunteer layout · Volunteer area layout and navigation container.
src/app/volunteer/layout.jsx - Volunteer sidebar · Volunteer workspace navigation.
src/components/volunteer/VolunteerSidebar.jsx - Volunteer pages · Request operations, profile, and tracking screens.
src/app/volunteer/page.jsx
Shared
Reusable shell components and local data helpers.
- App shell · Root app layout and global styling entrypoint.
src/app/layout.js - Conditional layout · Chooses public vs authenticated page chrome.
src/components/ConditionalLayout.jsx - Navbar · Shared top navigation for public-facing sections.
src/components/Navbar.jsx - Footer · Shared page footer.
src/components/Footer.jsx - Location data · Cascading location lookup based on bundled district and division data.
src/hooks/useLocationData.js - Respond button · Direct volunteer action for responding to requests.
src/components/RespondButton.jsx
Connections 26
- App shell → Conditional layout: wraps · Root layout delegates section chrome selection.
- App shell → Navbar: shares · Global shell provides the navigation component.
- App shell → Footer: shares · Global shell provides the footer component.
- Conditional layout → Discovery pages: renders · Public pages use the shared public shell.
- Conditional layout → Funding flow: renders · Funding pages are part of the public shell.
- Conditional layout → Admin layout: switches to · Authenticated routes branch into role workspaces.
- Conditional layout → Donor layout: switches to · Authenticated routes branch into role workspaces.
- Conditional layout → Volunteer layout: switches to · Authenticated routes branch into role workspaces.
- Auth context → Auth helpers: uses · Client session state relies on shared auth helpers.
- Auth API → Auth routes: delegates · Catch-all route and concrete endpoints form the auth boundary.
- Auth API → Auth helpers: uses · API handlers rely on auth utilities.
- Auth context → Auth API: syncs with · Browser session state is validated against auth endpoints.
- Discovery pages → Auth context: reads · Login and register pages consume session state.
- Discovery pages → Domain API: fetches · Discovery views are thin clients over the domain backend.
- Funding flow → Stripe gateway: redirects · Checkout completion and cancellation return from Stripe.
- Discovery pages → Location data: filters by · Search and request forms use bundled geographic data.
- Admin layout → Admin sidebar: contains · Admin workspace is centered on its sidebar navigation.
- Admin layout → Admin pages: hosts · Admin pages live inside the admin workspace shell.
- Admin pages → Domain API: manages · Admin screens operate on users and requests through the backend.
- Donor layout → Donor sidebar: contains · Donor workspace is centered on its sidebar navigation.
- Donor layout → Donor pages: hosts · Donor pages live inside the donor workspace shell.
- Donor pages → Domain API: manages · Donor screens create and track request records through the backend.
- Volunteer layout → Volunteer sidebar: contains · Volunteer workspace is centered on its sidebar navigation.
- Volunteer layout → Volunteer pages: hosts · Volunteer pages live inside the volunteer workspace shell.
- Volunteer pages → Respond button: uses · Request lists expose the response action component.
- Volunteer pages → Domain API: manages · Volunteer screens operate on requests and responses through the backend.