How sultanaladawi/caffaine-graduation-project-private works
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 API server · App.js App shell · Menu.js Menu · Checkout.js Checkout
Components 21
React SPA
Customer-facing site and shared client state
- App shell · Top-level client application composition and routing
src/App.js - Hero · Public marketing landing content
src/components/Hero.js - Menu · Shop and menu browsing on the client
src/components/Menu.js - Shop data · Seed content for menu and shop presentation
src/data/shopData.js - Cart state · Client shopping cart state and updates
src/context/CartContext.js - Store state · Broader app or store-level client state
src/context/StoreContext.js - Checkout · Collects order details before submission
src/components/Checkout.js - Chatbot · Customer-facing AI interaction surface
src/components/Chatbot.js - Reveal hook · Scroll and visibility animation helper
src/hooks/useReveal.js
Admin console
Protected operations area inside the React app
- Admin auth · Admin session and authorization state
src/admin/AdminContext.js - Admin layout · Protected admin navigation and page frame
src/admin/AdminLayout.js - Admin login · Admin sign-in boundary
src/admin/AdminLogin.js - Dashboard · Primary operational summary page
src/admin/pages/Dashboard.js - Orders · Order tracking and fulfillment management
src/admin/pages/Orders.js - Inventory · Stock and resource management
src/admin/pages/Inventory.js - Products · Menu and product management
src/admin/pages/Products.js - AI assistant · Admin-side access to the AI service
src/admin/pages/AIAssistant.js
API server
Node/Express runtime for persistence and AI
- API server · Shared backend runtime exposing application APIs
server.js
Delivery
Static hosting and deployment surface
- Public assets · Browser-delivered static files for the React app
public/index.html - CI workflow · Automated build and release workflow
.github/workflows/main_caffaine-dashboard-v1.yml
Tooling
Repository scripts and maintenance utilities
- Maintenance scripts · Root-level analysis and migration utilities
find_endpoints.js
Connections 22
- 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