# dragon-slayer99/microservice_ecommerce architecture

> Architecture diagram of the GitHub repository dragon-slayer99/microservice_ecommerce, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dragon-slayer99/microservice_ecommerce
- Repository: https://github.com/dragon-slayer99/microservice_ecommerce

## Overview

1. **Overall shape**
This is a Spring Boot microservices e-commerce platform with a thin React frontend and five backend support services. The backend is split into infrastructure services, business-domain services, and a gateway that is the primary ingress point.

2. **Request entry path**
All external client traffic is intended to go through the **API Gateway** on port 8080. The gateway is responsible for routing and JWT-based request filtering before traffic reaches the domain services. This makes the gateway the main boundary between untrusted client traffic and internal service-to-service calls.

3. **Infrastructure layer**
There are two core platform services:
- **Config Server** for centralized configuration.
- **Eureka Server** for service discovery and registration.
Each microservice has its own `application.yml` / `application.yaml`, and the README indicates they are meant to pull shared config from the config server and locate one another through Eureka.

4. **Identity and access boundary**
The **User Service** owns authentication and user lifecycle concerns. Its structure includes login/register/refresh DTOs, a `RefreshToken` model, JWT utilities, and a Spring Security config. That suggests it issues and refreshes tokens, persists refresh tokens, and exposes both user and admin-facing endpoints.

5. **API Gateway security**
The gateway contains a `JwtAuthFilter` and `JwtUtil`, which means it validates or inspects JWTs before forwarding requests. This creates a clear security boundary: token issuance lives in the user service, while token enforcement happens at the edge.

6. **Product domain**
The **Product Service** is the catalog subsystem. It is structurally simple: controller, service, repository, `Product` entity, and DTOs. It appears to own product persistence and product CRUD/business logic without depending on other domain services.

7. **Cart domain**
The **Cart Service** owns user-specific cart state. It has `Cart` and `CartItem` entities plus repositories, and exposes cart operations through `CartController` and `CartService`. It also uses a Feign client to call the Product Service, with a fallback implementation, so cart operations can enrich or validate items against product data.

8. **Order domain**
The **Order Service** coordinates checkout and order lifecycle. It has `Order` and `OrderItem` entities, repositories, and DTOs for placing orders and changing order status. It depends on both the Cart Service and Product Service through Feign clients, again with fallbacks, which makes order placement a cross-service orchestration flow.

9. **Service-to-service communication**
Internal communication is done with **Spring Cloud OpenFeign**. The presence of `FeignConfig` and fallback clients in cart/order/user services shows that these services are synchronous consumers of other services and are designed to degrade gracefully if a dependency is unavailable. That is an important architectural boundary for resilience.

10. **Data ownership**
Each business service owns its own persistence model and repository layer, which implies database-per-service ownership rather than a shared application database. The README calls out separate PostgreSQL databases per service, and the `db/init.sql` script supports initial provisioning. This keeps domain data isolated across services.

11. **Frontend boundary**
The `ecommerce_frontend` directory is a separate React SPA that talks to the backend through the gateway. It is not part of the Spring runtime, but it is the user-facing presentation layer and should be shown as a client tier consuming the gateway API.

12. **Delivery and runtime**
The repo is designed for containerized deployment. Each service has its own Dockerfile, the root `docker-compose.yml` orchestrates the stack, and `Jenkinsfile` defines CI/CD. So the practical deployment unit is the containerized service, not a monolith process.

13. **What to show in a diagram**
A good architecture diagram should emphasize:
- frontend → API Gateway
- API Gateway → user/product/cart/order services
- user service ↔ token management / auth boundary
- cart/order services → product service and cart/order persistence
- config server and Eureka as shared platform dependencies
- separate database per service
- fallback paths on Feign-based service calls

14. **Main architectural style**
This is a classic Spring Cloud microservice system: centralized configuration, service discovery, gateway-based ingress, JWT security, and domain-owned persistence. The important diagram boundaries are not just the services themselves, but the contracts between them: auth, catalog lookup, cart orchestration, and order orchestration.

Main entry points: [`api-gateway/src/main/java/com/techouts/api_gateway/ApiGatewayApplication.java`](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/api-gateway/src/main/java/com/techouts/api_gateway/ApiGatewayApplication.java) (API Gateway), [`docker-compose.yml`](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/docker-compose.yml) (Compose Stack), [`order-service/src/main/java/com/techouts/order_service/OrderServiceApplication.java`](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/order-service/src/main/java/com/techouts/order_service/OrderServiceApplication.java) (Order Service), [`user-service/src/main/java/com/techouts/user_service/UserServiceApplication.java`](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/user-service/src/main/java/com/techouts/user_service/UserServiceApplication.java) (User Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client tier"]
  node_frontend["Frontend<br/>React SPA"]
end

subgraph group_edge["Edge layer"]
  node_gateway{{"API Gateway<br/>Spring Cloud gateway"}}
  node_jwtfilter["JWT Filter<br/>gateway filter<br/>[JwtAuthFilter.java]"]
  node_jwtutilgw["JWT Util<br/>gateway util<br/>[JwtUtil.java]"]
end

subgraph group_platform["Platform services"]
  node_configserver[("Config Server<br/>Spring Cloud config")]
  node_eurekaserver[("Eureka Server<br/>service registry")]
end

subgraph group_identity["Identity boundary"]
  node_usersvc{{"User Service<br/>auth service"}}
  node_security["Security Config"]
  node_jwtutiluser["JWT Util<br/>auth util<br/>[JwtUtil.java]"]
  node_refresh["Refresh Token<br/>token model<br/>[RefreshToken.java]"]
  node_userproduct["Product Client<br/>Feign client<br/>[ProductClient.java]"]
end

subgraph group_commerce["Commerce services"]
  node_productsvc{{"Product Service<br/>catalog service"}}
  node_cartsvc{{"Cart Service"}}
  node_cartfeign["Product Client<br/>Feign client<br/>[ProductClient.java]"]
  node_ordersvc{{"Order Service"}}
  node_ordercart["Cart Client<br/>Feign client<br/>[CartClient.java]"]
  node_orderproduct["Product Client<br/>Feign client<br/>[ProductClient.java]"]
end

subgraph group_delivery["Delivery"]
  node_docker["Compose Stack<br/>deployment<br/>[docker-compose.yml]"]
  node_ci["Jenkinsfile<br/>ci/cd"]
end

node_frontend -->|"API calls"| node_gateway
node_gateway -->|"filters"| node_jwtfilter
node_jwtfilter -->|"validates"| node_jwtutilgw
node_gateway -->|"routes auth"| node_usersvc
node_gateway -->|"routes catalog"| node_productsvc
node_gateway -->|"routes cart"| node_cartsvc
node_gateway -->|"routes orders"| node_ordersvc
node_configserver -.->|"shared config"| node_gateway
node_configserver -.->|"shared config"| node_usersvc
node_configserver -.->|"shared config"| node_productsvc
node_configserver -.->|"shared config"| node_cartsvc
node_configserver -.->|"shared config"| node_ordersvc
node_eurekaserver -.->|"registry"| node_gateway
node_eurekaserver -.->|"registry"| node_usersvc
node_eurekaserver -.->|"registry"| node_productsvc
node_eurekaserver -.->|"registry"| node_cartsvc
node_eurekaserver -.->|"registry"| node_ordersvc
node_usersvc -->|"uses"| node_security
node_usersvc -->|"issues tokens"| node_jwtutiluser
node_usersvc -->|"persists"| node_refresh
node_cartsvc -->|"calls product"| node_cartfeign
node_cartsvc -.->|"fallback path"| node_productsvc
node_ordersvc -->|"reads cart"| node_ordercart
node_ordersvc -->|"validates items"| node_orderproduct
node_ordersvc -.->|"orchestrates"| node_cartsvc
node_ordersvc -.->|"orchestrates"| node_productsvc
node_userproduct -.->|"calls catalog"| node_productsvc
node_docker -->|"runs"| node_gateway
node_docker -->|"runs"| node_usersvc
node_docker -->|"runs"| node_productsvc
node_docker -->|"runs"| node_cartsvc
node_docker -->|"runs"| node_ordersvc
node_docker -->|"runs"| node_configserver
node_docker -->|"runs"| node_eurekaserver
node_ci -->|"builds"| node_docker

click node_frontend "https://github.com/dragon-slayer99/microservice_ecommerce/tree/master/ecommerce_frontend"
click node_gateway "https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/api-gateway/src/main/java/com/techouts/api_gateway/ApiGatewayApplication.java"
click node_jwtfilter "https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/api-gateway/src/main/java/com/techouts/api_gateway/filter/JwtAuthFilter.java"
click node_jwtutilgw "https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/api-gateway/src/main/java/com/techouts/api_gateway/utils/JwtUtil.java"
click node_configserver "https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/config-server/src/main/java/com/techouts/config_server/ConfigServerApplication.java"
click node_eurekaserver "https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/eureka-server/src/main/java/com/techouts/eureka_server/EurekaServerApplication.java"
click node_usersvc "https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/user-service/src/main/java/com/techouts/user_service/UserServiceApplication.java"
click node_security "https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/user-service/src/main/java/com/techouts/user_service/config/SecurityConfig.java"
click node_jwtutiluser "https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/user-service/src/main/java/com/techouts/user_service/utils/JwtUtil.java"
click node_refresh "https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/user-service/src/main/java/com/techouts/user_service/model/RefreshToken.java"
click node_productsvc "https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/product-service/src/main/java/com/techouts/product_service/ProductServiceApplication.java"
click node_cartsvc "https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/cart-service/src/main/java/com/techouts/cart_service/CartServiceApplication.java"
click node_cartfeign "https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/cart-service/src/main/java/com/techouts/cart_service/feignclient/ProductClient.java"
click node_ordersvc "https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/order-service/src/main/java/com/techouts/order_service/OrderServiceApplication.java"
click node_ordercart "https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/order-service/src/main/java/com/techouts/order_service/feignclient/CartClient.java"
click node_orderproduct "https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/order-service/src/main/java/com/techouts/order_service/feignclient/ProductClient.java"
click node_userproduct "https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/user-service/src/main/java/com/techouts/user_service/feignclient/ProductClient.java"
click node_docker "https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/docker-compose.yml"
click node_ci "https://github.com/dragon-slayer99/microservice_ecommerce/tree/master/Jenkinsfile"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend toneBlue
class node_gateway,node_jwtfilter,node_jwtutilgw toneAmber
class node_configserver,node_eurekaserver toneMint
class node_usersvc,node_security,node_jwtutiluser,node_refresh,node_userproduct toneRose
class node_productsvc,node_cartsvc,node_cartfeign,node_ordersvc,node_ordercart,node_orderproduct toneIndigo
class node_docker,node_ci toneTeal
```

## Components

### Client tier

User-facing frontend and external traffic entry

- [Frontend](https://github.com/dragon-slayer99/microservice_ecommerce/tree/master/ecommerce_frontend): React SPA · Thin browser client that talks to backend APIs through the gateway · `ecommerce_frontend`

### Edge layer

Gateway and request filtering boundary

- [API Gateway](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/api-gateway/src/main/java/com/techouts/api_gateway/ApiGatewayApplication.java): Spring Cloud gateway · Primary ingress that routes requests and enforces JWT checks · `api-gateway/src/main/java/com/techouts/api_gateway/ApiGatewayApplication.java`
- [JWT Filter](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/api-gateway/src/main/java/com/techouts/api_gateway/filter/JwtAuthFilter.java): gateway filter · Edge filter that validates or inspects bearer tokens before routing · `api-gateway/src/main/java/com/techouts/api_gateway/filter/JwtAuthFilter.java`
- [JWT Util](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/api-gateway/src/main/java/com/techouts/api_gateway/utils/JwtUtil.java): gateway util · Gateway-side token utility used by the request filter · `api-gateway/src/main/java/com/techouts/api_gateway/utils/JwtUtil.java`

### Platform services

Shared discovery and configuration infrastructure

- [Config Server](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/config-server/src/main/java/com/techouts/config_server/ConfigServerApplication.java): Spring Cloud config · Centralized external configuration source for the services · `config-server/src/main/java/com/techouts/config_server/ConfigServerApplication.java`
- [Eureka Server](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/eureka-server/src/main/java/com/techouts/eureka_server/EurekaServerApplication.java): service registry · Discovery registry for locating services at runtime · `eureka-server/src/main/java/com/techouts/eureka_server/EurekaServerApplication.java`

### Identity boundary

Authentication, authorization, and token lifecycle

- [User Service](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/user-service/src/main/java/com/techouts/user_service/UserServiceApplication.java): auth service · Owns login, registration, refresh tokens, and user/admin endpoints · `user-service/src/main/java/com/techouts/user_service/UserServiceApplication.java`
- [Security Config](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/user-service/src/main/java/com/techouts/user_service/config/SecurityConfig.java): security config · Spring Security setup for authentication and protected endpoints · `user-service/src/main/java/com/techouts/user_service/config/SecurityConfig.java`
- [JWT Util](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/user-service/src/main/java/com/techouts/user_service/utils/JwtUtil.java): auth util · User-service token generation and refresh support · `user-service/src/main/java/com/techouts/user_service/utils/JwtUtil.java`
- [Refresh Token](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/user-service/src/main/java/com/techouts/user_service/model/RefreshToken.java): token model · Persistent refresh-token entity backing token renewal · `user-service/src/main/java/com/techouts/user_service/model/RefreshToken.java`
- [Product Client](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/user-service/src/main/java/com/techouts/user_service/feignclient/ProductClient.java): Feign client · User-side client for product-related admin or supporting calls · `user-service/src/main/java/com/techouts/user_service/feignclient/ProductClient.java`

### Commerce services

Catalog, cart, and order domain services

- [Product Service](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/product-service/src/main/java/com/techouts/product_service/ProductServiceApplication.java): catalog service · Catalog persistence and product CRUD/business logic · `product-service/src/main/java/com/techouts/product_service/ProductServiceApplication.java`
- [Cart Service](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/cart-service/src/main/java/com/techouts/cart_service/CartServiceApplication.java): cart service · Manages per-user cart state and item operations · `cart-service/src/main/java/com/techouts/cart_service/CartServiceApplication.java`
- [Product Client](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/cart-service/src/main/java/com/techouts/cart_service/feignclient/ProductClient.java): Feign client · Cart-side synchronous client to look up product data · `cart-service/src/main/java/com/techouts/cart_service/feignclient/ProductClient.java`
- [Order Service](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/order-service/src/main/java/com/techouts/order_service/OrderServiceApplication.java): order service · Coordinates checkout, order creation, and status changes · `order-service/src/main/java/com/techouts/order_service/OrderServiceApplication.java`
- [Cart Client](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/order-service/src/main/java/com/techouts/order_service/feignclient/CartClient.java): Feign client · Order-side client used to read cart contents during checkout · `order-service/src/main/java/com/techouts/order_service/feignclient/CartClient.java`
- [Product Client](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/order-service/src/main/java/com/techouts/order_service/feignclient/ProductClient.java): Feign client · Order-side client used to validate or enrich order items · `order-service/src/main/java/com/techouts/order_service/feignclient/ProductClient.java`

### Delivery

Containerized deployment and CI/CD

- [Compose Stack](https://github.com/dragon-slayer99/microservice_ecommerce/blob/master/docker-compose.yml): deployment · Container orchestration for the full microservice stack · `docker-compose.yml`
- [Jenkinsfile](https://github.com/dragon-slayer99/microservice_ecommerce/tree/master/Jenkinsfile): ci/cd · Pipeline definition for building and delivering the system · `Jenkinsfile`

## Connections

- Frontend → API Gateway: API calls · Browser traffic is intended to flow through the gateway
- API Gateway → JWT Filter: filters · Gateway applies JWT-based request filtering before routing
- JWT Filter → JWT Util: validates · Filter relies on token utility for JWT parsing and checks
- API Gateway → User Service: routes auth · Login and registration traffic is routed to the user service
- API Gateway → Product Service: routes catalog · Gateway forwards catalog requests to the product service
- API Gateway → Cart Service: routes cart · Gateway forwards cart requests to the cart service
- API Gateway → Order Service: routes orders · Gateway forwards order and checkout requests to the order service
- Config Server → API Gateway: shared config · Gateway is expected to consume centralized configuration
- Config Server → User Service: shared config · User service consumes centralized configuration
- Config Server → Product Service: shared config · Product service consumes centralized configuration
- Config Server → Cart Service: shared config · Cart service consumes centralized configuration
- Config Server → Order Service: shared config · Order service consumes centralized configuration
- Eureka Server → API Gateway: registry · Gateway participates in service discovery
- Eureka Server → User Service: registry · User service registers for discovery
- Eureka Server → Product Service: registry · Product service registers for discovery
- Eureka Server → Cart Service: registry · Cart service registers for discovery
- Eureka Server → Order Service: registry · Order service registers for discovery
- User Service → Security Config: uses · Security config governs authentication and endpoint access
- User Service → JWT Util: issues tokens · User service uses JWT utilities to generate and refresh tokens
- User Service → Refresh Token: persists · Refresh tokens are stored as part of auth lifecycle
- Cart Service → Product Client: calls product · Cart service enriches or validates items through product lookups
- Cart Service → Product Service: fallback path · Cart operations depend on product data and degrade through fallback clients
- Order Service → Cart Client: reads cart · Order placement pulls cart contents through Feign
- Order Service → Product Client: validates items · Order placement consults product data through Feign
- Order Service → Cart Service: orchestrates · Order service depends on cart state during checkout
- Order Service → Product Service: orchestrates · Order service depends on catalog data during checkout
- Product Client → Product Service: calls catalog · User service has a supporting Feign integration to product data
- Compose Stack → API Gateway: runs · Compose stack includes the gateway container
- Compose Stack → User Service: runs · Compose stack includes the user service container
- Compose Stack → Product Service: runs · Compose stack includes the product service container
- Compose Stack → Cart Service: runs · Compose stack includes the cart service container
- Compose Stack → Order Service: runs · Compose stack includes the order service container
- Compose Stack → Config Server: runs · Compose stack includes the config server container
- Compose Stack → Eureka Server: runs · Compose stack includes the discovery server container
- Jenkinsfile → Compose Stack: builds · CI/CD pipeline supports containerized delivery of the stack
