How aak-developers/centraleats-frontend works
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: App.tsx App router · axiosConfig.ts API client · useAllProducts.ts Domain hooks · CartPanel.tsx Cart flow
Components 20
App & identity
Routing, auth boundary, and client session state
- Entry · React app bootstrap
src/main.tsx - App router · Top-level route and role composition
src/App.tsx - Auth init · Initializes Clerk session state
src/components/auth/AuthInitializer.tsx - Protected route · Guards private routes by auth and role
src/components/auth/ProtectedRoute.tsx - Auth pages · Login, register, and role selection
src/pages/auth/LoginPage.tsx - Auth store · Shared auth/session state
src/store/authStore.ts - Landing · Marketing and presentation entry page
src/pages/landing/PresentationPage.tsx
Student flow
Browse, cart, checkout, and invoice experience
- Student page · Student-facing dashboard screen
src/pages/student/StudentDashboardPage.tsx - Student UI · Browsing, filtering, ordering, and activity widgets
src/components/student/organisms/DashboardHeader.tsx - Cart store · Local cart state independent of server data
src/store/cartStore.ts - Cart flow · Cart panels and order confirmation path
src/components/cart/organisms/CartPanel.tsx - Invoice panel · Invoice, totals, QR, and actions
src/components/student/invoice/organisms/InvoicePanel.tsx
Vendor flow
Restaurant operations and order management
- Vendor page · Vendor-facing dashboard screen
src/pages/vendor - Vendor console · Order, catalog, status, and pickup workflows
src/components/restaurant/organisms/VendorOrdersPanel.tsx
Shared platform
Reusable UI, data access, and delivery/runtime concerns
- App shell · Shared framing and page structure
src/components/layout/AppContainer.tsx - Shared UI · Auth header, notifications, profile, empty states, and base controls
src/components/shared/organisms/AuthHeader.tsx - API client · Central Axios configuration and interceptors
src/api/axiosConfig.ts - Domain hooks · Products, restaurants, orders, checkout, auth-me, and notifications
src/hooks/useAllProducts.ts - Env config · Environment injection for API endpoints and deployment settings
src/config/env.ts - Delivery · Docker, Nginx, and CI/CD release topology
Dockerfile
Connections 27
- 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