# aak-developers/centraleats-frontend architecture

> Architecture diagram of the GitHub repository aak-developers/centraleats-frontend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aak-developers/centraleats-frontend
- Repository: https://github.com/aak-developers/centraleats-frontend

## Overview

1. **What this repo is**
   - CentralEats Frontend is a single-page React application for a campus food “click & collect” platform.
   - The app is split by user persona and workflow: authentication/onboarding, student ordering, and vendor/restaurant operations.

2. **Runtime and delivery model**
   - The frontend is built with **React 19 + TypeScript + Vite** and served as static assets.
   - In QA/production it runs behind **Nginx** in Docker, with an Nginx reverse proxy used to route API traffic and avoid CORS/mixed-content issues.

3. **Top-level app routing and access control**
   - `src/App.tsx` is the main route composition point.
   - `AuthInitializer` and `ProtectedRoute` form the auth boundary: Clerk session state is initialized once, then routes are gated based on whether the user is authenticated and what role they have.
   - Public entry points are the landing/auth pages; private areas are the student and vendor dashboards.

4. **Identity and session boundary**
   - Authentication is integrated with **Clerk**.
   - The auth flow spans `LoginPage`, `RegisterPage`, and `RoleSelectionPage`, then feeds into protected application routes.
   - `src/store/authStore.ts` holds client-side auth/session state used across the app.

5. **Domain segmentation by persona**
   - `src/pages/student` contains the student-facing dashboard experience.
   - `src/components/restaurant` contains vendor-facing management UI for orders, catalog, status, and profile.
   - `src/components/cart` and `src/components/student/invoice` support the student checkout/invoicing path.
   - Shared cross-role UI lives under `src/components/shared`.

6. **Data-fetching and backend interaction**
   - `src/api/axiosConfig.ts` centralizes Axios setup, so all API calls share the same base configuration and interceptors.
   - Custom hooks in `src/hooks` encapsulate backend workflows: products, restaurants, notifications, orders, cart checkout, and auth-me.
   - The hooks are the main data boundary: pages/components consume them, while network logic stays out of UI components.

7. **Client-side state and interaction flow**
   - `src/store/cartStore.ts` manages cart state independently from server state.
   - The shopping flow is: browse/filter products → add to cart → checkout → generate invoice/confirmation.
   - The vendor flow is: view orders → inspect order details → update restaurant/product/status state.

8. **Component architecture**
   - The UI follows **Atomic Design** explicitly:
     - atoms for basic controls and visual primitives,
     - molecules for composed widgets,
     - organisms for page sections/panels,
     - layout components for app shell structure.
   - This pattern is used consistently across shared, student, cart, and restaurant modules, which makes the diagram naturally divide into reusable UI layers around domain-specific screens.

9. **Student-facing flow**
   - The student dashboard combines product browsing, search/filtering, pagination, sorting, cart feedback, and active order visibility.
   - `InvoicePanel`, `InvoiceQR`, and related invoice components represent the post-checkout artifact shown to the student.
   - `useCartToast`, `useProductFilters`, `useAllProducts`, and `useStudentOrders` are the key data/interaction hooks here.

10. **Vendor-facing flow**
   - Vendor components model operational tasks: restaurant selection, open/closed status, catalog management, order tabs, pickup code handling, and product cards.
   - The vendor area is organized as dashboard/header/panel-style organisms, indicating a management console rather than a consumer flow.
   - `useVendorOrders` and `useVendorRestaurant` provide the backend data for that console.

11. **Shared shell and feedback systems**
   - `src/components/layout` defines the app shell and visual framing.
   - Shared organisms like `NotificationPanel`, `ProfilePanel`, and `AuthHeader` support cross-cutting concerns such as notifications, user profile, and authenticated navigation.
   - These components sit above the role-specific screens and are reused across the app.

12. **Environment and deployment configuration**
   - Runtime configuration is injected through `.env`, `src/config/env.ts`, and `public/env-config.js`.
   - QA/prod deployments use GitHub Actions, Docker Compose, and Nginx templating/scripts to inject backend addresses without hardcoding them into the repository.
   - This matters architecturally because the frontend’s API endpoint is environment-dependent and deployed through a proxy layer, not directly embedded in the app.

13. **Quality and build pipeline**
   - The repo includes ESLint, Vitest setup, and TypeScript build checks, indicating the frontend is validated at both type and build levels.
   - CI/CD workflows under `.github/workflows` build and deploy separate QA/prod frontend targets, so the release topology is environment-specific even though the codebase is shared.

Main entry points: [`src/App.tsx`](https://github.com/aak-developers/centraleats-frontend/blob/main/src/App.tsx) (App router), [`src/api/axiosConfig.ts`](https://github.com/aak-developers/centraleats-frontend/blob/main/src/api/axiosConfig.ts) (API client), [`src/hooks/useAllProducts.ts`](https://github.com/aak-developers/centraleats-frontend/blob/main/src/hooks/useAllProducts.ts) (Domain hooks), [`src/components/cart/organisms/CartPanel.tsx`](https://github.com/aak-developers/centraleats-frontend/blob/main/src/components/cart/organisms/CartPanel.tsx) (Cart flow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_app["App & identity"]
  node_n_main["Entry<br/>bootstrap<br/>[main.tsx]"]
  node_n_app["App router<br/>route composition<br/>[App.tsx]"]
  node_n_auth_init["Auth init<br/>auth boundary"]
  node_n_protected["Protected route<br/>access gate<br/>[ProtectedRoute.tsx]"]
  node_n_auth_pages["Auth pages<br/>public screens<br/>[LoginPage.tsx]"]
  node_n_session[("Auth store<br/>client session<br/>[authStore.ts]")]
  node_n_landing["Landing<br/>public page"]
end

subgraph group_g_student["Student flow"]
  node_n_student_page["Student page<br/>dashboard page"]
  node_n_student_ui["Student UI<br/>atomic UI"]
  node_n_cart_store[("Cart store<br/>client cart<br/>[cartStore.ts]")]
  node_n_cart_flow["Cart flow<br/>checkout UI<br/>[CartPanel.tsx]"]
  node_n_invoice["Invoice panel<br/>post-checkout<br/>[InvoicePanel.tsx]"]
end

subgraph group_g_vendor["Vendor flow"]
  node_n_vendor_page["Vendor page<br/>operations page"]
  node_n_vendor_ui["Vendor console<br/>atomic UI"]
end

subgraph group_g_platform["Shared platform"]
  node_n_shell["App shell<br/>layout<br/>[AppContainer.tsx]"]
  node_n_shared_ui["Shared UI<br/>cross-cutting UI<br/>[AuthHeader.tsx]"]
  node_n_api["API client<br/>http boundary<br/>[axiosConfig.ts]"]
  node_n_hooks["Domain hooks<br/>data hooks<br/>[useAllProducts.ts]"]
  node_n_env["Env config<br/>runtime config<br/>[env.ts]"]
  node_n_deploy["Delivery<br/>build & deploy"]
end

node_n_main -->|"mounts"| node_n_app
node_n_app -->|"initializes"| node_n_auth_init
node_n_app -->|"gates"| node_n_protected
node_n_app -->|"exposes"| node_n_auth_pages
node_n_app -->|"exposes"| node_n_landing
node_n_auth_init -->|"reads/writes"| node_n_session
node_n_protected -->|"checks"| node_n_session
node_n_auth_pages -->|"updates"| node_n_session
node_n_app -->|"routes to"| node_n_student_page
node_n_student_page -->|"uses"| node_n_shell
node_n_student_page -->|"composes"| node_n_student_ui
node_n_student_ui -->|"fetches via"| node_n_hooks
node_n_student_ui -->|"syncs cart"| node_n_cart_store
node_n_cart_flow -->|"reads"| node_n_cart_store
node_n_cart_flow -->|"checks out via"| node_n_hooks
node_n_cart_flow -->|"produces"| node_n_invoice
node_n_invoice -->|"uses"| node_n_shared_ui
node_n_app -->|"routes to"| node_n_vendor_page
node_n_vendor_page -->|"uses"| node_n_shell
node_n_vendor_page -->|"composes"| node_n_vendor_ui
node_n_vendor_ui -->|"fetches via"| node_n_hooks
node_n_vendor_ui -->|"calls"| node_n_api
node_n_hooks -->|"uses"| node_n_api
node_n_api -->|"configured by"| node_n_env
node_n_deploy -->|"injects"| node_n_env
node_n_deploy -->|"proxies"| node_n_api
node_n_shared_ui -->|"fills"| node_n_shell

click node_n_main "https://github.com/aak-developers/centraleats-frontend/blob/main/src/main.tsx"
click node_n_app "https://github.com/aak-developers/centraleats-frontend/blob/main/src/App.tsx"
click node_n_auth_init "https://github.com/aak-developers/centraleats-frontend/blob/main/src/components/auth/AuthInitializer.tsx"
click node_n_protected "https://github.com/aak-developers/centraleats-frontend/blob/main/src/components/auth/ProtectedRoute.tsx"
click node_n_auth_pages "https://github.com/aak-developers/centraleats-frontend/blob/main/src/pages/auth/LoginPage.tsx"
click node_n_session "https://github.com/aak-developers/centraleats-frontend/blob/main/src/store/authStore.ts"
click node_n_landing "https://github.com/aak-developers/centraleats-frontend/blob/main/src/pages/landing/PresentationPage.tsx"
click node_n_student_page "https://github.com/aak-developers/centraleats-frontend/blob/main/src/pages/student/StudentDashboardPage.tsx"
click node_n_student_ui "https://github.com/aak-developers/centraleats-frontend/blob/main/src/components/student/organisms/DashboardHeader.tsx"
click node_n_cart_store "https://github.com/aak-developers/centraleats-frontend/blob/main/src/store/cartStore.ts"
click node_n_cart_flow "https://github.com/aak-developers/centraleats-frontend/blob/main/src/components/cart/organisms/CartPanel.tsx"
click node_n_invoice "https://github.com/aak-developers/centraleats-frontend/blob/main/src/components/student/invoice/organisms/InvoicePanel.tsx"
click node_n_vendor_page "https://github.com/aak-developers/centraleats-frontend/tree/main/src/pages/vendor"
click node_n_vendor_ui "https://github.com/aak-developers/centraleats-frontend/blob/main/src/components/restaurant/organisms/VendorOrdersPanel.tsx"
click node_n_shell "https://github.com/aak-developers/centraleats-frontend/blob/main/src/components/layout/AppContainer.tsx"
click node_n_shared_ui "https://github.com/aak-developers/centraleats-frontend/blob/main/src/components/shared/organisms/AuthHeader.tsx"
click node_n_api "https://github.com/aak-developers/centraleats-frontend/blob/main/src/api/axiosConfig.ts"
click node_n_hooks "https://github.com/aak-developers/centraleats-frontend/blob/main/src/hooks/useAllProducts.ts"
click node_n_env "https://github.com/aak-developers/centraleats-frontend/blob/main/src/config/env.ts"
click node_n_deploy "https://github.com/aak-developers/centraleats-frontend/tree/main/Dockerfile"

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_n_main,node_n_app,node_n_auth_init,node_n_protected,node_n_auth_pages,node_n_session,node_n_landing toneBlue
class node_n_student_page,node_n_student_ui,node_n_cart_store,node_n_cart_flow,node_n_invoice toneAmber
class node_n_vendor_page,node_n_vendor_ui toneMint
class node_n_shell,node_n_shared_ui,node_n_api,node_n_hooks,node_n_env,node_n_deploy toneRose
```

## Components

### App & identity

Routing, auth boundary, and client session state

- [Entry](https://github.com/aak-developers/centraleats-frontend/blob/main/src/main.tsx): bootstrap · React app bootstrap · `src/main.tsx`
- [App router](https://github.com/aak-developers/centraleats-frontend/blob/main/src/App.tsx): route composition · Top-level route and role composition · `src/App.tsx`
- [Auth init](https://github.com/aak-developers/centraleats-frontend/blob/main/src/components/auth/AuthInitializer.tsx): auth boundary · Initializes Clerk session state · `src/components/auth/AuthInitializer.tsx`
- [Protected route](https://github.com/aak-developers/centraleats-frontend/blob/main/src/components/auth/ProtectedRoute.tsx): access gate · Guards private routes by auth and role · `src/components/auth/ProtectedRoute.tsx`
- [Auth pages](https://github.com/aak-developers/centraleats-frontend/blob/main/src/pages/auth/LoginPage.tsx): public screens · Login, register, and role selection · `src/pages/auth/LoginPage.tsx`
- [Auth store](https://github.com/aak-developers/centraleats-frontend/blob/main/src/store/authStore.ts): client session · Shared auth/session state · `src/store/authStore.ts`
- [Landing](https://github.com/aak-developers/centraleats-frontend/blob/main/src/pages/landing/PresentationPage.tsx): public page · Marketing and presentation entry page · `src/pages/landing/PresentationPage.tsx`

### Student flow

Browse, cart, checkout, and invoice experience

- [Student page](https://github.com/aak-developers/centraleats-frontend/blob/main/src/pages/student/StudentDashboardPage.tsx): dashboard page · Student-facing dashboard screen · `src/pages/student/StudentDashboardPage.tsx`
- [Student UI](https://github.com/aak-developers/centraleats-frontend/blob/main/src/components/student/organisms/DashboardHeader.tsx): atomic UI · Browsing, filtering, ordering, and activity widgets · `src/components/student/organisms/DashboardHeader.tsx`
- [Cart store](https://github.com/aak-developers/centraleats-frontend/blob/main/src/store/cartStore.ts): client cart · Local cart state independent of server data · `src/store/cartStore.ts`
- [Cart flow](https://github.com/aak-developers/centraleats-frontend/blob/main/src/components/cart/organisms/CartPanel.tsx): checkout UI · Cart panels and order confirmation path · `src/components/cart/organisms/CartPanel.tsx`
- [Invoice panel](https://github.com/aak-developers/centraleats-frontend/blob/main/src/components/student/invoice/organisms/InvoicePanel.tsx): post-checkout · Invoice, totals, QR, and actions · `src/components/student/invoice/organisms/InvoicePanel.tsx`

### Vendor flow

Restaurant operations and order management

- [Vendor page](https://github.com/aak-developers/centraleats-frontend/tree/main/src/pages/vendor): operations page · Vendor-facing dashboard screen · `src/pages/vendor`
- [Vendor console](https://github.com/aak-developers/centraleats-frontend/blob/main/src/components/restaurant/organisms/VendorOrdersPanel.tsx): atomic UI · Order, catalog, status, and pickup workflows · `src/components/restaurant/organisms/VendorOrdersPanel.tsx`

### Shared platform

Reusable UI, data access, and delivery/runtime concerns

- [App shell](https://github.com/aak-developers/centraleats-frontend/blob/main/src/components/layout/AppContainer.tsx): layout · Shared framing and page structure · `src/components/layout/AppContainer.tsx`
- [Shared UI](https://github.com/aak-developers/centraleats-frontend/blob/main/src/components/shared/organisms/AuthHeader.tsx): cross-cutting UI · Auth header, notifications, profile, empty states, and base controls · `src/components/shared/organisms/AuthHeader.tsx`
- [API client](https://github.com/aak-developers/centraleats-frontend/blob/main/src/api/axiosConfig.ts): http boundary · Central Axios configuration and interceptors · `src/api/axiosConfig.ts`
- [Domain hooks](https://github.com/aak-developers/centraleats-frontend/blob/main/src/hooks/useAllProducts.ts): data hooks · Products, restaurants, orders, checkout, auth-me, and notifications · `src/hooks/useAllProducts.ts`
- [Env config](https://github.com/aak-developers/centraleats-frontend/blob/main/src/config/env.ts): runtime config · Environment injection for API endpoints and deployment settings · `src/config/env.ts`
- [Delivery](https://github.com/aak-developers/centraleats-frontend/tree/main/Dockerfile): build & deploy · Docker, Nginx, and CI/CD release topology · `Dockerfile`

## Connections

- Entry → App router: mounts · Application bootstrap renders the route tree
- App router → Auth init: initializes · Routes are wrapped by session initialization
- App router → Protected route: gates · Private areas are protected by auth/role checks
- App router → Auth pages: exposes · Public authentication entry points
- App router → Landing: exposes · Public landing page
- Auth init → Auth store: reads/writes · Session state is synchronized to the auth store
- Protected route → Auth store: checks · Route access depends on client session state
- Auth pages → Auth store: updates · Login/register/role selection feed session state
- App router → Student page: routes to · Authenticated student experience
- Student page → App shell: uses · Page content is framed by shared layout
- Student page → Student UI: composes · Dashboard page assembles student widgets
- Student UI → Domain hooks: fetches via · Student browsing and activity use domain hooks
- Student UI → Cart store: syncs cart · Product selection updates local cart state
- Cart flow → Cart store: reads · Checkout panels consume cart contents
- Cart flow → Domain hooks: checks out via · Checkout and confirmation use backend workflows
- Cart flow → Invoice panel: produces · Successful checkout leads to invoice artifact
- Invoice panel → Shared UI: uses · Invoice screens reuse shared primitives and panels
- App router → Vendor page: routes to · Authenticated vendor experience
- Vendor page → App shell: uses · Vendor screens share the app frame
- Vendor page → Vendor console: composes · Vendor page assembles operational console widgets
- Vendor console → Domain hooks: fetches via · Orders, restaurants, and status updates use hooks
- Vendor console → API client: calls · Domain hooks rely on the shared API client
- Domain hooks → API client: uses · All major backend workflows share Axios setup
- API client → Env config: configured by · Base URLs and proxy targets come from runtime env
- Delivery → Env config: injects · Docker, Nginx, and CI build environment-specific config
- Delivery → API client: proxies · Nginx routes API traffic through the frontend delivery layer
- Shared UI → App shell: fills · Shared header and panels sit inside the layout shell
