How sheldon1999/e-commerce-app works
1. This repository is a small e-commerce platform split into five independently built Spring Boot services plus shared container orchestration. The main architectural boundary is by business capability: catalog, inventory, orders, notifications, and edge routing.
2. The API Gateway is the single external entry point. It contains route configuration only, so its role is request forwarding and path-based routing rather than business logic. The README indicates it also aggregates Swagger/OpenAPI access for the backend services.
3. Product Service owns the product catalog. Its internal shape is a standard Spring layered service: controller → service → repository → MongoDB model/DTOs. The presence of InventoryFeignClient and a second inventory client package suggests it also performs synchronous calls to inventory during product-related workflows, likely to enrich responses or coordinate stock checks.
4. Inventory Service owns stock persistence and stock adjustment. It is implemented with Spring Data JPA against MySQL, uses Flyway migrations for schema setup, and has explicit domain exceptions for missing resources and insufficient stock. The InventoryRequest/InventoryResponse DTOs indicate a dedicated service API around stock operations.
5. Order Service is the orchestration point for checkout/order creation. It has a controller, service, JPA repository, and MySQL-backed Order model. It also depends on an inventory client, so order placement appears to synchronously verify or reserve inventory before persisting the order.
6. Order Service is also the main event producer. The OrderPlacedEvent class and the Avro schema under src/main/resources/avro/order-placed.avsc show that order creation emits a structured domain event, intended for Kafka-based asynchronous consumers.
7. Notification Service is the event-driven consumer side of the system. It has no persistence layer in the tree, which strongly suggests it reacts to order events and performs side effects such as email delivery without owning core business state.
8. The primary synchronous data flow is HTTP/REST between the gateway and the services, and service-to-service calls for inventory coordination. The primary asynchronous flow is Kafka-backed domain events from Order Service to downstream consumers such as Notification Service.
9. Persistence is polyglot and service-owned: Product Service uses MongoDB; Inventory and Order Services use MySQL; Notification Service appears stateless. Each service carries its own migration/init scripts, and the repository includes checked-in local database data directories, indicating a Dockerized development setup with persisted volumes.
10. Containerization is first-class. Every service has a Dockerfile, and there are Compose files at the repo root and in individual services. The root README confirms Docker Compose is used to bring up the full stack, including Kafka, MySQL, MongoDB, and a Kafka UI.
11. The codebase is organized for clean service boundaries: each service has its own pom.xml, source tree, test tree, and application bootstrap class. Testcontainers configuration classes in multiple services show that integration tests are expected to run against real backing services rather than mocks alone.
12. OpenAPI configuration exists in Product and Order Services, and the README says Swagger UI is exposed per service and through the gateway. That means documentation is a cross-cutting concern but still deployed per service, not centralized in a separate docs service.
Main entry points: docker-compose.yml Compose stack · Routes.java Routes · OrderService.java Order service · ProductService.java Product service
Components 22
Edge & orchestration
External entry point and local runtime stack
- Compose stack · Root multi-service orchestration for the full local stack
docker-compose.yml - API gateway · Single external entry point that forwards requests by route
api-gateway/src/main/java/com/programming/techie/api_gateway/ApiGatewayApplication.java - Routes · Path-based forwarding and service aggregation rules
api-gateway/src/main/java/com/programming/techie/api_gateway/routes/Routes.java
Business services
Independently built Spring Boot services
- Product API · HTTP surface for catalog operations
product-service/src/main/java/com/techie/microservices/product/controller/ProductController.java - Product service · Catalog workflows and inventory-aware coordination
product-service/src/main/java/com/techie/microservices/product/service/ProductService.java - Product repo · Persistence boundary for catalog data
product-service/src/main/java/com/techie/microservices/product/repository/ProductRepository.java - OpenAPI config · Per-service Swagger/OpenAPI setup
product-service/src/main/java/com/techie/microservices/product/config/OpenAPIConfig.java - Inventory client · Synchronous callout from catalog workflows to inventory
product-service/src/main/java/com/techie/microservices/product/client/InventoryFeignClient.java - Inventory API · HTTP surface for stock adjustment and lookup
inventory-service/src/main/java/com/techie/microservices/inventory/controller/InventoryController.java - Inventory service · Stock persistence, validation, and adjustment logic
inventory-service/src/main/java/com/techie/microservices/inventory/service/InventoryService.java - Inventory repo · Persistence boundary for inventory records
inventory-service/src/main/java/com/techie/microservices/inventory/repository/InventoryRepository.java - Order API · HTTP surface for checkout and order creation
order-service/src/main/java/com/techie/microservices/order/controller/OrderController.java - Order service · Checkout orchestration, inventory verification, and order persistence
order-service/src/main/java/com/techie/microservices/order/service/OrderService.java - Order repo · Persistence boundary for orders
order-service/src/main/java/com/techie/microservices/order/repository/OrderRepository.java - OpenAPI config · Per-service Swagger/OpenAPI setup
order-service/src/main/java/com/techie/microservices/order/config/OpenAPIConfig.java - Inventory client · Order-time synchronous dependency on inventory
order-service/src/main/java/com/techie/microservices/order/client/InventoryClient.java - Order event · Structured order-placed event published for async consumers
order-service/src/main/java/com/techie/microservices/order/event/OrderPlacedEvent.java - Notification service · Consumes order events and performs side effects like notifications
notification-service/src/main/java/com/techie/microservices/notification/service/NotificationService.java
Data stores & messaging
Service-owned persistence and async backbone
- Kafka · Asynchronous event backbone for order-driven workflows
- Inventory MySQL · Service-owned relational store for inventory state
inventory-service/docker/mysql/data - Order MySQL · Service-owned relational store for orders
order-service/mysql - Product MongoDB · Service-owned document store for catalog data
product-service/data
Connections 24
- Compose stack → API gateway: starts · Compose brings up the gateway alongside the services
- Compose stack → Inventory MySQL: provisions · Local stack includes inventory MySQL with persisted volume
- Compose stack → Order MySQL: provisions · Local stack includes order MySQL with persisted volume
- Compose stack → Product MongoDB: provisions · Local stack includes MongoDB with persisted volume
- API gateway → Routes: uses · Gateway app is driven by route definitions
- Routes → Product API: forwards · Routes expose catalog endpoints through the edge
- Routes → Inventory API: forwards · Routes expose inventory endpoints through the edge
- Routes → Order API: forwards · Routes expose order endpoints through the edge
- Product API → Product service: calls · Controller delegates catalog workflow handling
- Product service → Product repo: reads/writes · Catalog state is persisted via the repository
- Product service → Inventory client: checks stock · Catalog workflows synchronously coordinate with inventory
- Inventory API → Inventory service: calls · Controller delegates stock operations
- Inventory service → Inventory repo: reads/writes · Inventory state is persisted via the repository
- Inventory repo → Inventory MySQL: stores in · Inventory repository persists to MySQL
- Order API → Order service: calls · Controller delegates checkout orchestration
- Order service → Inventory client: verifies stock · Order placement synchronously depends on inventory
- Order service → Order repo: reads/writes · Order state is persisted via the repository
- Order repo → Order MySQL: stores in · Order repository persists to MySQL
- Product repo → Product MongoDB: stores in · Product repository persists to MongoDB
- Order service → Order event: publishes · Order creation emits a structured domain event
- Order event → Kafka: streamed on · Order events are carried on Kafka
- Notification service → Kafka: consumes · Notification service reacts to order events
- OpenAPI config → Order API: documents · OpenAPI config describes the order API
- OpenAPI config → Product API: documents · OpenAPI config describes the product API