# anpk1011/shopnow architecture

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

- Interactive diagram: https://gitdiagram.com/anpk1011/shopnow
- Repository: https://github.com/anpk1011/shopnow

## Overview

#### Purpose and Scope
The repository tree is a Shopnow e-commerce system: a React frontend backed by Spring Boot microservices for users, products, and shopping carts. The supplied README describes an unrelated DerScanner DAST deployment bundle; it does not correspond to the checked-in Shopnow paths, so architecture should be derived from the tree.

#### Entry Points and Deployment
Each backend service is independently buildable/runnable Spring Boot application, containerized with its own Dockerfile. The frontend is a separate Node/React application.
- `shopnow-backend/docker-compose.yaml`
- `shopnow-backend/api-gateway/src/main/java/com/techcareer/apigateway/ApiGatewayApplication.java`
- `shopnow-frontend/src/index.js`

#### Edge Gateway and Security Boundary
The API gateway is the intended external backend entry point. Its security configuration forms the cross-service request boundary before traffic reaches domain services. Configuration is centrally supplied rather than duplicated in each service.
- `shopnow-backend/api-gateway/src/main/java/com/techcareer/apigateway/config/SecurityConfig.java`
- `shopnow-backend/api-gateway/src/main/resources/application.properties`
- `shopnow-backend/config-server/src/main/resources/config/api-gateway.yaml`

#### Service Discovery and Central Configuration
A dedicated discovery server supports service registration/location, while the config server publishes service-specific runtime configuration. This separates deployment topology and environment values from application code.
- `shopnow-backend/discovery-server/src/main/java/com/techcareer/discoveryserver/DiscoveryServerApplication.java`
- `shopnow-backend/config-server/src/main/java/com/techcareer/configserver/ConfigServerApplication.java`
- `shopnow-backend/config-server/src/main/resources/config/product-service.yaml`

#### Product Domain
Product service owns product-facing HTTP endpoints, product entities, persistence access, and business operations. Its controller → service → repository layering is the canonical backend request/data flow.
- `shopnow-backend/product-service/src/main/java/com/techcareer/productservice/controller/ProductController.java`
- `shopnow-backend/product-service/src/main/java/com/techcareer/productservice/service/ProductService.java`
- `shopnow-backend/product-service/src/main/java/com/techcareer/productservice/repository/ProductRepository.java`

#### User and Cart Domains
User service handles account/authentication-oriented requests and profile updates; cart service manages cart operations and its product/cart persistence model. Both expose domain boundaries through controllers and encapsulate persistence behind repositories.
- `shopnow-backend/user-service/src/main/java/com/techcareer/userservice/controller/UserController.java`
- `shopnow-backend/user-service/src/main/java/com/techcareer/userservice/service/UserService.java`
- `shopnow-backend/shopping-cart-service/src/main/java/com/techcareer/shoppingcartservice/controller/ShoppingCartController.java`
- `shopnow-backend/shopping-cart-service/src/main/java/com/techcareer/shoppingcartservice/service/ShoppingCartService.java`

#### Frontend Flow and External Services
The React SPA enters through `index.js` and composes routes/views in `App.js`. Redux actions/reducers maintain client state; service modules isolate HTTP calls for authentication, products, carts, and profiles. Keycloak realm export indicates Keycloak is the identity-provider integration; backend services also expose OpenAPI configuration. Docker Compose and per-service Dockerfiles are the material local/container runtime infrastructure.
- `shopnow-frontend/src/App.js`
- `shopnow-frontend/src/store.js`
- `shopnow-frontend/src/services/AuthService.js`
- `shopnow-backend/keycloak-realms/realm-export.json`

Main entry points: [`shopnow-backend/api-gateway/src/main/java/com/techcareer/apigateway/ApiGatewayApplication.java`](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/api-gateway/src/main/java/com/techcareer/apigateway/ApiGatewayApplication.java) (API gateway), [`shopnow-backend/discovery-server/src/main/java/com/techcareer/discoveryserver/DiscoveryServerApplication.java`](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/discovery-server/src/main/java/com/techcareer/discoveryserver/DiscoveryServerApplication.java) (Discovery server), [`shopnow-frontend/src/App.js`](https://github.com/anpk1011/shopnow/blob/main/shopnow-frontend/src/App.js) (Routes and views), [`shopnow-backend/api-gateway/src/main/java/com/techcareer/apigateway/config/SecurityConfig.java`](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/api-gateway/src/main/java/com/techcareer/apigateway/config/SecurityConfig.java) (Gateway security)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React frontend"]
  node_spa_entry["SPA entry<br/>React bootstrap<br/>[index.js]"]
  node_spa_app["Routes and views<br/>React app<br/>[App.js]"]
  node_client_store["Client state<br/>Redux store<br/>[store.js]"]
  node_auth_client["Auth API client<br/>HTTP service<br/>[AuthService.js]"]
end

subgraph group_platform["Platform services"]
  node_compose["Docker Compose<br/>container runtime"]
  node_keycloak{{"Keycloak identity provider<br/>identity service<br/>[realm-export.json]"}}
  node_gateway{{"API gateway<br/>Spring Boot gateway"}}
  node_gateway_security["Gateway security<br/>security configuration"]
  node_gateway_config["Gateway runtime config<br/>central configuration<br/>[api-gateway.yaml]"]
  node_config_server["Config server<br/>Spring Boot config service"]
  node_discovery["Discovery server<br/>service registry"]
  node_product_config["Product runtime config<br/>central configuration"]
end

subgraph group_domains["Domain services"]
  node_product_controller["Product API<br/>REST controller"]
  node_product_service["Product operations<br/>service layer"]
  node_product_repository[("Product persistence")]
  node_user_service["User service<br/>account domain service<br/>[UserService.java]"]
  node_user_controller["User API<br/>REST controller"]
  node_cart_controller["Cart API<br/>REST controller"]
  node_cart_service["Cart operations<br/>service layer"]
end

node_spa_entry -->|"boots"| node_spa_app
node_spa_app -->|"uses state"| node_client_store
node_spa_app -->|"auth requests"| node_auth_client
node_auth_client -->|"identity flow"| node_keycloak
node_spa_app -->|"backend API requests"| node_gateway
node_gateway -->|"enforces"| node_gateway_security
node_gateway_security -->|"authorized product traffic"| node_product_controller
node_gateway_security -->|"authorized user traffic"| node_user_controller
node_gateway_security -->|"authorized cart traffic"| node_cart_controller
node_product_controller -->|"delegates"| node_product_service
node_product_service -->|"persists products"| node_product_repository
node_user_controller -->|"delegates"| node_user_service
node_cart_controller -->|"delegates"| node_cart_service
node_config_server -->|"publishes"| node_gateway_config
node_config_server -->|"publishes"| node_product_config
node_gateway_config -.->|"configures"| node_gateway
node_product_config -.->|"configures"| node_product_service
node_gateway -.->|"registers and locates"| node_discovery
node_product_service -.->|"registers"| node_discovery
node_user_service -.->|"registers"| node_discovery
node_cart_service -.->|"registers"| node_discovery
node_compose -.->|"runs"| node_gateway
node_compose -.->|"runs"| node_config_server
node_compose -.->|"runs"| node_discovery

click node_compose "https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/docker-compose.yaml"
click node_spa_entry "https://github.com/anpk1011/shopnow/blob/main/shopnow-frontend/src/index.js"
click node_spa_app "https://github.com/anpk1011/shopnow/blob/main/shopnow-frontend/src/App.js"
click node_client_store "https://github.com/anpk1011/shopnow/blob/main/shopnow-frontend/src/store.js"
click node_auth_client "https://github.com/anpk1011/shopnow/blob/main/shopnow-frontend/src/services/AuthService.js"
click node_keycloak "https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/keycloak-realms/realm-export.json"
click node_gateway "https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/api-gateway/src/main/java/com/techcareer/apigateway/ApiGatewayApplication.java"
click node_gateway_security "https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/api-gateway/src/main/java/com/techcareer/apigateway/config/SecurityConfig.java"
click node_gateway_config "https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/config-server/src/main/resources/config/api-gateway.yaml"
click node_config_server "https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/config-server/src/main/java/com/techcareer/configserver/ConfigServerApplication.java"
click node_discovery "https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/discovery-server/src/main/java/com/techcareer/discoveryserver/DiscoveryServerApplication.java"
click node_product_config "https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/config-server/src/main/resources/config/product-service.yaml"
click node_product_controller "https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/product-service/src/main/java/com/techcareer/productservice/controller/ProductController.java"
click node_product_service "https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/product-service/src/main/java/com/techcareer/productservice/service/ProductService.java"
click node_product_repository "https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/product-service/src/main/java/com/techcareer/productservice/repository/ProductRepository.java"
click node_user_service "https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/user-service/src/main/java/com/techcareer/userservice/service/UserService.java"
click node_user_controller "https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/user-service/src/main/java/com/techcareer/userservice/controller/UserController.java"
click node_cart_controller "https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/shopping-cart-service/src/main/java/com/techcareer/shoppingcartservice/controller/ShoppingCartController.java"
click node_cart_service "https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/shopping-cart-service/src/main/java/com/techcareer/shoppingcartservice/service/ShoppingCartService.java"

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_spa_entry,node_spa_app,node_client_store,node_auth_client toneBlue
class node_compose,node_keycloak,node_gateway,node_gateway_security,node_gateway_config,node_config_server,node_discovery,node_product_config toneAmber
class node_product_controller,node_product_service,node_product_repository,node_user_service,node_user_controller,node_cart_controller,node_cart_service toneMint
```

## Components

### React frontend

- [SPA entry](https://github.com/anpk1011/shopnow/blob/main/shopnow-frontend/src/index.js): React bootstrap · `shopnow-frontend/src/index.js`
- [Routes and views](https://github.com/anpk1011/shopnow/blob/main/shopnow-frontend/src/App.js): React app · `shopnow-frontend/src/App.js`
- [Client state](https://github.com/anpk1011/shopnow/blob/main/shopnow-frontend/src/store.js): Redux store · `shopnow-frontend/src/store.js`
- [Auth API client](https://github.com/anpk1011/shopnow/blob/main/shopnow-frontend/src/services/AuthService.js): HTTP service · `shopnow-frontend/src/services/AuthService.js`

### Platform services

- [Docker Compose](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/docker-compose.yaml): container runtime · Coordinates the local backend service runtime. · `shopnow-backend/docker-compose.yaml`
- [Keycloak identity provider](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/keycloak-realms/realm-export.json): identity service · Realm export defines the identity integration. · `shopnow-backend/keycloak-realms/realm-export.json`
- [API gateway](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/api-gateway/src/main/java/com/techcareer/apigateway/ApiGatewayApplication.java): Spring Boot gateway · External backend entry point. · `shopnow-backend/api-gateway/src/main/java/com/techcareer/apigateway/ApiGatewayApplication.java`
- [Gateway security](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/api-gateway/src/main/java/com/techcareer/apigateway/config/SecurityConfig.java): security configuration · Applies the cross-service request boundary. · `shopnow-backend/api-gateway/src/main/java/com/techcareer/apigateway/config/SecurityConfig.java`
- [Gateway runtime config](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/config-server/src/main/resources/config/api-gateway.yaml): central configuration · `shopnow-backend/config-server/src/main/resources/config/api-gateway.yaml`
- [Config server](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/config-server/src/main/java/com/techcareer/configserver/ConfigServerApplication.java): Spring Boot config service · Publishes service-specific runtime configuration. · `shopnow-backend/config-server/src/main/java/com/techcareer/configserver/ConfigServerApplication.java`
- [Discovery server](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/discovery-server/src/main/java/com/techcareer/discoveryserver/DiscoveryServerApplication.java): service registry · Supports service registration and lookup. · `shopnow-backend/discovery-server/src/main/java/com/techcareer/discoveryserver/DiscoveryServerApplication.java`
- [Product runtime config](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/config-server/src/main/resources/config/product-service.yaml): central configuration · `shopnow-backend/config-server/src/main/resources/config/product-service.yaml`

### Domain services

- [Product API](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/product-service/src/main/java/com/techcareer/productservice/controller/ProductController.java): REST controller · `shopnow-backend/product-service/src/main/java/com/techcareer/productservice/controller/ProductController.java`
- [Product operations](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/product-service/src/main/java/com/techcareer/productservice/service/ProductService.java): service layer · `shopnow-backend/product-service/src/main/java/com/techcareer/productservice/service/ProductService.java`
- [Product persistence](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/product-service/src/main/java/com/techcareer/productservice/repository/ProductRepository.java): repository · `shopnow-backend/product-service/src/main/java/com/techcareer/productservice/repository/ProductRepository.java`
- [User service](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/user-service/src/main/java/com/techcareer/userservice/service/UserService.java): account domain service · Handles authentication-oriented requests and profile updates. · `shopnow-backend/user-service/src/main/java/com/techcareer/userservice/service/UserService.java`
- [User API](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/user-service/src/main/java/com/techcareer/userservice/controller/UserController.java): REST controller · `shopnow-backend/user-service/src/main/java/com/techcareer/userservice/controller/UserController.java`
- [Cart API](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/shopping-cart-service/src/main/java/com/techcareer/shoppingcartservice/controller/ShoppingCartController.java): REST controller · `shopnow-backend/shopping-cart-service/src/main/java/com/techcareer/shoppingcartservice/controller/ShoppingCartController.java`
- [Cart operations](https://github.com/anpk1011/shopnow/blob/main/shopnow-backend/shopping-cart-service/src/main/java/com/techcareer/shoppingcartservice/service/ShoppingCartService.java): service layer · Manages cart operations and cart/product persistence. · `shopnow-backend/shopping-cart-service/src/main/java/com/techcareer/shoppingcartservice/service/ShoppingCartService.java`

## Connections

- SPA entry → Routes and views: boots
- Routes and views → Client state: uses state
- Routes and views → Auth API client: auth requests
- Auth API client → Keycloak identity provider: identity flow
- Routes and views → API gateway: backend API requests
- API gateway → Gateway security: enforces
- Gateway security → Product API: authorized product traffic
- Gateway security → User API: authorized user traffic
- Gateway security → Cart API: authorized cart traffic
- Product API → Product operations: delegates
- Product operations → Product persistence: persists products
- User API → User service: delegates
- Cart API → Cart operations: delegates
- Config server → Gateway runtime config: publishes
- Config server → Product runtime config: publishes
- Gateway runtime config → API gateway: configures
- Product runtime config → Product operations: configures
- API gateway → Discovery server: registers and locates
- Product operations → Discovery server: registers
- User service → Discovery server: registers
- Cart operations → Discovery server: registers
- Docker Compose → API gateway: runs
- Docker Compose → Config server: runs
- Docker Compose → Discovery server: runs
