How lileijordan/hmall works
Main Components
a. UI / Client Layer:
• Web applications and static content served via hmall-nginx. This includes the admin and customer portal pages.
b. API Gateway:
• hm-gateway serves as the entry point. It handles routing, authentication (via Jwt and security configs), and filters (e.g., LoginGlobalFilter).
c. Microservices:
• cart-service: Manages shopping cart operations.
• item-service: Handles product and inventory management.
• pay-service: Processes payments.
• trade-service: Manages orders and trade details.
• user-service: Handles user and address information.
d. Shared Components:
• hm-common: Contains common utilities, configuration files (e.g., MyBatisConfig, MvcConfig), exception handling, and database scripts.
• hm-api: Provides the open feign interfaces, DTOs, fallback mechanisms, and interceptors that allow inter-service communication.
e. Middleware / External Services:
• Nacos: For centralized configuration management.
• Seata: For distributed transactions.
• Sentinel: For fault tolerance and rate limiting.
• Other middleware (e.g., Feign for remote calls).
Relationships and Interactions
• Requests from users initiate at the UI layer (nginx) and are forwarded to the hm-gateway.
• The gateway, after applying security and routing rules (with JWT and security filters), directs the requests to the corresponding microservices.
• Within each microservice, the MVC (or layered) structure is evident:
• Controllers receive HTTP requests.
• Service layers (with interfaces and implementations) process business logic.
• Mappers/data access layers interact with the underlying MySQL databases.
• Inter-service communication is handled via Feign clients defined in hm-api. For example, the Cart service might call the Item service via CartClient or ItemClient.
• Shared modules (hm-common) are imported across services to standardize exception handling, JSON configurations, and other utilities.
• Middleware components such as Nacos, Sentinel, and Seata are integrated into configuration files (bootstrap.yaml, application.yaml) in each service to support configuration, monitoring, and distributed transaction management.
Key Architectural Patterns
• Microservices orchestration using Spring Cloud.
• API gateway pattern to centralize access and routing.
• Layered (MVC) architecture within each service.
• Use of shared libraries (hm-common) and API contracts (hm-api) for consistency.
• Distributed transaction management (Seata) and circuit breaking/rate limiting (Sentinel).
Relevant Technologies and Frameworks
• Spring Boot and Spring Cloud across services.
• MyBatis for data persistence.
• Nacos for dynamic configuration.
• Seata for distributed transaction management.
• Sentinel for fault-tolerance.
• Feign for declarative REST clients.
• Docker (as mentioned) for deploying non-JDK components like Sentinel.
• JDK 11 as the project’s runtime base.
• NGINX for serving static web pages (admin/portal).
Detailed Steps for the Principal Software Engineer
• Within the microservices layer, list and separate each service (cart, item, pay, trade, user) and briefly annotate their responsibilities based on the file paths and domain classes.
• A side note block for shared modules (hm-common, hm-api) and how they integrate with the microservices (imported as dependencies for consistent functionality).
• Middleware services (Nacos, Seata, Sentinel) to each microservice and the gateway to emphasize their roles in configuration and resiliency.
• Flow of requests from the UI to the backend, ensuring a clear depiction of how requests are authenticated, processed, and how inter-service communication works via Feign clients.
• Finally, mark configuration points (application.yaml, bootstrap.yaml) as examples of where central configuration is applied.
• Being detailed by capturing not only the distinct services but also the crucial infrastructural dependencies that drive the project’s behavior.