How rffrench/portafolioweb works
Project Type and Overall Purpose
• The project is one of several components in a microservices architecture for a restaurant management website. This particular repository implements the NodeJS frontend, which uses EJS as a template engine together with plain HTML, CSS, and client-side JavaScript.
• It serves as the user interface to interact with the backend orchestrator as well as with services handling authentication, restaurant operations (orders/reservations), finance, and warehouse management.
Analyzing the File Structure
• Top-level files/folders:
– app.js: The entry point running the Express server.
– controllers: Contains logic for different routes (admin, auth, finance, restaurant, warehouse, error handling).
– middleware: Example – authMiddleware.js for validating user credentials/JWT tokens before processing requests.
– models: Defines data models (e.g., InventoryOrder, productModel, reservationsModel, userModel) used by Sequelize ORM for communicating with the single MySQL database.
– routes: Divided into different endpoint groups (admin, auth, finance, restaurant, warehouse) that map URLs to corresponding controller actions.
– public: Hosts static assets including CSS, JavaScript, and media used in the frontend.
– views: EJS templates organized by feature (admin, auth, finance, restaurant, warehouse) and layout files (includes folder) responsible for rendering the HTML sent to the client.
• Utility and configuration modules in the util folder support the overall backend processing (error handling, configuration constants).
Key Information from the README
• The README spells out how the entire system is broken up into several microservices (“Auth Microservice”, “Restaurant Microservice”, “Admin Microservice”) besides the main orchestrator and the NodeJS frontend (this repository).
• Authentication relies on JWT tokens (stored in cookies) that are validated by the backend microservices through the orchestrator, and the communication is strictly via RESTful HTTP requests.
• Additional applications (desktop admin app, totem waiter app, etc.) and their integration with the orchestrator are part of the overall ecosystem.
• The project uses a “microservices architecture” pattern with orchestration—not choreography—so central request routing and security validation (JWT checks) are managed by the orchestrator service.
a. Main Components of the System
• Browser/Client: Represents the end-user’s device accessing the website.
• NodeJS Frontend Service (this repository):
– Controllers (adminController, authController, financeController, restaurantController, warehouseController, errorController, messenger)
– Routes (adminRoutes, authRoutes, financeRoutes, restaurantRoutes, warehouseRoutes)
– Middleware (authMiddleware responsible for JWT validation)
– Models (data models interacting with the MySQL database via Sequelize)
– Views (EJS templates assembling HTML, organized by functional areas).
• External Orchestrator Microservice: Acts as a gateway by forwarding RESTful HTTP requests after checking JWT tokens.
• Backend Microservices:
▪ Auth Microservice (handles signup/login, JWT creation, password management, and email notifications).
▪ Restaurant Microservice (handles orders, reservations, menu image processing and compression, customer operations).
▪ Admin Microservice (handles administration tasks including operations for finance, warehouse, waiters, etc.).
• MySQL Database: A singular database shared among the microservices for data persistence.
b. Relationships and Interactions
• The NodeJS Frontend communicates with the Orchestrator service using RESTful HTTP, including JWT authorization tokens.
• The Orchestrator then routes the requests to the appropriate microservices (Auth, Restaurant, and Admin).
• Each microservice also communicates with the common MySQL database to perform CRUD operations.
• Additionally, socket-based connections (as mentioned in the README for real-time updates) and static file serving (CSS/JS in the public folder) should be illustrated where applicable.
c. Highlighting Architectural Patterns and Design Principles
• Microservices-based architecture along with the orchestration pattern used (i.e., a central orchestrator service that validates and forwards requests).
• Separation of concerns:
– The frontend (presentation layer) is distinctly separated from the business logic (handled by controllers and routed appropriately).
– Data persistence is abstracted via Sequelize models.
d. Relevant Technologies, Frameworks, and Libraries
• Node.js with Express for server handling.
• EJS for template rendering.
• Sequelize ORM for database operations with MySQL.
• Socket.io for real-time communications (if implemented in the app.js or elsewhere).
• JWT for authentication and authorization.
– Browser/Client
– Orchestrator Microservice
– Auth, Restaurant, and Admin Microservices
– MySQL Database
– Data flow from the client to the frontend, then to the orchestrator, and finally to the appropriate microservice.
– Internal flows, such as middleware checking JWT before routing to controllers.