How akash2xd/akash-scafe works
1. Repository shape
- This is a two-tier application: a React frontend in frontend/ and an Express + MongoDB backend in backend/.
- The product is a café ordering system, not just a marketing site: users can browse items, build a cart, place orders, review items, and track orders; admins can manage inventory and orders.
2. Frontend application shell
- The frontend is a Vite React app (main.jsx, App.jsx, vite.config.js), despite the README mentioning Next.js.
- Global styling lives in src/index.css, and the app includes shared UI helpers like Loader, ToastContainer, and ScrollToTop.
- Static media is a major part of the UI: menu imagery and promo video assets are stored in both public/assets and src/assets.
3. Frontend state and cross-cutting concerns
- Shared application state is organized through React context:
- AuthContext for login/session state
- CartContext for basket contents and checkout prep
- LoadingContext for UI loading state
- SocketContext for real-time updates
- This suggests the frontend is designed around global state rather than page-local state only.
4. Customer-facing UI flow
- The customer experience is composed from modular components such as HeroSection, Dishes, DishCard, AddOnModal, Cart, CheckoutPage, DeliveryForm, MyOrders, RatingPage, and Review.
- The structure implies a flow of: browse menu → inspect item/add-ons → add to cart → checkout → provide delivery details → view orders / submit ratings.
5. Content and informational pages
- The app also includes policy and support pages: PrivacyPolicyPage, TermsPage, ShippingDeliveryPage, CancellationRefundPage, and ContactSection.
- These are wrapped by PolicyLayout, indicating a separate layout pattern for legal/help content versus the main ordering flow.
6. Admin-facing surface
- Admin functionality is isolated into dedicated components: AdminLogin, AdminDashboard, AdminInventory, AdminOrderDashboard, and AdminInvoices.
- This is a separate operational lane from the customer UI, likely used for product management, order handling, and billing oversight.
7. Backend API structure
- The backend is organized by domain with route and controller layers:
- auth, admin, product, cart, order, payment, delivery, and review
- Controllers mirror those domains in src/controllers/, which keeps business logic separated from route wiring.
- There are also route variants like productRoutes.js and reviewRoutes.js, suggesting either legacy naming or alternate route grouping.
8. Backend data model layer
- MongoDB models are defined for the core entities:
- User
- Product
- Order
- Review
- This model set matches the app’s main business objects: accounts, catalog items, purchases, and feedback.
9. Backend infrastructure and boundaries
- config/db.js handles database connectivity.
- middlewares/authMiddleware.js protects authenticated/admin-only actions.
- config/mailer.js and utils/smsSender.js indicate outbound notifications via email and SMS.
- seed.js provides initial data loading, which matters for bootstrapping menu/catalog content.
10. Operational data flow
- The likely end-to-end flow is:
- frontend requests catalog data from product endpoints
- cart state is built client-side and may sync to backend
- checkout creates an order and payment intent/result
- backend triggers delivery/order notifications and status updates
- frontend reads updated order state via API and possibly sockets
- This architecture splits interactive UI state from durable server-side order state.
11. External services and integrations
- MongoDB is the primary persistence layer.
- Email and SMS are first-class integration points for customer communication.
- Real-time socket support on the frontend implies live order or status updates are part of the system design, even though the backend socket implementation is not visible in the tree.
12. What to emphasize in a diagram
- Show a clear boundary between customer/admin React UI and the Express API.
- Inside the backend, separate routes, controllers, models, and integrations.
- On the frontend, emphasize context providers and feature components rather than page-only routing.
- Highlight the order lifecycle as the central business flow connecting catalog, cart, payment, delivery, and admin operations.
Main entry points: controllers Controllers · Dishes.jsx Customer flow · main.jsx App shell · context Contexts
Components 19
Frontend
React/Vite customer and admin UI
- App shell · Frontend bootstrapping and global styles
frontend/src/main.jsx - Contexts · Auth, cart, loading, and socket state
frontend/src/context - Customer flow · Browse menu, cart, checkout, orders, and reviews
frontend/src/components/Dishes.jsx - Admin surface · Admin login, dashboard, inventory, orders, and invoices
frontend/src/components/AdminDashboard.jsx - Policy pages · Legal, support, and informational pages
frontend/src/components/PolicyLayout.jsx - Media assets · Menu imagery, gallery media, and promo video
frontend/src/assets
Backend
Express API, data, and integrations
- API server · Backend entrypoint and HTTP server
backend/src/server.js - Routes · Domain route wiring for auth, catalog, cart, orders, payments, and admin
backend/src/routes - Controllers · Request handling for core domains
backend/src/controllers - Models · User, product, order, and review documents
backend/src/models - Auth guard · Authentication and authorization checks
backend/src/middlewares/authMiddleware.js - Mongo config · Database connection setup
backend/src/config/db.js - Notifications · Email and SMS outbound messaging
backend/src/config/mailer.js - Seed data · Initial catalog and data loading
backend/src/seed.js - Auth API · Login and session endpoints
backend/src/routes/auth.js - Catalog API · Product browsing and menu endpoints
backend/src/routes/product.js - Order API · Cart, order, and payment endpoints
backend/src/routes/order.js - Admin API · Admin operations for inventory and orders
backend/src/routes/admin.js - Review API · Customer review endpoints
backend/src/routes/reviewRoutes.js
Connections 22
- App shell → Contexts: provides state · App shell composes global providers
- App shell → Customer flow: renders · Main UI mounts ordering flow
- App shell → Admin surface: renders · Admin area is part of the same frontend
- App shell → Policy pages: routes to · Legal and support pages use a separate layout
- Customer flow → Media assets: uses media · Menu and promo visuals come from static assets
- Admin surface → Admin API: calls · Admin UI operates through admin endpoints
- Customer flow → Catalog API: fetches catalog · Menu browsing reads product data from API
- Customer flow → Order API: checks out · Cart and order submission flow to backend
- Customer flow → Review API: submits reviews · Ratings and feedback are persisted server-side
- Contexts → Auth API: auth state · Login/session context depends on auth endpoints
- Contexts → Order API: syncs cart · Cart and socket state coordinate with order lifecycle
- API server → Routes: mounts · Server wires route modules
- Routes → Controllers: delegates · Routes forward requests to domain controllers
- Controllers → Models: reads/writes · Controllers persist and query MongoDB models
- Controllers → Auth guard: protects · Sensitive actions are guarded by middleware
- API server → Mongo config: connects · Server initializes MongoDB connection
- Controllers → Notifications: sends alerts · Orders and delivery events can trigger email/SMS
- Seed data → Models: loads · Bootstrap data populates core collections
- Catalog API → Controllers: uses · Product routes map to product controller logic
- Order API → Controllers: uses · Order/payment/cart routes map to corresponding controllers
- Admin API → Controllers: uses · Admin endpoints reuse admin controller logic
- Review API → Controllers: uses · Review routes map to review controller logic