# whyeric92-eng/flash-sale-inventory architecture

> Architecture diagram of the GitHub repository whyeric92-eng/flash-sale-inventory, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/whyeric92-eng/flash-sale-inventory
- Repository: https://github.com/whyeric92-eng/flash-sale-inventory

## Overview

Flash Sale Inventory is a Spring Boot API for product and stock administration, order creation, and JWT-based authentication. The principal order path is a client request through the order controller and service, which decrements stock, looks up the product, and persists a pending order. Product and inventory management and registration/login are separate API branches. PostgreSQL is documented as the business-data source of truth; Redis cache, atomic stock control, and an async order queue are documented capabilities, but the README marks the system in progress and their implementation is not shown in the sampled source.

Main entry points: [`src/main/java/com/flashsale/inventory/service/OrderService.java`](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/service/OrderService.java) (Order service), [`src/main/java/com/flashsale/inventory/service/ProductService.java`](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/service/ProductService.java) (Product service), [`src/main/java/com/flashsale/inventory/service/InventoryService.java`](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/service/InventoryService.java) (Inventory service), [`src/main/java/com/flashsale/inventory/service/AuthService.java`](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/service/AuthService.java) (Auth service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API endpoints"]
  node_product_api["Product API"]
  node_inventory_api["Inventory API"]
  node_order_api["Order API"]
  node_auth_api["Auth API"]
  node_request_dtos["Request DTOs"]
end

subgraph group_domain["Business services"]
  node_product_service["Product service"]
  node_inventory_service["Inventory service"]
  node_order_service["Order service<br/>[OrderService.java]"]
end

subgraph group_security["Authentication"]
  node_auth_service["Auth service<br/>[AuthService.java]"]
  node_jwt_service["JWT service<br/>[JwtService.java]"]
  node_jwt_filter["JWT filter"]
  node_security_config["Security config"]
end

subgraph group_data["Persistence and integrations"]
  node_domain_models["Domain models"]
  node_product_repo["Product repository"]
  node_inventory_repo["Inventory repository"]
  node_order_repo["Order repository"]
  node_user_repo["User repository"]
  node_postgres[("PostgreSQL")]
  node_redis[("Redis")]
  node_order_queue["Async order queue"]
end

node_client(("API client"))

node_client -->|"manages products"| node_product_api
node_client -->|"manages stock"| node_inventory_api
node_client -->|"places orders"| node_order_api
node_client -->|"registers or logs in"| node_auth_api
node_product_api -->|"delegates"| node_product_service
node_inventory_api -->|"delegates"| node_inventory_service
node_order_api -->|"delegates"| node_order_service
node_auth_api -->|"delegates"| node_auth_service
node_product_service -->|"reads and writes"| node_product_repo
node_inventory_service -->|"reads and writes"| node_inventory_repo
node_order_service -->|"decreases stock"| node_inventory_service
node_order_service -->|"looks up product"| node_product_service
node_order_service -->|"saves order"| node_order_repo
node_auth_service -->|"checks and saves user"| node_user_repo
node_auth_service -->|"issues token"| node_jwt_service
node_security_config -->|"configures"| node_jwt_filter
node_jwt_filter -->|"validates token"| node_jwt_service
node_product_repo -.->|"persists product data"| node_postgres
node_inventory_repo -.->|"persists stock data"| node_postgres
node_order_repo -.->|"persists order data"| node_postgres
node_user_repo -.->|"persists user data"| node_postgres
node_redis -.->|"planned stock control"| node_inventory_service
node_redis -.->|"planned product cache"| node_product_service
node_order_service -.->|"planned async enqueue"| node_order_queue

click node_product_api "https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/controller/ProductController.java"
click node_inventory_api "https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/controller/InventoryController.java"
click node_order_api "https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/controller/OrderController.java"
click node_auth_api "https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/controller/AuthController.java"
click node_product_service "https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/service/ProductService.java"
click node_inventory_service "https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/service/InventoryService.java"
click node_order_service "https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/service/OrderService.java"
click node_auth_service "https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/service/AuthService.java"
click node_jwt_service "https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/security/JwtService.java"
click node_jwt_filter "https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/security/JwtAuthenticationFilter.java"
click node_security_config "https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/config/SecurityConfig.java"
click node_domain_models "https://github.com/whyeric92-eng/flash-sale-inventory/tree/main/src/main/java/com/flashsale/inventory/entity"
click node_request_dtos "https://github.com/whyeric92-eng/flash-sale-inventory/tree/main/src/main/java/com/flashsale/inventory/dto"
click node_product_repo "https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/repository/ProductRepository.java"
click node_inventory_repo "https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/repository/InventoryRepository.java"
click node_order_repo "https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/repository/OrderRepository.java"
click node_user_repo "https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/repository/UserRepository.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_product_api,node_inventory_api,node_order_api,node_auth_api,node_request_dtos,node_client toneBlue
class node_product_service,node_inventory_service,node_order_service toneAmber
class node_auth_service,node_jwt_service,node_jwt_filter,node_security_config toneMint
class node_domain_models,node_product_repo,node_inventory_repo,node_order_repo,node_user_repo,node_postgres,node_redis,node_order_queue toneRose
```

## Components

### API endpoints

- [Product API](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/controller/ProductController.java): `src/main/java/com/flashsale/inventory/controller/ProductController.java`
- [Inventory API](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/controller/InventoryController.java): `src/main/java/com/flashsale/inventory/controller/InventoryController.java`
- [Order API](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/controller/OrderController.java): `src/main/java/com/flashsale/inventory/controller/OrderController.java`
- [Auth API](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/controller/AuthController.java): `src/main/java/com/flashsale/inventory/controller/AuthController.java`
- [Request DTOs](https://github.com/whyeric92-eng/flash-sale-inventory/tree/main/src/main/java/com/flashsale/inventory/dto): `src/main/java/com/flashsale/inventory/dto`

### Business services

- [Product service](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/service/ProductService.java): `src/main/java/com/flashsale/inventory/service/ProductService.java`
- [Inventory service](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/service/InventoryService.java): `src/main/java/com/flashsale/inventory/service/InventoryService.java`
- [Order service](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/service/OrderService.java): `src/main/java/com/flashsale/inventory/service/OrderService.java`

### Authentication

- [Auth service](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/service/AuthService.java): `src/main/java/com/flashsale/inventory/service/AuthService.java`
- [JWT service](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/security/JwtService.java): `src/main/java/com/flashsale/inventory/security/JwtService.java`
- [JWT filter](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/security/JwtAuthenticationFilter.java): `src/main/java/com/flashsale/inventory/security/JwtAuthenticationFilter.java`
- [Security config](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/config/SecurityConfig.java): `src/main/java/com/flashsale/inventory/config/SecurityConfig.java`

### Persistence and integrations

- [Domain models](https://github.com/whyeric92-eng/flash-sale-inventory/tree/main/src/main/java/com/flashsale/inventory/entity): `src/main/java/com/flashsale/inventory/entity`
- [Product repository](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/repository/ProductRepository.java): `src/main/java/com/flashsale/inventory/repository/ProductRepository.java`
- [Inventory repository](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/repository/InventoryRepository.java): `src/main/java/com/flashsale/inventory/repository/InventoryRepository.java`
- [Order repository](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/repository/OrderRepository.java): `src/main/java/com/flashsale/inventory/repository/OrderRepository.java`
- [User repository](https://github.com/whyeric92-eng/flash-sale-inventory/blob/main/src/main/java/com/flashsale/inventory/repository/UserRepository.java): `src/main/java/com/flashsale/inventory/repository/UserRepository.java`
- **PostgreSQL**
- **Redis**
- **Async order queue**

### Other components

- **API client**

## Connections

- API client → Product API: manages products (evidence: `src/main/java/com/flashsale/inventory/controller/ProductController.java`)
- API client → Inventory API: manages stock (evidence: `src/main/java/com/flashsale/inventory/controller/InventoryController.java`)
- API client → Order API: places orders (evidence: `src/main/java/com/flashsale/inventory/controller/OrderController.java`)
- API client → Auth API: registers or logs in (evidence: `src/main/java/com/flashsale/inventory/controller/AuthController.java`)
- Product API → Product service: delegates (evidence: `src/main/java/com/flashsale/inventory/controller/ProductController.java`)
- Inventory API → Inventory service: delegates (evidence: `src/main/java/com/flashsale/inventory/controller/InventoryController.java`)
- Order API → Order service: delegates (evidence: `src/main/java/com/flashsale/inventory/controller/OrderController.java`)
- Auth API → Auth service: delegates (evidence: `src/main/java/com/flashsale/inventory/controller/AuthController.java`)
- Product service → Product repository: reads and writes (evidence: `src/main/java/com/flashsale/inventory/service/ProductService.java`)
- Inventory service → Inventory repository: reads and writes (evidence: `src/main/java/com/flashsale/inventory/service/InventoryService.java`)
- Order service → Inventory service: decreases stock (evidence: `src/main/java/com/flashsale/inventory/service/OrderService.java`)
- Order service → Product service: looks up product (evidence: `src/main/java/com/flashsale/inventory/service/OrderService.java`)
- Order service → Order repository: saves order (evidence: `src/main/java/com/flashsale/inventory/service/OrderService.java`)
- Auth service → User repository: checks and saves user (evidence: `src/main/java/com/flashsale/inventory/service/AuthService.java`)
- Auth service → JWT service: issues token (evidence: `src/main/java/com/flashsale/inventory/service/AuthService.java`)
- Security config → JWT filter: configures (evidence: `src/main/java/com/flashsale/inventory/config/SecurityConfig.java`)
- JWT filter → JWT service: validates token (evidence: `src/main/java/com/flashsale/inventory/security/JwtAuthenticationFilter.java`)
- Product repository → PostgreSQL: persists product data (evidence: `README.md`)
- Inventory repository → PostgreSQL: persists stock data (evidence: `README.md`)
- Order repository → PostgreSQL: persists order data (evidence: `README.md`)
- User repository → PostgreSQL: persists user data (evidence: `README.md`)
- Redis → Inventory service: planned stock control (evidence: `README.md`)
- Redis → Product service: planned product cache (evidence: `README.md`)
- Order service → Async order queue: planned async enqueue (evidence: `README.md`)
