How huynhduydong/mastershop works
Main Components to Highlight
• API Gateway: Represent the module found under both LavenShopBackend/api-gateway and additional gateway-related code in src. This component is responsible for routing client requests, enforcing security (e.g., using JWT filters and OAuth2 in security configs), rate limiting (via filters configured with Resilience4j and RateLimitFilter), and offering fallback controllers.
• Microservices:
• Auth Service: Located under MasterShopMicroservices/auth-service. It handles user authentication, token management, security configuration, and error handling with dedicated controllers and services.
• User Service: Located under MasterShopMicroservices/user-service, it deals with user management; its architecture includes controllers, DTOs, repositories, and service layers.
• Other potential domain services: Though not isolated into separate directories, the main back-end under src contains controllers and services for handling products, orders, cart, address, notifications, and reviews. These are typically part of the core business logic in an e-commerce platform.
• Infrastructure Services:
• Config Server: Found in MasterShopMicroservices/config-server. It centralizes configuration management for various services with its own set of configuration files.
• Discovery Server: Located in MasterShopMicroservices/discovery-server. It provides service discovery (likely using Spring Cloud or Netflix Eureka) so that the API gateway and services can register/find each other dynamically.
• Database: Indicate a relational database (evidenced by various SQL scripts in resources/scriptdb) that serves as a persistent data storage layer for both domain and authentication data.
• Redis Cache: Shown by the presence of Redis configuration and related services. It is likely used for caching data such as sessions or shopping cart information.
• Front-end Client: Although in a separate repository, mention that the user-facing client (Next.js/React) communicates with the back-end system via the API gateway for a value-added, next-generation UI.
Relationships and Interactions
• The Client (front-end) sends HTTP-based API requests to the API Gateway.
• The API Gateway, after doing authentication/authorization checks (using JWT filters), routes requests to the appropriate microservice (e.g., Auth Service for login, User Service for user profile management, and other services for product or order operations).
• The microservices register themselves with the Discovery Server and fetch configuration properties from the Config Server.
• Communication between microservices (if any) can be shown through service calls mediated by the API gateway and supported by discovery.
• Error handling, logging, and resilience (with Zipkin and resilience patterns) should also be represented.
• A separate data flow line connects the services to the Database and Redis cache systems.
Architectural Patterns and Design Principles
• Microservices Architecture: Each service is designed as an independent deployable unit.
• Gateway Pattern: The API Gateway abstracts the complexity of the microservices from the client.
• Service Discovery: The Discovery Server enables dynamic resolution of service locations.
• Centralized Configuration: The Config Server provides common configuration to all microservices.
• Security & Exception Handling: Each service implements its own security and error handling mechanisms (e.g., GlobalExceptionHandler in multiple modules).
• Cache Layer: Integration of Redis for performance enhancements in session management or data caching.
Relevant Technologies
• Java 17, Spring Boot 3, OAuth2, Spring Security, and Spring Cloud (for discovery and configuration).
• Next.js, React.js, TailwindCSS for the front end.
• Redis for caching; SQL-based databases as suggested by the scripts.
• Zipkin for distributed tracing.