How tuandat1601/food_delivery_backend_go works
Main Components
• API/Transport Layer: Represented by the “internal/transport/gin” directory, which includes handlers for various endpoints (menus, restaurants, users). Also include “internal/routes” where the routing logic is defined. This layer receives HTTP requests, performs parameter validation, and delegates processing to business logic.
• Business Logic Layer: Located in “internal/biz,” this is where core functions for handling menu creation, restaurant management, and user authentication reside. This layer encapsulates business rules and processing.
• Data Model & Repository Layer: Indicated by the “internal/model” (domain objects like food, order, restaurant, user) and “internal/repositories” (actual data access operations) directories. This layer handles interactions with the database.
• Middleware: The “internal/middleware” component (e.g., authentication) ensures that security and access control are enforced before reaching the business logic.
• Database: External to the codebase but integral – represented by the “database” directory containing migrations (schema and initial data) and then your Postgres database.
• Configuration and Environment: The “config”, “app.env”, and related files provide environment-specific settings which configure how the application runs.
• Documentation: The “docs” folder (with Swagger JSON/YAML) provides API documentation that informs how clients should interact with the service.
• Orchestration/Deployment: Files like the Dockerfile and docker-compose.yml define containerization details and how the service is deployed.
• External Clients: Although not a direct code component, include clients like restaurant managers (web/mobile apps) and customers (web/mobile interfaces) as external actors interacting via HTTP.
• Middleware (authentication) as an inline security check that intercepts requests before reaching the business layer.
• Also, note configuration services that feed environment and runtime settings into the system.
• Optionally, show a side component for documentation (Swagger) which clients can refer to for API details.
Architectural Patterns and Technologies
• Layered Architecture: Separate concerns clearly into transport (Gin handlers), business logic (biz), and data access (repositories/models).
• RESTful API Design: Represented through clearly defined routers in “internal/routes” and handlers in “internal/transport/gin”.
• Middleware Pattern: Authentication is applied globally or on selected routes.
• Database Migrations: Show that a migration process exists (database/migrations) to update the schema in the Postgres database.