How anselmo07/chatbot-de-sushi works
Main Components
• Frontend: Built in React (using Vite), this is where the user interface is implemented. The frontend is responsible for rendering the chatbot UI (e.g., pages like Chatbot.jsx) and communicates with the backend via API calls (configured through environment variables such as NEXT_PUBLIC_API_URL).
• Backend: This is a Node.js server using the NestJS framework. It is organized into multiple modules including “chat”, “menu”, “faqs”, and “orders”. Each module has its own controller, service, and, in some cases, entity definitions.
• Database: Although the file tree only shows connection configuration details (MONGO_URI), the backend connects to a MongoDB database to store persistent data, such as order details, menu items, and FAQ information.
• Middleware & Seeding: The backend includes middleware (e.g., horarios for scheduling) and seed data (for chat help and products) that initialize or enrich the system with default value sets.
Relationships & Interactions
• Client-Server Communication: The frontend makes API calls to the backend. For example, the React UI sends GET requests to endpoints like /menu/comida, /faqs/status, /chat/ubicacion, and a POST request to /orders for placing an order.
• Module Interactions within the Backend: Each NestJS module (chat, menu, faqs, orders) encapsulates its responsibilities. They may interact with shared services or use custom middleware for cross-cutting concerns.
• Database Access: The backend modules interact with the MongoDB database using defined entities. These entities (such as chat.entity.ts, menu.entity.ts, and order.entity.ts) map data structures to database collections.
Architectural Patterns & Design Principles
• Separation of Concerns: The project clearly distinguishes between presentation (frontend) and business logic (backend). In the backend, the use of NestJS modules enforces modularity.
• RESTful API Design: The endpoints follow REST principles by providing distinct actions (GET for fetching data, POST for creating orders).
• Configuration Management: Environment configuration is managed separately for both the frontend and backend, enhancing security and flexibility.
• Self-seeding and Initialization: The presence of seed scripts within the backend ensures that initial data is loaded into the system.
Relevant Technologies and Frameworks
• Frontend: React, Vite (for bundling), and CSS for styling.
• Backend: Node.js with the NestJS framework, and integration with MongoDB as the database.
• Additional Tools: ESLint, Prettier for code quality, and tools like jest for testing, are included in the project.