How hoangm416/hustfood works
Main Components
• Frontend (Client-Side):
– Built with React using TypeScript and Vite (as indicated by the presence of vite.config.ts, tsconfig, and .tsx files)
– Contains pages (e.g., HomePage, DetailPage, UserProfilePage), auth components (e.g., Auth0ProviderWithNavigate, ProtectedRoute) and common UI components (Header, Footer, and various reusable UI components).
– Includes modules for API interactions where the frontend calls backend endpoints.
• Backend (Server-Side):
– Built in Node.js using TypeScript (noted by .ts files throughout the backend folder)
– Follows an MVC-like structure with clear separation into controllers (e.g., MyRestaurantController.ts, OrderController.ts), models (e.g., order, restaurant, user), middleware layers (authentication and validation), and routing files.
– Offers REST API endpoints that the frontend communicates with (as seen in the routes directory work).
• Database:
– Although not represented directly in the file tree, the README mentions MongoDB, so including it as the persistence layer is key.
– The models directory in the backend reflects the data structure that is likely stored in MongoDB.
• External Services/Integrations:
– Auth0: For user authentication, as evidenced by the frontend/auth directory components and provided account credentials in the README.
– Cloudinary: Likely used for managing media (images, restaurant photos, etc.).
– MoMo Payment Gateway: The README instructions mention downloading the MoMo UAT application, indicating integration for processing payments.
Relationships and Interactions
• The backend handles business logic in controllers and interacts with the MongoDB database to store or retrieve entities like orders, restaurants, and users.
• For image uploads or media management, show an interface between the backend or possibly directly the frontend and Cloudinary.
• Payment processing is facilitated through the MoMo payment gateway. Indicate communication from the backend (or directly from a payment module) to the MoMo service.
Architectural Patterns & Design Principles
• Classic separation of concerns:
• The frontend is a decoupled, client-side application with its own routing and state management.
• The backend uses an MVC-like pattern: controllers (handling requests), models (data representation), and routes (defining API endpoints), along with middleware for cross-cutting concerns like authentication and validation.
• Component-based design for the frontend (clearly visible through the numerous reusable UI components) and RESTful API design in the backend.
• Importance of external integrations (authentication, storage, payment) as part of the system design.