How amunozsuarez/gestion-restaurante works
Project Type and Purpose
• This is a full-stack web application (“Sistema de Gestión de Restaurante”) providing three user-facing modules—Mostrador (counter), Delivery and Admin—for order management, product/category management, customer management, cash register and reporting.
File Structure Analysis
• Top level:
• backend – Node.js/Express REST API
– src/bdd: MongoDB connection
– src/models: Mongoose schemas (User, Restaurant, Category, Food, Order, Customer, CashRegister)
– src/controllers: business logic per entity
– src/routes: Express routers mapping endpoints (/api/auth, /user, /restaurant, /category, /food, /order, /customer, /cash, /report)
– src/middlewares: auth (JWT), role-based, restaurant filtering
– server.js: API entry point
• frontend – React SPA
– public: index.html, static assets
– src/components: UI components split by module (admin, cart, common, forms, layout, lists, pages for delivery/mostrador/login)
– src/hooks: custom hooks (API access, business logic, state/forms)
– src/services: axios config, React Query client, API wrappers
– src/store: global state (Zustand stores for auth, cart, UI, restaurant)
– src/styles: CSS by component/module
a. Main Components
• Client layer: React SPA with three logical modules (Mostrador, Delivery, Admin)
• API layer: Node.js/Express server
• Data layer: MongoDB database
• Auth subsystem: JWT issuance & validation middleware
• External services: (optional) Email/SMS gateways, third-party payment or delivery partner APIs
b. Relationships & Data Flows
1. User (browser/mobile) interacts with the React SPA
2. SPA calls backend endpoints via Axios/React-Query (using REACT_APP_API_URL)
3. Express middleware validates JWT and user roles, then routes to controllers
4. Controllers perform CRUD via Mongoose models against MongoDB
5. Responses propagate back through middleware to the client
6. For reporting, the server aggregates data and returns analytics
c. Architectural Patterns & Design Principles
• Client-Server separation
• MVC pattern on backend (Models, Controllers, Routes)
• Component-based architecture on frontend with custom hooks for separation of concerns
• Single source of truth for global state (Zustand)
• API layer secured via JWT + role-based access
• Modularization by feature (admin vs. user vs. order management)
d. Key Technologies & Frameworks
• Frontend: React 19, React Router 7, Zustand, React Query, Axios, React Toastify
• Backend: Node.js, Express, Mongoose (MongoDB), JWT, bcrypt, Morgan