# shivanisingh2k/orderflow architecture

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

- Interactive diagram: https://gitdiagram.com/shivanisingh2k/orderflow
- Repository: https://github.com/shivanisingh2k/orderflow

## Overview

OrderFlow is a Spring REST API for product and user management, authentication, and inventory-backed order creation. Clients call the controllers; services perform business operations and use JPA repositories to persist entities. Order creation validates the user and products, totals prices, reduces stock, and runs transactionally. Login verifies a password and issues a JWT; the security filter and configuration enforce authenticated and role-restricted access. The README also documents pagination and OpenAPI. Some subsystem links rely on the source index or README because not all source was excerpted.

Main entry points: [`src/main/java/com/orderflow/orderflow/repository`](https://github.com/shivanisingh2k/orderflow/tree/main/src/main/java/com/orderflow/orderflow/repository) (JPA repositories), [`src/main/java/com/orderflow/orderflow/controller/AuthController.java`](https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/controller/AuthController.java) (Authentication API), [`src/main/java/com/orderflow/orderflow/service/UserService.java`](https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/service/UserService.java) (User service), [`src/main/java/com/orderflow/orderflow`](https://github.com/shivanisingh2k/orderflow/tree/main/src/main/java/com/orderflow/orderflow) (Domain entities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["REST API"]
  node_auth_api["Authentication API"]
  node_product_api["Product API"]
  node_user_api["User API"]
  node_order_api["Order API"]
  node_openapi["OpenAPI setup<br/>[OpenApiConfig.java]"]
  node_dto["Request responses"]
  node_exceptions["API error handling"]
end

subgraph group_domain["Business Domain"]
  node_product_service["Product service"]
  node_user_service["User service<br/>[UserService.java]"]
  node_order_service["Order service<br/>[OrderService.java]"]
  node_entities["Domain entities"]
end

subgraph group_persistence["Persistence"]
  node_repositories["JPA repositories"]
  node_database[("PostgreSQL")]
end

subgraph group_security["Security"]
  node_security_config["Security configuration"]
  node_jwt_filter["JWT filter"]
  node_jwt_service["JWT service<br/>[JwtService.java]"]
  node_password_encoder["BCrypt encoder"]
end

node_client(("API client"))

node_client -->|"logs in"| node_auth_api
node_client -->|"manages products"| node_product_api
node_client -->|"manages users"| node_user_api
node_client -->|"creates order"| node_order_api
node_product_api -->|"delegates to"| node_product_service
node_user_api -->|"delegates to"| node_user_service
node_order_api -->|"delegates to"| node_order_service
node_auth_api -->|"looks up user"| node_repositories
node_auth_api -->|"issues token"| node_jwt_service
node_auth_api -->|"checks password"| node_password_encoder
node_user_service -->|"hashes password"| node_password_encoder
node_product_service -->|"reads and writes"| node_repositories
node_user_service -->|"reads and writes"| node_repositories
node_order_service -->|"loads and saves"| node_repositories
node_order_service -->|"builds order"| node_entities
node_product_service -->|"maps products"| node_entities
node_user_service -->|"maps users"| node_entities
node_repositories -.->|"persists entities"| node_database
node_security_config -->|"registers filter"| node_jwt_filter
node_jwt_filter -->|"validates token"| node_jwt_service
node_entities -.->|"raises domain errors"| node_exceptions

click node_auth_api "https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/controller/AuthController.java"
click node_product_api "https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/controller/ProductController.java"
click node_user_api "https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/controller/UserController.java"
click node_order_api "https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/controller/OrderController.java"
click node_openapi "https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/config/OpenApiConfig.java"
click node_product_service "https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/service/ProductService.java"
click node_user_service "https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/service/UserService.java"
click node_order_service "https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/service/OrderService.java"
click node_entities "https://github.com/shivanisingh2k/orderflow/tree/main/src/main/java/com/orderflow/orderflow"
click node_dto "https://github.com/shivanisingh2k/orderflow/tree/main/src/main/java/com/orderflow/orderflow/dto"
click node_exceptions "https://github.com/shivanisingh2k/orderflow/tree/main/src/main/java/com/orderflow/orderflow/exception"
click node_repositories "https://github.com/shivanisingh2k/orderflow/tree/main/src/main/java/com/orderflow/orderflow/repository"
click node_security_config "https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/config/SecurityConfig.java"
click node_jwt_filter "https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/security/JwtAuthenticationFilter.java"
click node_jwt_service "https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/security/JwtService.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_auth_api,node_product_api,node_user_api,node_order_api,node_openapi,node_dto,node_exceptions,node_client toneBlue
class node_product_service,node_user_service,node_order_service,node_entities toneAmber
class node_repositories,node_database toneMint
class node_security_config,node_jwt_filter,node_jwt_service,node_password_encoder toneRose
```

## Components

### REST API

- [Authentication API](https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/controller/AuthController.java): `src/main/java/com/orderflow/orderflow/controller/AuthController.java`
- [Product API](https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/controller/ProductController.java): `src/main/java/com/orderflow/orderflow/controller/ProductController.java`
- [User API](https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/controller/UserController.java): `src/main/java/com/orderflow/orderflow/controller/UserController.java`
- [Order API](https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/controller/OrderController.java): `src/main/java/com/orderflow/orderflow/controller/OrderController.java`
- [OpenAPI setup](https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/config/OpenApiConfig.java): `src/main/java/com/orderflow/orderflow/config/OpenApiConfig.java`
- [Request responses](https://github.com/shivanisingh2k/orderflow/tree/main/src/main/java/com/orderflow/orderflow/dto): `src/main/java/com/orderflow/orderflow/dto`
- [API error handling](https://github.com/shivanisingh2k/orderflow/tree/main/src/main/java/com/orderflow/orderflow/exception): `src/main/java/com/orderflow/orderflow/exception`

### Business Domain

- [Product service](https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/service/ProductService.java): `src/main/java/com/orderflow/orderflow/service/ProductService.java`
- [User service](https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/service/UserService.java): `src/main/java/com/orderflow/orderflow/service/UserService.java`
- [Order service](https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/service/OrderService.java): `src/main/java/com/orderflow/orderflow/service/OrderService.java`
- [Domain entities](https://github.com/shivanisingh2k/orderflow/tree/main/src/main/java/com/orderflow/orderflow): `src/main/java/com/orderflow/orderflow`

### Persistence

- [JPA repositories](https://github.com/shivanisingh2k/orderflow/tree/main/src/main/java/com/orderflow/orderflow/repository): `src/main/java/com/orderflow/orderflow/repository`
- **PostgreSQL**

### Security

- [Security configuration](https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/config/SecurityConfig.java): `src/main/java/com/orderflow/orderflow/config/SecurityConfig.java`
- [JWT filter](https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/security/JwtAuthenticationFilter.java): `src/main/java/com/orderflow/orderflow/security/JwtAuthenticationFilter.java`
- [JWT service](https://github.com/shivanisingh2k/orderflow/blob/main/src/main/java/com/orderflow/orderflow/security/JwtService.java): `src/main/java/com/orderflow/orderflow/security/JwtService.java`
- **BCrypt encoder**

### Other components

- **API client**

## Connections

- API client → Authentication API: logs in (evidence: `README.md`)
- API client → Product API: manages products (evidence: `README.md`)
- API client → User API: manages users (evidence: `README.md`)
- API client → Order API: creates order (evidence: `README.md`)
- Product API → Product service: delegates to (evidence: `src/main/java/com/orderflow/orderflow/controller/ProductController.java`)
- User API → User service: delegates to (evidence: `src/main/java/com/orderflow/orderflow/controller/UserController.java`)
- Order API → Order service: delegates to (evidence: `src/main/java/com/orderflow/orderflow/controller/OrderController.java`)
- Authentication API → JPA repositories: looks up user (evidence: `src/main/java/com/orderflow/orderflow/controller/AuthController.java`)
- Authentication API → JWT service: issues token (evidence: `src/main/java/com/orderflow/orderflow/controller/AuthController.java`)
- Authentication API → BCrypt encoder: checks password (evidence: `src/main/java/com/orderflow/orderflow/controller/AuthController.java`)
- User service → BCrypt encoder: hashes password (evidence: `src/main/java/com/orderflow/orderflow/service/UserService.java`)
- Product service → JPA repositories: reads and writes (evidence: `src/main/java/com/orderflow/orderflow/service/ProductService.java`)
- User service → JPA repositories: reads and writes (evidence: `src/main/java/com/orderflow/orderflow/service/UserService.java`)
- Order service → JPA repositories: loads and saves (evidence: `src/main/java/com/orderflow/orderflow/service/OrderService.java`)
- Order service → Domain entities: builds order (evidence: `src/main/java/com/orderflow/orderflow/service/OrderService.java`)
- Product service → Domain entities: maps products (evidence: `src/main/java/com/orderflow/orderflow/service/ProductService.java`)
- User service → Domain entities: maps users (evidence: `src/main/java/com/orderflow/orderflow/service/UserService.java`)
- JPA repositories → PostgreSQL: persists entities (evidence: `README.md`)
- Security configuration → JWT filter: registers filter (evidence: `src/main/java/com/orderflow/orderflow/config/SecurityConfig.java`)
- JWT filter → JWT service: validates token (evidence: `src/main/java/com/orderflow/orderflow/security/JwtAuthenticationFilter.java`)
- Domain entities → API error handling: raises domain errors (evidence: `src/main/java/com/orderflow/orderflow/service/OrderService.java`)
