# hafizmanap/campuseats-2410285 architecture

> Architecture diagram of the GitHub repository hafizmanap/campuseats-2410285, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hafizmanap/campuseats-2410285
- Repository: https://github.com/hafizmanap/campuseats-2410285

## Overview

CampusEats is a React app for browsing campus food vendors, adding menu items and specials to a cart, and placing and managing orders. Users can register or sign in (including with Google); authentication protects cart and order pages. Vendor and order data are backed by Firebase, while cart state is persisted in browser storage. The source index and excerpts support the main route and service relationships; some UI and Firebase details are unsampled, so those links are omitted where their callers are not evidenced.

Main entry points: [`src/App.jsx`](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/App.jsx) (Application router), [`src/pages/CartPage.jsx`](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/pages/CartPage.jsx) (Cart and checkout), [`src/pages/VendorPage.jsx`](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/pages/VendorPage.jsx) (Vendor menu), [`src/context/AuthProvider.jsx`](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/context/AuthProvider.jsx) (Authentication state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and routes"]
  node_app["Application router<br/>[App.jsx]"]
end

subgraph group_identity["Identity"]
  node_login["Login<br/>[LoginPage.jsx]"]
  node_register["Registration<br/>[RegisterPage.jsx]"]
  node_authprovider["Authentication state<br/>[AuthProvider.jsx]"]
  node_authhook["Auth hook<br/>[useAuth.js]"]
  node_autherrors["Auth error messages<br/>[authErrors.js]"]
  node_guard["Protected routes<br/>[ProtectedRoute.jsx]"]
end

subgraph group_vendors["Vendor browsing"]
  node_home["Vendor home<br/>[HomePage.jsx]"]
  node_vendorpage["Vendor menu<br/>[VendorPage.jsx]"]
  node_vendorhook["Vendor data hooks<br/>[useVendors.js]"]
  node_vendorservice["Vendor services<br/>[vendors.js]"]
  node_vendorcards["Vendor cards<br/>[VendorCard.jsx]"]
  node_menulist["Menu list<br/>[MenuList.jsx]"]
  node_special["Daily special<br/>[DailySpecial.jsx]"]
end

subgraph group_ordering["Cart and orders"]
  node_cartpage["Cart and checkout<br/>[CartPage.jsx]"]
  node_checkout["Checkout form<br/>[CheckOutForm.jsx]"]
  node_cartitem["Cart item<br/>[CartItem.jsx]"]
  node_orderspage["Order history<br/>[OrdersPage.jsx]"]
  node_myorders["Order subscription hook<br/>[useMyOrders.js]"]
  node_orderservice["Order services<br/>[orders.js]"]
  node_orderactions["Order actions<br/>[OrderActions.jsx]"]
end

subgraph group_infra["State and Firebase"]
  node_cartprovider["Cart state<br/>[CartProvider.jsx]"]
  node_carthook["Cart hook<br/>[useCart.js]"]
  node_localstorage[("Browser storage<br/>[useLocalStorage.js]")]
  node_firebase["Firebase setup<br/>[firebase.js]"]
end

node_visitor(("CampusEats user"))
node_firestore[("Cloud Firestore")]
node_firebaseauth["Firebase Auth"]

node_visitor -->|"opens"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_vendorpage
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_register
node_app -->|"routes to"| node_cartpage
node_app -->|"routes to"| node_orderspage
node_app -->|"provides auth"| node_authprovider
node_app -->|"provides cart"| node_cartprovider
node_app -->|"guards routes"| node_guard
node_home -->|"loads vendors"| node_vendorhook
node_home -->|"renders vendors"| node_vendorcards
node_vendorhook -->|"subscribes"| node_vendorservice
node_vendorpage -->|"renders menu"| node_menulist
node_vendorpage -->|"renders special"| node_special
node_vendorpage -->|"loads vendor"| node_vendorservice
node_vendorservice -->|"reads and seeds"| node_firestore
node_login -->|"uses auth"| node_authhook
node_register -->|"uses auth"| node_authhook
node_login -->|"formats errors"| node_autherrors
node_register -->|"formats errors"| node_autherrors
node_authhook -->|"reads context"| node_authprovider
node_authprovider -->|"authenticates"| node_firebaseauth
node_authprovider -->|"uses auth config"| node_firebase
node_guard -->|"checks user"| node_authhook
node_cartpage -->|"renders lines"| node_cartitem
node_cartpage -->|"renders checkout"| node_checkout
node_cartpage -->|"places orders"| node_orderservice
node_cartpage -->|"uses cart"| node_carthook
node_orderspage -->|"loads orders"| node_myorders
node_orderspage -->|"renders actions"| node_orderactions
node_myorders -->|"subscribes"| node_orderservice
node_orderactions -->|"updates orders"| node_orderservice
node_orderservice -->|"reads and writes"| node_firestore
node_carthook -->|"reads context"| node_cartprovider
node_cartprovider -->|"persists cart"| node_localstorage
node_firebase -->|"initializes"| node_firestore

click node_app "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/App.jsx"
click node_home "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/pages/HomePage.jsx"
click node_vendorpage "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/pages/VendorPage.jsx"
click node_vendorhook "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/hooks/useVendors.js"
click node_vendorservice "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/services/vendors.js"
click node_vendorcards "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/components/VendorCard.jsx"
click node_menulist "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/components/MenuList.jsx"
click node_special "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/components/DailySpecial.jsx"
click node_login "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/pages/LoginPage.jsx"
click node_register "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/pages/RegisterPage.jsx"
click node_authprovider "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/context/AuthProvider.jsx"
click node_authhook "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/hooks/useAuth.js"
click node_autherrors "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/authErrors.js"
click node_guard "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/components/ProtectedRoute.jsx"
click node_cartpage "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/pages/CartPage.jsx"
click node_checkout "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/components/CheckOutForm.jsx"
click node_cartitem "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/components/CartItem.jsx"
click node_orderspage "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/pages/OrdersPage.jsx"
click node_myorders "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/hooks/useMyOrders.js"
click node_orderservice "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/services/orders.js"
click node_orderactions "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/components/OrderActions.jsx"
click node_cartprovider "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/context/CartProvider.jsx"
click node_carthook "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/hooks/useCart.js"
click node_localstorage "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/hooks/useLocalStorage.js"
click node_firebase "https://github.com/hafizmanap/campuseats-2410285/blob/main/src/firebase.js"

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_app,node_visitor toneBlue
class node_login,node_register,node_authprovider,node_authhook,node_autherrors,node_guard,node_firestore toneAmber
class node_home,node_vendorpage,node_vendorhook,node_vendorservice,node_vendorcards,node_menulist,node_special toneMint
class node_cartpage,node_checkout,node_cartitem,node_orderspage,node_myorders,node_orderservice,node_orderactions toneRose
class node_cartprovider,node_carthook,node_localstorage,node_firebase,node_firebaseauth toneIndigo
```

## Components

### App and routes

- [Application router](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/App.jsx): `src/App.jsx`

### Identity

- [Login](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/pages/LoginPage.jsx): `src/pages/LoginPage.jsx`
- [Registration](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/pages/RegisterPage.jsx): `src/pages/RegisterPage.jsx`
- [Authentication state](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/context/AuthProvider.jsx): `src/context/AuthProvider.jsx`
- [Auth hook](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/hooks/useAuth.js): `src/hooks/useAuth.js`
- [Auth error messages](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/authErrors.js): `src/authErrors.js`
- [Protected routes](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/components/ProtectedRoute.jsx): `src/components/ProtectedRoute.jsx`

### Vendor browsing

- [Vendor home](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/pages/HomePage.jsx): `src/pages/HomePage.jsx`
- [Vendor menu](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/pages/VendorPage.jsx): `src/pages/VendorPage.jsx`
- [Vendor data hooks](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/hooks/useVendors.js): `src/hooks/useVendors.js`
- [Vendor services](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/services/vendors.js): `src/services/vendors.js`
- [Vendor cards](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/components/VendorCard.jsx): `src/components/VendorCard.jsx`
- [Menu list](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/components/MenuList.jsx): `src/components/MenuList.jsx`
- [Daily special](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/components/DailySpecial.jsx): `src/components/DailySpecial.jsx`

### Cart and orders

- [Cart and checkout](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/pages/CartPage.jsx): `src/pages/CartPage.jsx`
- [Checkout form](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/components/CheckOutForm.jsx): `src/components/CheckOutForm.jsx`
- [Cart item](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/components/CartItem.jsx): `src/components/CartItem.jsx`
- [Order history](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/pages/OrdersPage.jsx): `src/pages/OrdersPage.jsx`
- [Order subscription hook](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/hooks/useMyOrders.js): `src/hooks/useMyOrders.js`
- [Order services](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/services/orders.js): `src/services/orders.js`
- [Order actions](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/components/OrderActions.jsx): `src/components/OrderActions.jsx`

### State and Firebase

- [Cart state](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/context/CartProvider.jsx): `src/context/CartProvider.jsx`
- [Cart hook](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/hooks/useCart.js): `src/hooks/useCart.js`
- [Browser storage](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/hooks/useLocalStorage.js): `src/hooks/useLocalStorage.js`
- [Firebase setup](https://github.com/hafizmanap/campuseats-2410285/blob/main/src/firebase.js): `src/firebase.js`

### Other components

- **CampusEats user**
- **Cloud Firestore**
- **Firebase Auth**

## Connections

- CampusEats user → Application router: opens
- Application router → Vendor home: routes to (evidence: `src/App.jsx`)
- Application router → Vendor menu: routes to (evidence: `src/App.jsx`)
- Application router → Login: routes to (evidence: `src/App.jsx`)
- Application router → Registration: routes to (evidence: `src/App.jsx`)
- Application router → Cart and checkout: routes to (evidence: `src/App.jsx`)
- Application router → Order history: routes to (evidence: `src/App.jsx`)
- Application router → Authentication state: provides auth (evidence: `src/App.jsx`)
- Application router → Cart state: provides cart (evidence: `src/App.jsx`)
- Application router → Protected routes: guards routes (evidence: `src/App.jsx`)
- Vendor home → Vendor data hooks: loads vendors (evidence: `src/pages/HomePage.jsx`)
- Vendor home → Vendor cards: renders vendors (evidence: `src/pages/HomePage.jsx`)
- Vendor data hooks → Vendor services: subscribes (evidence: `src/hooks/useVendors.js`)
- Vendor menu → Menu list: renders menu (evidence: `src/pages/VendorPage.jsx`)
- Vendor menu → Daily special: renders special (evidence: `src/pages/VendorPage.jsx`)
- Vendor menu → Vendor services: loads vendor
- Vendor services → Cloud Firestore: reads and seeds (evidence: `src/services/vendors.js`)
- Login → Auth hook: uses auth (evidence: `src/pages/LoginPage.jsx`)
- Registration → Auth hook: uses auth (evidence: `src/pages/RegisterPage.jsx`)
- Login → Auth error messages: formats errors (evidence: `src/pages/LoginPage.jsx`)
- Registration → Auth error messages: formats errors (evidence: `src/pages/RegisterPage.jsx`)
- Auth hook → Authentication state: reads context (evidence: `src/hooks/useAuth.js`)
- Authentication state → Firebase Auth: authenticates (evidence: `src/context/AuthProvider.jsx`)
- Authentication state → Firebase setup: uses auth config (evidence: `src/context/AuthProvider.jsx`)
- Protected routes → Auth hook: checks user (evidence: `src/components/ProtectedRoute.jsx`)
- Cart and checkout → Cart item: renders lines (evidence: `src/pages/CartPage.jsx`)
- Cart and checkout → Checkout form: renders checkout (evidence: `src/pages/CartPage.jsx`)
- Cart and checkout → Order services: places orders (evidence: `src/pages/CartPage.jsx`)
- Cart and checkout → Cart hook: uses cart (evidence: `src/pages/CartPage.jsx`)
- Order history → Order subscription hook: loads orders (evidence: `src/pages/OrdersPage.jsx`)
- Order history → Order actions: renders actions (evidence: `src/pages/OrdersPage.jsx`)
- Order subscription hook → Order services: subscribes (evidence: `src/hooks/useMyOrders.js`)
- Order actions → Order services: updates orders (evidence: `src/components/OrderActions.jsx`)
- Order services → Cloud Firestore: reads and writes (evidence: `src/services/orders.js`)
- Cart hook → Cart state: reads context (evidence: `src/hooks/useCart.js`)
- Cart state → Browser storage: persists cart (evidence: `src/context/CartProvider.jsx`)
- Firebase setup → Cloud Firestore: initializes (evidence: `src/firebase.js`)
