How datnp1810/gocerystore_dacn works
Main Components
• Front-End Client: Represent the separately cloned Font-End project which interacts with the back-end via APIs.
• API Layer: Controllers (like HoaDonController, MonAnController, UserController, etc.) that expose endpoints for managing food products, orders, menus, and nutrition-related details.
• Business Logic Layer: Services (e.g., HoaDonService, EmailService, MonAnService, etc.) that encapsulate the core business rules, including supporting the GA algorithm for menu suggestions, email functionalities, and token management.
• Data Access Layer: Repositories (with their interfaces such as IMonAnRepository, IHoaDonRepository, etc.) that abstract away database interactions. Also include DTOs for data transfer between layers.
• Database Layer: SQL Server (with data and migration scripts, CSV seed files, and Entity definitions housed in the Entities folder).
• Supporting Components: Middleware for Authentication and Authorization (CustomAuthenticationMiddleware, CustomAuthorizationMiddleware) and other helpers (e.g., ApplicationAutoMapper, ApplicationRoles, EmailTemplateHelper).
• External Services: Indicate external integrations such as Email Services, Cloud-based image/file management (Cloudinary as evidenced by settings in Models), and any other external APIs or libraries (Swagger for API testing).
Relationships and Interactions
• Services interact with Repositories for database operations and use Entity Framework’s DbContext (ApplicationDbContext) to translate requests to SQL Server.
• Middleware intercepts incoming requests to enforce security (authenticated access via JWT) and applies authorization checks before the request reaches the Controllers.
• The GA Algorithm for menu suggestion should be highlighted as part of the business logic, possibly noted beside the ThucDonTuanService and related services.
Architectural Patterns
• Layered Architecture: Distinguish between Presentation (Controllers), Business Logic (Services), and Data Access (Repositories/Entities).
• Clean Separation of Concerns: Each layer/component should have clearly defined responsibilities—Controllers handling HTTP requests, Services processing business logic, and Repositories working with data persistence.
• Use of Middleware for cross-cutting concerns (authentication and authorization).
Technologies and Frameworks
• .NET Core and ASP.NET Core for building API services.
• Entity Framework Core for ORM and SQL Server for the database.
• Swagger for API documentation and testing.
• Threading and Memory Cache mechanisms for optimizing the GA algorithm and performance.
• External libraries for email management and cloud uploads (Cloudinary).