How olasunkanmi-se/restaurant works
Main components
• Frontend: Built with React (located in the frontend directory). It includes pages, components, contexts, reducers, and APIs which interact with the backend.
• Backend: Developed using NestJS (found under the backend directory). It follows a modular structure, splitting responsibilities into distinct modules such as addon, category, cart, item, location, menu, order, order_manager, order_notes, order_processing_queue, order_statuses, restaurant, singleclient, etc.
• Authentication & Authorization: Managed by the AuthModule alongside JWT-based authentication components (strategies, guards, decorators).
• Data Persistence: Interfaces with a MongoDB database through the DocumentDatabaseModule in the backend infrastructure, and there are numerous repository patterns and schemas to manage data access.
• API Gateway/Endpoints: Exposed endpoints such as /api/restaurants, /api/menus, /api/items, /api/orders, /api/singleclients to handle CRUD operations and communications between the frontend and backend.
• External Services & Utilities: Includes middlewares, context management, logging utilities, and validation pipes to enforce data integrity and proper error handling.
Relationships and interactions
• The AuthModule and its supporting infrastructure (guards, strategies, decorators) act as cross-cutting concerns enforcing security and user identity checks.
• The infrastructure layer ties in the database and repository components, depicting how the backend modules rely on repositories (e.g., addon.repository, cart-item.repository, etc.) to interact with MongoDB.
• A separation of concerns is evident by the division between application logic (domain, services), infrastructure (data access, authentication, logging), and presentation (controllers).
Important architectural patterns and design principles
• Modular design: The backend is partitioned into numerous feature-specific modules ensuring separation of concerns.
• MVC/Mediator pattern: Controllers handle HTTP requests, services implement business logic, and repositories manage data persistence.
• Domain-Driven Design (DDD): The project includes domain, entity, and value object layers, which encapsulate business rules and entities.
• Repository Pattern: Used extensively for data access abstraction in the infrastructure layer.
• JWT Authentication and Role Based Access Control: Security is enforced using JWT-based strategies and custom middleware/guards.
• Client-side state management: The frontend leverages Context APIs and reducers for shopping cart and session management.
• Frontend:
• Pages and Components (Authentication, Menu, Cart, Order screens)
• API layer (Axios calls, API gateways)
• Backend:
• Controllers (e.g., restaurant.controller, menu.controller, order.controller)
• Services and Modules (AuthModule, OrderModule, etc.)
• Domain Layer (Entities, Value Objects, Mappers)
• Infrastructure (JWT strategies, guards, data access repositories, DocumentDatabaseModule)
• Database and External Services:
• MongoDB along with repository models and schemas
• External API endpoints if any (as suggested by the Postman collection)
Emphasizing details
• Don’t shy away from splitting the backend into its several sub-components if needed – the goal is to capture every aspect of the system.