How cntt-uth/shopee-clone-be works
Main Components
• Frontend & External Clients: Although this repository is for the backend API, note that it is developed to work in tandem with a separately hosted frontend. Indicate that external clients (e.g., the Shopee-clone Frontend) interact with this API.
• API Gateway (Express Application): Represent the Express server as the main entry point for requests, where middleware (authentication, error handling, rate limiting, helmet, etc.) is applied.
• Controllers & Routes: Show that HTTP requests are routed through clearly organized controllers (for addresses, authentication, products, orders, payments, shipping, etc.) which then forward the requests as necessary.
• Data Access Layer: Illustrate the repository components that interact with the database using TypeORM. Add “models” or “entities” (DTOs and entity definitions) that structure the data.
• Database: Display the MariaDB database and mention that migrations and seeders are used to initialize data.
• External Services & Libraries:
• Cloudinary & Sharp for media upload and image processing.
• Winston for logging.
• Swagger (API docs available at /api-docs) for documentation.
• Data Crawling & Scripts: Optionally include a side module for the “crawl” functionality (external scripts that scrape or seed product, shop, and category data) to show data ingestion paths.
Relationships and Interactions
• From the API gateway, split the flow into the controller layer which then relays validated data to the service layer (using Awilix for DI).
• That the service layer talks to the repository layer which in turn interacts with the database.
• Middleware (authentication, validation, error handling) as intercepting the API request flow.
• Integration flows where media files pass through Cloudinary/Sharp and logs/errors funnel into Winston-based logging.
Architectural Patterns & Design Principles
• Layered Architecture: Separate the system into clear layers (API/Controller, Service, Repository/Data Access, and External Services).
• Dependency Injection: Emphasize how Awilix is used to decouple modules, making each component easily testable and maintainable.
• Modularization: Use clear boundaries (controllers, services, repositories) along with a modular file structure as shown by the folder hierarchy.
• RESTful Design: Represent that the API handles various endpoints (addresses, auth, cate, products, orders, etc.) compliant with REST principles.