# auzzton/scm architecture

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

- Interactive diagram: https://gitdiagram.com/auzzton/scm
- Repository: https://github.com/auzzton/scm

## Overview

SCM is a supply-chain management application for inventory, suppliers, purchase orders, users, and operational analytics. The primary workflow is a user managing products and suppliers, creating or editing pending orders, then completing an order to increase stock; order status changes also publish events. The Next.js client uses a typed API client to reach Spring REST endpoints, with backend services coordinating persistence and business logic. The tree and README establish analytics and Kafka capabilities; sampled source verifies order and product service behavior, while detailed wiring for unsampled subsystems is not inferred.

Main entry points: [`scm-client/src/lib/api.ts`](https://github.com/auzzton/scm/blob/main/scm-client/src/lib/api.ts) (Typed API client), [`scm-server/src/main/java/com/scm/server/service/OrderService.java`](https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/service/OrderService.java) (Order lifecycle), [`scm-server/src/main/java/com/scm/server/repository`](https://github.com/auzzton/scm/tree/main/scm-server/src/main/java/com/scm/server/repository) (Domain repositories), [`scm-client/src/app`](https://github.com/auzzton/scm/tree/main/scm-client/src/app) (App pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_pages["App pages"]
  node_authui[("Auth state<br/>[useAuthStore.ts]")]
  node_apiclient["Typed API client<br/>[api.ts]"]
end

subgraph group_identity["Identity and access"]
  node_authpages["Login and guards"]
  node_authcontroller["Authentication API"]
  node_authservice["Authentication service"]
  node_jwt["JWT security"]
  node_users[("User persistence")]
end

subgraph group_operations["Supply operations"]
  node_orderapi["Order API"]
  node_orderservice["Order lifecycle<br/>[OrderService.java]"]
  node_productapi["Product API"]
  node_productservice["Inventory service"]
  node_supplierapi["Supplier API"]
  node_supplierdata["Supplier service"]
  node_repositories[("Domain repositories")]
  node_models["Supply domain"]
end

subgraph group_insights["Analytics"]
  node_dashboardapi["Dashboard API"]
  node_dashboardservice["Dashboard metrics"]
  node_analyticsapi["Analytics API"]
  node_analyticsservice["Analytics service"]
end

subgraph group_events["Order events"]
  node_producer["Order event producer"]
  node_consumers["Event consumers"]
end

node_user(("User"))
node_postgres[("PostgreSQL")]
node_kafka["Kafka"]

node_user -->|"uses"| node_pages
node_pages -->|"requests data"| node_apiclient
node_pages -->|"renders auth"| node_authpages
node_authpages -->|"stores session"| node_authui
node_apiclient -->|"REST calls"| node_authcontroller
node_authcontroller -->|"delegates auth"| node_authservice
node_authservice -->|"reads and writes"| node_users
node_authservice -->|"issues tokens"| node_jwt
node_apiclient -->|"REST calls"| node_orderapi
node_orderapi -->|"delegates orders"| node_orderservice
node_orderservice -->|"reads and writes"| node_repositories
node_orderservice -->|"loads supplier"| node_supplierdata
node_orderservice -->|"loads products"| node_productservice
node_orderservice -->|"dispatches event"| node_producer
node_producer -->|"publishes"| node_kafka
node_kafka -->|"delivers events"| node_consumers
node_apiclient -->|"REST calls"| node_productapi
node_productapi -->|"delegates inventory"| node_productservice
node_productservice -->|"reads and writes"| node_repositories
node_apiclient -->|"REST calls"| node_supplierapi
node_supplierapi -->|"delegates suppliers"| node_supplierdata
node_supplierdata -->|"reads and writes"| node_repositories
node_repositories -->|"persists entities"| node_postgres
node_orderservice -->|"updates stock"| node_models
node_apiclient -->|"REST calls"| node_dashboardapi
node_dashboardapi -->|"requests stats"| node_dashboardservice
node_dashboardservice -->|"reads summaries"| node_repositories
node_apiclient -->|"REST calls"| node_analyticsapi
node_analyticsapi -->|"requests analytics"| node_analyticsservice
node_analyticsservice -->|"reads metrics"| node_repositories

click node_pages "https://github.com/auzzton/scm/tree/main/scm-client/src/app"
click node_authui "https://github.com/auzzton/scm/blob/main/scm-client/src/store/useAuthStore.ts"
click node_apiclient "https://github.com/auzzton/scm/blob/main/scm-client/src/lib/api.ts"
click node_authpages "https://github.com/auzzton/scm/tree/main/scm-client/src/components"
click node_authcontroller "https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/controller/AuthenticationController.java"
click node_authservice "https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/service/AuthenticationService.java"
click node_jwt "https://github.com/auzzton/scm/tree/main/scm-server/src/main/java/com/scm/server/config"
click node_users "https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/repository/UserRepository.java"
click node_orderapi "https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/controller/OrderController.java"
click node_orderservice "https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/service/OrderService.java"
click node_productapi "https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/controller/ProductController.java"
click node_productservice "https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/service/ProductService.java"
click node_supplierapi "https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/controller/SupplierController.java"
click node_supplierdata "https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/service/SupplierService.java"
click node_repositories "https://github.com/auzzton/scm/tree/main/scm-server/src/main/java/com/scm/server/repository"
click node_models "https://github.com/auzzton/scm/tree/main/scm-server/src/main/java/com/scm/server/model"
click node_dashboardapi "https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/controller/DashboardController.java"
click node_dashboardservice "https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/service/DashboardService.java"
click node_analyticsapi "https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/controller/AnalyticsController.java"
click node_analyticsservice "https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/service/AnalyticsService.java"
click node_producer "https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/service/OrderEventProducer.java"
click node_consumers "https://github.com/auzzton/scm/tree/main/scm-server/src/main/java/com/scm/server/service"

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_pages,node_authui,node_apiclient,node_user toneBlue
class node_authpages,node_authcontroller,node_authservice,node_jwt,node_users,node_postgres toneAmber
class node_orderapi,node_orderservice,node_productapi,node_productservice,node_supplierapi,node_supplierdata,node_repositories,node_models toneMint
class node_dashboardapi,node_dashboardservice,node_analyticsapi,node_analyticsservice toneRose
class node_producer,node_consumers,node_kafka toneIndigo
```

## Components

### Web client

- [App pages](https://github.com/auzzton/scm/tree/main/scm-client/src/app): `scm-client/src/app`
- [Auth state](https://github.com/auzzton/scm/blob/main/scm-client/src/store/useAuthStore.ts): `scm-client/src/store/useAuthStore.ts`
- [Typed API client](https://github.com/auzzton/scm/blob/main/scm-client/src/lib/api.ts): `scm-client/src/lib/api.ts`

### Identity and access

- [Login and guards](https://github.com/auzzton/scm/tree/main/scm-client/src/components): `scm-client/src/components`
- [Authentication API](https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/controller/AuthenticationController.java): `scm-server/src/main/java/com/scm/server/controller/AuthenticationController.java`
- [Authentication service](https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/service/AuthenticationService.java): `scm-server/src/main/java/com/scm/server/service/AuthenticationService.java`
- [JWT security](https://github.com/auzzton/scm/tree/main/scm-server/src/main/java/com/scm/server/config): `scm-server/src/main/java/com/scm/server/config`
- [User persistence](https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/repository/UserRepository.java): `scm-server/src/main/java/com/scm/server/repository/UserRepository.java`

### Supply operations

- [Order API](https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/controller/OrderController.java): `scm-server/src/main/java/com/scm/server/controller/OrderController.java`
- [Order lifecycle](https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/service/OrderService.java): `scm-server/src/main/java/com/scm/server/service/OrderService.java`
- [Product API](https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/controller/ProductController.java): `scm-server/src/main/java/com/scm/server/controller/ProductController.java`
- [Inventory service](https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/service/ProductService.java): `scm-server/src/main/java/com/scm/server/service/ProductService.java`
- [Supplier API](https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/controller/SupplierController.java): `scm-server/src/main/java/com/scm/server/controller/SupplierController.java`
- [Supplier service](https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/service/SupplierService.java): `scm-server/src/main/java/com/scm/server/service/SupplierService.java`
- [Domain repositories](https://github.com/auzzton/scm/tree/main/scm-server/src/main/java/com/scm/server/repository): `scm-server/src/main/java/com/scm/server/repository`
- [Supply domain](https://github.com/auzzton/scm/tree/main/scm-server/src/main/java/com/scm/server/model): `scm-server/src/main/java/com/scm/server/model`

### Analytics

- [Dashboard API](https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/controller/DashboardController.java): `scm-server/src/main/java/com/scm/server/controller/DashboardController.java`
- [Dashboard metrics](https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/service/DashboardService.java): `scm-server/src/main/java/com/scm/server/service/DashboardService.java`
- [Analytics API](https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/controller/AnalyticsController.java): `scm-server/src/main/java/com/scm/server/controller/AnalyticsController.java`
- [Analytics service](https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/service/AnalyticsService.java): `scm-server/src/main/java/com/scm/server/service/AnalyticsService.java`

### Order events

- [Order event producer](https://github.com/auzzton/scm/blob/main/scm-server/src/main/java/com/scm/server/service/OrderEventProducer.java): `scm-server/src/main/java/com/scm/server/service/OrderEventProducer.java`
- [Event consumers](https://github.com/auzzton/scm/tree/main/scm-server/src/main/java/com/scm/server/service): `scm-server/src/main/java/com/scm/server/service`

### Other components

- **User**
- **PostgreSQL**
- **Kafka**

## Connections

- User → App pages: uses
- App pages → Typed API client: requests data
- App pages → Login and guards: renders auth
- Login and guards → Auth state: stores session
- Typed API client → Authentication API: REST calls
- Authentication API → Authentication service: delegates auth
- Authentication service → User persistence: reads and writes
- Authentication service → JWT security: issues tokens
- Typed API client → Order API: REST calls
- Order API → Order lifecycle: delegates orders
- Order lifecycle → Domain repositories: reads and writes
- Order lifecycle → Supplier service: loads supplier
- Order lifecycle → Inventory service: loads products
- Order lifecycle → Order event producer: dispatches event
- Order event producer → Kafka: publishes
- Kafka → Event consumers: delivers events
- Typed API client → Product API: REST calls
- Product API → Inventory service: delegates inventory
- Inventory service → Domain repositories: reads and writes
- Typed API client → Supplier API: REST calls
- Supplier API → Supplier service: delegates suppliers
- Supplier service → Domain repositories: reads and writes
- Domain repositories → PostgreSQL: persists entities
- Order lifecycle → Supply domain: updates stock
- Typed API client → Dashboard API: REST calls
- Dashboard API → Dashboard metrics: requests stats
- Dashboard metrics → Domain repositories: reads summaries
- Typed API client → Analytics API: REST calls
- Analytics API → Analytics service: requests analytics
- Analytics service → Domain repositories: reads metrics
