How yasen-ab/homeychefpt works
1. Overall shape
- HomeyChef is a single Node.js/Express backend that also serves its own browser UI from backend/views.
- The system is organized as a layered monolith: client pages and scripts call Express routes, controllers orchestrate requests, services handle non-trivial business logic, and Sequelize models persist to MySQL.
2. Entry points and bootstrapping
- backend/server.js is the runtime entry point.
- backend/config/database.js configures the Sequelize/MySQL connection, while backend/config/syncDatabase.js suggests schema sync/initialization support.
- The app likely mounts route modules by domain and exposes both API endpoints and static view assets.
3. Presentation layer
- The browser UI lives under backend/views as HTML/CSS/JS, not as a separate SPA build system.
- There are distinct screens for login/register, user dashboard, chef dashboard, admin dashboard, menu/dishes, cart, orders, favorites, notifications, statistics, and password recovery.
- Frontend JavaScript files call backend endpoints and handle page-specific interactions such as authentication, cart updates, notifications, and analytics.
4. API boundary and domain routing
- Routes are split by business area: auth, users, chefs, dishes, orders, cart, favorites, reviews, notifications, statistics, and admin.
- This boundary maps cleanly to the main use-case groups in the README: customer browsing/orders, chef management, and admin moderation.
- backend/controllers/*Controller.js files form the request-handling layer for each domain.
5. Core business domains
- Users and Chefs are intentionally separate account tables, not inheritance-based variants of one table.
- Other core domains are Dish, Order, OrderItem, Review, Favorite, Notification, and PasswordReset.
- This separation supports distinct lifecycle rules for customers, chefs, and admins, and keeps chef onboarding/moderation independent from customer identity.
6. Order and menu flow
- Customer-facing flows start with browsing chefs/dishes, then move into cart, checkout, and order creation.
- Orders are decomposed into Order plus OrderItem records, which is the main persistence boundary for multi-item purchases.
- Chefs manage order state transitions such as accept/reject/complete, while customers can track and cancel orders depending on status.
7. Chef operations and availability
- Chef capabilities include profile management, dish CRUD, image upload, and sales/statistics views.
- ChefAvailability indicates a separate scheduling layer for availability slots, holidays/leaves, and automatic rejection outside working hours.
- This means order acceptance is constrained not just by status, but also by chef availability rules.
8. Favorites, reviews, and discovery
- Favorite supports user-curated saved items, likely spanning dishes and/or chefs as described in the README.
- Review captures ratings and feedback for chefs, feeding both dish/chef discovery and reputation.
- dishes, chefs, and reviews routes together implement browsing, filtering, and trust-building for the marketplace side of the system.
9. Authentication and authorization
- backend/middleware/auth.js enforces protected access and role-based boundaries for User / Chef / Admin.
- Authentication includes JWT access/refresh tokens, Google OAuth2 login, bcrypt password hashing, and role-aware route protection.
- Account state logic is centralized in backend/utils/accountStatus.js, which likely supports moderation actions such as activation/deactivation.
10. Password recovery and email
- OTP-based password reset is modeled explicitly through PasswordReset, separate from user credentials.
- backend/utils/mailer.js and backend/controllers/authController.js coordinate email delivery and token validation.
- The README’s 15-minute hashed OTP policy suggests the reset flow is designed as a short-lived, server-verified security path.
11. Notifications and real-time delivery
- Notifications are both persisted (Notification model) and pushed in real time through backend/socket/notificationSocket.js.
- backend/services/notificationService.js appears to centralize notification creation and fan-out, so events from orders or admin actions can become both database records and socket events.
- This is one of the few genuinely asynchronous boundaries in the system.
12. Admin and analytics
- admin routes and statisticsController.js back the admin dashboard and platform reporting.
- Admin capabilities include moderating users/chefs, viewing system metrics, and monitoring overall platform activity.
- Chef-specific statistics are also supported, meaning analytics is split between platform-wide and per-chef views.
13. Infrastructure and storage
- The data layer is MySQL via Sequelize.
- Image handling is implied by dish/profile uploads and the presence of view scripts for upload-heavy pages; uploaded assets are part of the backend-managed filesystem rather than an external media service.
- Email uses Nodemailer with Gmail App Passwords, and external auth depends on Google OAuth2.
14. What to show in an architecture diagram
- A useful diagram would show: browser views/scripts → Express routes → controllers → services → Sequelize models → MySQL, with side channels for email OTP, Google OAuth, and socket-based notifications.
- The key boundaries are role-based access, separate user/chef identities, and the split between synchronous request handling and real-time notification delivery.
Main entry points: server.js Server · index.html Browser UI · auth.js Auth Guard · User.js Core Models
Components 20
Presentation
Browser-served HTML/CSS/JS UI
- Browser UI · Server-rendered pages and page scripts for customers, chefs, and admins.
backend/views/index.html
API Layer
Express entrypoints, routes, and middleware
- Server · Bootstraps the app and wires routes, views, and infrastructure.
backend/server.js - Auth Guard · Protects routes and enforces role-based access.
backend/middleware/auth.js - Auth Routes · Login, registration, OAuth, and password recovery endpoints.
backend/routes/auth.js - User Routes · User account and profile endpoints.
backend/routes/users.js - Chef Routes · Chef profile, availability, and management endpoints.
backend/routes/chef.js - Dish Routes · Menu and dish browsing or CRUD endpoints.
backend/routes/dishes.js - Order Routes · Cart checkout and order lifecycle endpoints.
backend/routes/orders.js - Admin Routes · Moderation and admin dashboard endpoints.
backend/routes/admin.js - Notify Routes · Notification retrieval and management endpoints.
backend/routes/notifications.js
Domain Logic
Controllers, services, and business rules
- Auth Controller · Handles authentication, OTP reset, Google login, and account state flow.
backend/controllers/authController.js - Order Controller · Coordinates cart checkout and order state transitions.
backend/controllers/orderController.js - Chef Controller · Manages chef profiles, availability, and chef-facing actions.
backend/controllers/chefController.js - Stats Controller · Serves platform and chef statistics.
backend/controllers/statisticsController.js - Notification Service · Creates notifications and fans them out to real-time clients.
backend/services/notificationService.js
Data & Infra
Persistence, sockets, and external integrations
- DB Config · Configures the MySQL connection and schema sync support.
backend/config/database.js - Sync DB · Initializes or synchronizes database schema.
backend/config/syncDatabase.js - Socket Channel · Pushes notification events to connected clients.
backend/socket/notificationSocket.js - Mailer · Sends OTP and account-related emails.
backend/utils/mailer.js - Core Models · Users, chefs, dishes, orders, reviews, favorites, notifications, and reset tokens.
backend/models/User.js
Connections 34
- Server → DB Config: configures · Initializes the database connection before handling requests.
- Server → Sync DB: syncs · Can prepare or synchronize schema at startup.
- Server → Auth Routes: mounts · Registers domain route modules on the Express app.
- Server → User Routes: mounts · Registers domain route modules on the Express app.
- Server → Chef Routes: mounts · Registers domain route modules on the Express app.
- Server → Dish Routes: mounts · Registers domain route modules on the Express app.
- Server → Order Routes: mounts · Registers domain route modules on the Express app.
- Server → Admin Routes: mounts · Registers domain route modules on the Express app.
- Server → Notify Routes: mounts · Registers domain route modules on the Express app.
- Server → Browser UI: serves · Hosts the browser UI from backend/views.
- Auth Routes → Auth Guard: protects · Applies route protection where needed.
- Auth Routes → Auth Controller: dispatches · Forwards requests into authentication handling.
- User Routes → Auth Guard: protects · Enforces role-based access.
- Chef Routes → Auth Guard: protects · Enforces role-based access.
- Dish Routes → Auth Guard: protects · Enforces role-based access for mutating actions.
- Order Routes → Auth Guard: protects · Enforces authenticated order and cart access.
- Admin Routes → Auth Guard: protects · Restricts moderation and reporting endpoints.
- Notify Routes → Auth Guard: protects · Restricts notification access.
- Auth Controller → Core Models: uses · Reads and updates user, chef, and password reset records.
- Auth Controller → Mailer: emails · Sends OTP and recovery messages.
- Auth Controller → Socket Channel: signs in · May emit account-related socket events through shared app state.
- Chef Controller → Core Models: uses · Manages chef profile and availability records.
- Order Controller → Core Models: uses · Persists orders, items, and status changes.
- Order Controller → Notification Service: announces · Triggers notifications for order events.
- Stats Controller → Core Models: reads · Aggregates platform and chef metrics from persisted data.
- Notification Service → Core Models: persists · Creates notification records before delivery.
- Notification Service → Socket Channel: pushes · Fans notification events out to connected clients.
- Browser UI → Auth Routes: calls · Login, register, and reset flows use auth endpoints.
- Browser UI → Order Routes: calls · Cart, checkout, and order pages use order endpoints.
- Browser UI → Chef Routes: calls · Chef dashboard and profile pages use chef endpoints.
- Browser UI → Dish Routes: calls · Menu and browse pages use dish endpoints.
- Browser UI → Admin Routes: calls · Admin dashboards use moderation endpoints.
- Browser UI → Notify Routes: calls · Notification pages poll or fetch notification data.
- Browser UI → Socket Channel: subscribes · Client scripts listen for real-time notification updates.