# sultanaladawi/caffaine-graduation-project-private architecture

> Architecture diagram of the GitHub repository sultanaladawi/caffaine-graduation-project-private, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sultanaladawi/caffaine-graduation-project-private
- Repository: https://github.com/sultanaladawi/caffaine-graduation-project-private

## Overview

1. This repository is a split-stack application: a React single-page frontend for the customer-facing site and admin console, plus a Node/Express backend (`server.js`) that talks to a MySQL database and an OpenAI-powered AI endpoint.

2. The public UI lives under `src/components` and is composed as a mostly static marketing/e-commerce experience: hero/about/gallery/menu/contact/careers/footer, plus transactional pieces like cart, checkout, and chatbot. `src/data/shopData.js` appears to seed menu/shop content on the client side.

3. Client state is organized with React context rather than a heavier global store. `src/context/CartContext.js` handles shopping cart state, and `src/context/StoreContext.js` likely provides broader app/store data. `useReveal` is a small UI hook for scroll/visibility animations.

4. The checkout/data boundary is important: the frontend collects selections and order details, but the backend is responsible for persistence and inventory mutation. The README states that when an order is placed, the server deducts materials from the `inventory` table based on `menu_items.resource_consumption`.

5. The backend is a separate runtime/process launched from `server.js`, configured through `.env` with MySQL connection settings and `OPENAI_API_KEY`. The README indicates the frontend and admin panel communicate with `http://127.0.0.1:5000`, so the server is the shared API boundary for the app.

6. There is an AI integration surface at `POST /api/ai`, backed by OpenAI. This is likely consumed by the `Chatbot` component on the public site and by the `src/admin/pages/AIAssistant.js` admin page, making AI a cross-cutting service rather than a standalone app.

7. The admin subsystem is a protected area within the same React app. `AdminContext`, `AdminLogin`, `AdminRoute`, and `AdminLayout` define the auth and layout boundary, while the admin pages cover operational domains such as dashboard, analytics, orders, products, inventory, offers, jobs, applications, feedback, messages, and leader-facing views.

8. The repository suggests a restaurant/shop operations model: menu/catalog management, order tracking, inventory consumption, hiring/jobs, customer feedback, and internal messaging. That means the admin UI is not just a content editor; it is the operational console for the business workflow.

9. `src/components/supabaseClient.js` indicates an additional service integration point, though the exact usage is not visible from the tree alone. Architecturally, that file marks a second external dependency beyond the custom API/database stack.

10. The `public` folder is standard SPA hosting output: `index.html`, `manifest.json`, `robots.txt`, and static assets. This supports browser delivery of the React app, with the Node server and/or deployment platform serving the built frontend.

11. Deployment is supported by a GitHub Actions workflow under `.github/workflows` and a `.deployment` directory, implying automated build/release setup. The exact target isn’t visible, but the repo is clearly prepared for CI/CD rather than only local execution.

12. The root-level utility scripts (`find_endpoints.js`, `extract_queries.js`, `generate_presentation.js`, `migrate_menu_icons.js`, etc.) are maintenance/analysis tools, not part of the runtime path. They suggest the codebase has been inspected and transformed with custom scripts, but they do not change the main app architecture.

Main entry points: [`server.js`](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/server.js) (API server), [`src/App.js`](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/App.js) (App shell), [`src/components/Menu.js`](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/components/Menu.js) (Menu), [`src/components/Checkout.js`](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/components/Checkout.js) (Checkout)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React SPA"]
  node_app["App shell<br/>React entry<br/>[App.js]"]
  node_hero["Hero<br/>landing section<br/>[Hero.js]"]
  node_catalog["Menu<br/>catalog UI<br/>[Menu.js]"]
  node_shopdata["Shop data<br/>client data<br/>[shopData.js]"]
  node_cartctx(("Cart state<br/>React context<br/>[CartContext.js]"))
  node_storectx(("Store state<br/>React context<br/>[StoreContext.js]"))
  node_checkout["Checkout<br/>order flow<br/>[Checkout.js]"]
  node_chatbot["Chatbot<br/>ai client<br/>[Chatbot.js]"]
  node_reveal(("Reveal hook<br/>ui hook<br/>[useReveal.js]"))
end

subgraph group_admin["Admin console"]
  node_adminctx(("Admin auth<br/>auth context<br/>[AdminContext.js]"))
  node_adminlayout["Admin layout<br/>admin shell<br/>[AdminLayout.js]"]
  node_adminlogin["Admin login<br/>auth screen<br/>[AdminLogin.js]"]
  node_dashboard["Dashboard<br/>admin overview<br/>[Dashboard.js]"]
  node_orders["Orders<br/>ops page<br/>[Orders.js]"]
  node_inventory["Inventory<br/>ops page<br/>[Inventory.js]"]
  node_products["Products<br/>catalog admin<br/>[Products.js]"]
  node_aiassistant["AI assistant<br/>admin ai<br/>[AIAssistant.js]"]
end

subgraph group_backend["API server"]
  node_server["API server<br/>Node/Express<br/>[server.js]"]
end

subgraph group_delivery["Delivery"]
  node_public["Public assets<br/>SPA assets<br/>[index.html]"]
  node_workflow["CI workflow<br/>build pipeline"]
end

subgraph group_tooling["Tooling"]
  node_scripts["Maintenance scripts<br/>repo tools<br/>[find_endpoints.js]"]
end

node_app -->|"renders"| node_hero
node_app -->|"includes"| node_catalog
node_app -->|"includes"| node_checkout
node_app -->|"includes"| node_chatbot
node_app -->|"provides"| node_cartctx
node_app -->|"provides"| node_storectx
node_catalog -->|"reads"| node_shopdata
node_catalog -->|"updates"| node_cartctx
node_checkout -->|"consumes"| node_cartctx
node_checkout -->|"submits"| node_server
node_chatbot -->|"calls"| node_server
node_reveal -.->|"animates"| node_hero
node_adminlayout -->|"uses"| node_adminctx
node_adminlogin -->|"authenticates"| node_adminctx
node_dashboard -->|"reads"| node_server
node_orders -->|"reads"| node_server
node_inventory -->|"updates"| node_server
node_products -->|"updates"| node_server
node_aiassistant -->|"calls"| node_server
node_server -->|"serves"| node_public
node_workflow -.->|"builds"| node_public
node_scripts -.->|"analyzes"| node_server

click node_app "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/App.js"
click node_hero "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/components/Hero.js"
click node_catalog "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/components/Menu.js"
click node_shopdata "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/data/shopData.js"
click node_cartctx "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/context/CartContext.js"
click node_storectx "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/context/StoreContext.js"
click node_checkout "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/components/Checkout.js"
click node_chatbot "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/components/Chatbot.js"
click node_reveal "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/hooks/useReveal.js"
click node_adminctx "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/admin/AdminContext.js"
click node_adminlayout "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/admin/AdminLayout.js"
click node_adminlogin "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/admin/AdminLogin.js"
click node_dashboard "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/admin/pages/Dashboard.js"
click node_orders "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/admin/pages/Orders.js"
click node_inventory "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/admin/pages/Inventory.js"
click node_products "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/admin/pages/Products.js"
click node_aiassistant "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/admin/pages/AIAssistant.js"
click node_server "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/server.js"
click node_public "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/public/index.html"
click node_workflow "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/.github/workflows/main_caffaine-dashboard-v1.yml"
click node_scripts "https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/find_endpoints.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_hero,node_catalog,node_shopdata,node_cartctx,node_storectx,node_checkout,node_chatbot,node_reveal toneBlue
class node_adminctx,node_adminlayout,node_adminlogin,node_dashboard,node_orders,node_inventory,node_products,node_aiassistant toneAmber
class node_server toneMint
class node_public,node_workflow toneRose
class node_scripts toneIndigo
```

## Components

### React SPA

Customer-facing site and shared client state

- [App shell](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/App.js): React entry · Top-level client application composition and routing · `src/App.js`
- [Hero](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/components/Hero.js): landing section · Public marketing landing content · `src/components/Hero.js`
- [Menu](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/components/Menu.js): catalog UI · Shop and menu browsing on the client · `src/components/Menu.js`
- [Shop data](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/data/shopData.js): client data · Seed content for menu and shop presentation · `src/data/shopData.js`
- [Cart state](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/context/CartContext.js): React context · Client shopping cart state and updates · `src/context/CartContext.js`
- [Store state](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/context/StoreContext.js): React context · Broader app or store-level client state · `src/context/StoreContext.js`
- [Checkout](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/components/Checkout.js): order flow · Collects order details before submission · `src/components/Checkout.js`
- [Chatbot](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/components/Chatbot.js): ai client · Customer-facing AI interaction surface · `src/components/Chatbot.js`
- [Reveal hook](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/hooks/useReveal.js): ui hook · Scroll and visibility animation helper · `src/hooks/useReveal.js`

### Admin console

Protected operations area inside the React app

- [Admin auth](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/admin/AdminContext.js): auth context · Admin session and authorization state · `src/admin/AdminContext.js`
- [Admin layout](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/admin/AdminLayout.js): admin shell · Protected admin navigation and page frame · `src/admin/AdminLayout.js`
- [Admin login](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/admin/AdminLogin.js): auth screen · Admin sign-in boundary · `src/admin/AdminLogin.js`
- [Dashboard](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/admin/pages/Dashboard.js): admin overview · Primary operational summary page · `src/admin/pages/Dashboard.js`
- [Orders](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/admin/pages/Orders.js): ops page · Order tracking and fulfillment management · `src/admin/pages/Orders.js`
- [Inventory](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/admin/pages/Inventory.js): ops page · Stock and resource management · `src/admin/pages/Inventory.js`
- [Products](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/admin/pages/Products.js): catalog admin · Menu and product management · `src/admin/pages/Products.js`
- [AI assistant](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/src/admin/pages/AIAssistant.js): admin ai · Admin-side access to the AI service · `src/admin/pages/AIAssistant.js`

### API server

Node/Express runtime for persistence and AI

- [API server](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/server.js): Node/Express · Shared backend runtime exposing application APIs · `server.js`

### Delivery

Static hosting and deployment surface

- [Public assets](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/public/index.html): SPA assets · Browser-delivered static files for the React app · `public/index.html`
- [CI workflow](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/.github/workflows/main_caffaine-dashboard-v1.yml): build pipeline · Automated build and release workflow · `.github/workflows/main_caffaine-dashboard-v1.yml`

### Tooling

Repository scripts and maintenance utilities

- [Maintenance scripts](https://github.com/sultanaladawi/caffaine-graduation-project-private/blob/main/find_endpoints.js): repo tools · Root-level analysis and migration utilities · `find_endpoints.js`

## Connections

- App shell → Hero: renders · Composes the public landing experience
- App shell → Menu: includes · Hosts the shopping and menu flow
- App shell → Checkout: includes · Hosts the order submission flow
- App shell → Chatbot: includes · Embeds the AI interaction surface
- App shell → Cart state: provides · Shares cart state across the client
- App shell → Store state: provides · Shares broader store state across the client
- Menu → Shop data: reads · Uses seeded menu and shop content
- Menu → Cart state: updates · Adds items to the cart
- Checkout → Cart state: consumes · Uses cart contents for order creation
- Checkout → API server: submits · Sends order data to the backend API
- Chatbot → API server: calls · Uses the AI endpoint on the server
- Reveal hook → Hero: animates · Supports scroll reveal behavior in UI sections
- Admin layout → Admin auth: uses · Wraps protected admin state and navigation
- Admin login → Admin auth: authenticates · Establishes admin access
- Dashboard → API server: reads · Loads operational data from the backend
- Orders → API server: reads · Fetches and updates order data
- Inventory → API server: updates · Manages stock and resource levels
- Products → API server: updates · Manages catalog records
- AI assistant → API server: calls · Admin access to the AI service endpoint
- API server → Public assets: serves · Delivers the SPA shell and static assets
- CI workflow → Public assets: builds · Automates app packaging and deployment
- Maintenance scripts → API server: analyzes · Inspects backend endpoints and queries
