# pashtet482/autoshop architecture

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

- Interactive diagram: https://gitdiagram.com/pashtet482/autoshop
- Repository: https://github.com/pashtet482/autoshop

## Overview

1. **Overall shape**  
   AutoShop is a single Spring Boot monolith, not a set of microservices. It exposes a REST-style backend and also serves the browser UI from `src/main/resources/static`.

2. **Client boundary**  
   The frontend is made of static HTML, CSS, and vanilla JavaScript pages such as `index.html`, `products.html`, `orders.html`, `supplies.html`, `users.html`, and `login.html`. The JS layer (`static/js/api.js`, `app.js`) is the client-side entry point that talks to backend controllers.

3. **Backend layering pattern**  
   The code is organized consistently by business domain into `controller -> service -> repository -> model`, with DTOs and mappers in between. That means controllers receive/return transfer objects, services hold business logic, repositories persist JPA entities, and mappers translate between entity and DTO forms.

4. **Security boundary**  
   Authentication and authorization are handled centrally with Spring Security. `SecurityConfig`, `SecurityBeansConfig`, and `CustomUserDetailsService` indicate a custom user lookup from the database, role-based access control, and dedicated security bean wiring. Static resource handling is also explicitly configured, so public pages and protected endpoints are separated.

5. **User management subsystem**  
   The `users` package manages application accounts, roles, and price levels. `User`, `UserRole`, and `PriceLevel` are the core domain objects, with `UserService` and `UserController` handling account operations such as profile and password changes. `WrongPasswordException` suggests password update validation is enforced in the service layer.

6. **Product catalog subsystem**  
   The `products` package models the parts catalog. It includes `Product`, `Brand`, `Category`, `ProductAttribute`, and `ProductStock`, plus DTOs for create/update/search operations. This subsystem likely supports catalog browsing, filtering, product CRUD, and stock visibility.

7. **Inventory and supply subsystem**  
   The `supply` package covers procurement and warehouse flow. It models `Supplier`, `Warehouse`, `Supply`, and `SupplyItem`, with controllers and services for recording incoming goods. This is the inbound inventory path that feeds stock into the product/warehouse data model.

8. **Order processing subsystem**  
   The `orders` package handles customer orders. `Order`, `OrderStatus`, and `ProductInOrder` represent the order header and line items, while `OrderService` contains order lifecycle logic and `ReceiptService` suggests receipt generation or order output. Order DTOs and mappers isolate the API from the persistence model.

9. **Cross-domain links**  
   Some repositories and models bridge bounded contexts, especially where product, stock, and order data overlap. For example, order items reference product data, and supply/warehouse activity affects stock availability. This is important for the architecture diagram because inventory is shared state across multiple modules.

10. **Persistence layer**  
    Persistence is through Spring Data JPA repositories over PostgreSQL, as stated in the README. Each domain has its own repository set, such as `UserRepository`, `ProductRepository`, `OrderRepository`, `SupplyRepository`, and `WarehouseRepository`, which makes the database the main integration point for business state.

11. **DTO and mapper boundary**  
    DTOs are used heavily throughout the app to separate API contracts from entities. Mappers like `ProductMapper`, `OrderMapper`, `SupplyMapper`, and `UserMapper` indicate a deliberate anti-corruption layer between the web/API layer and the JPA model.

12. **Error handling and response consistency**  
    `GlobalExceptionHandler` centralizes exception-to-response mapping for the REST API. This keeps controller logic thin and ensures predictable error behavior across domains.

13. **Runtime and tooling**  
    The application targets Java 21 and uses Maven (`pom.xml`, Maven wrapper) for build and run. The only visible test is a basic Spring Boot context test, so the repository appears to focus more on application structure than extensive automated test coverage.

14. **What the architecture diagram should emphasize**  
    The key diagram should show: browser static pages and JS on one side; Spring Boot controllers/services in the middle; JPA repositories and PostgreSQL on the other side; with security, exception handling, and DTO/mapper layers wrapping the business domains.

Main entry points: [`src/main/java/com/example/autoshop/orders/service/OrderService.java`](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/orders/service/OrderService.java) (Order Service), [`src/main/resources/static/js/api.js`](https://github.com/pashtet482/autoshop/blob/master/src/main/resources/static/js/api.js) (Browser JS), [`src/main/java/com/example/autoshop/supply/service/SupplyService.java`](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/supply/service/SupplyService.java) (Supply Service), [`src/main/java/com/example/autoshop/SecurityConfig.java`](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/SecurityConfig.java) (Security)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client UI"]
  node_api["Browser JS<br/>frontend js<br/>[api.js]"]
  node_pages["Static Pages<br/>html ui<br/>[index.html]"]
end

subgraph group_platform["Platform"]
  node_app(("AutoShop<br/>Spring Boot app"))
  node_security["Security"]
  node_securitybeans["Security Beans<br/>security config"]
  node_staticconfig["Static Config<br/>web config"]
  node_errors["Errors<br/>exception handler"]
end

subgraph group_domains["Business Domains"]
  node_usersctl["Users API<br/>rest controller"]
  node_usersvc["User Service<br/>domain service<br/>[UserService.java]"]
  node_customuds["User Details<br/>security service"]
  node_productsctl["Products API<br/>rest controller"]
  node_brandsvc["Catalog Service<br/>domain service"]
  node_productmapper["Product Mapper<br/>dto mapper<br/>[ProductMapper.java]"]
  node_supplyctl["Supply API<br/>rest controller"]
  node_supplysvc["Supply Service<br/>domain service<br/>[SupplyService.java]"]
  node_supplymapper["Supply Mapper<br/>dto mapper<br/>[SupplyMapper.java]"]
  node_ordersctl["Orders API<br/>rest controller"]
  node_ordersvc["Order Service<br/>domain service<br/>[OrderService.java]"]
  node_ordermapper["Order Mapper<br/>dto mapper<br/>[OrderMapper.java]"]
end

subgraph group_data["Persistence"]
  node_userrepo["User Repo<br/>jpa repository"]
  node_productrepo["Product Repo<br/>jpa repository"]
  node_supplyrepo["Supply Repo<br/>jpa repository"]
  node_orderrepo["Order Repo<br/>jpa repository"]
end

node_api -->|"calls"| node_usersctl
node_api -->|"calls"| node_productsctl
node_api -->|"calls"| node_supplyctl
node_api -->|"calls"| node_ordersctl
node_pages -->|"uses"| node_api
node_security -->|"auth lookup"| node_customuds
node_security -->|"wires"| node_securitybeans
node_security -->|"permits static"| node_staticconfig
node_usersctl -->|"delegates"| node_usersvc
node_usersvc -->|"persists"| node_userrepo
node_usersvc -.->|"throws"| node_errors
node_productsctl -->|"delegates"| node_brandsvc
node_brandsvc -->|"maps"| node_productmapper
node_brandsvc -->|"persists"| node_productrepo
node_supplyctl -->|"delegates"| node_supplysvc
node_supplysvc -->|"maps"| node_supplymapper
node_supplysvc -->|"persists"| node_supplyrepo
node_ordersctl -->|"delegates"| node_ordersvc
node_ordersvc -->|"maps"| node_ordermapper
node_ordersvc -->|"persists"| node_orderrepo
node_ordersvc -.->|"throws"| node_errors
node_supplysvc -.->|"updates stock"| node_productrepo
node_ordersvc -.->|"reads stock"| node_productrepo
node_app -->|"boots"| node_security
node_app -->|"registers"| node_errors

click node_app "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/AutoshopApplication.java"
click node_security "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/SecurityConfig.java"
click node_securitybeans "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/SecurityBeansConfig.java"
click node_staticconfig "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/StaticResourceConfig.java"
click node_errors "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/exceptions/GlobalExceptionHandler.java"
click node_api "https://github.com/pashtet482/autoshop/blob/master/src/main/resources/static/js/api.js"
click node_pages "https://github.com/pashtet482/autoshop/blob/master/src/main/resources/static/index.html"
click node_usersctl "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/users/controller/UserController.java"
click node_usersvc "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/users/service/UserService.java"
click node_customuds "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/users/service/CustomUserDetailsService.java"
click node_userrepo "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/users/repository/UserRepository.java"
click node_productsctl "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/products/controller/ProductController.java"
click node_brandsvc "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/products/service/ProductService.java"
click node_productmapper "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/products/mapper/ProductMapper.java"
click node_productrepo "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/products/repository/ProductRepository.java"
click node_supplyctl "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/supply/controller/SupplyController.java"
click node_supplysvc "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/supply/service/SupplyService.java"
click node_supplymapper "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/supply/mapper/SupplyMapper.java"
click node_supplyrepo "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/supply/repository/SupplyRepository.java"
click node_ordersctl "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/orders/controller/OrderController.java"
click node_ordersvc "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/orders/service/OrderService.java"
click node_ordermapper "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/orders/mapper/OrderMapper.java"
click node_orderrepo "https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/orders/repository/OrderRepository.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_api,node_pages toneBlue
class node_app,node_security,node_securitybeans,node_staticconfig,node_errors toneAmber
class node_usersctl,node_usersvc,node_customuds,node_productsctl,node_brandsvc,node_productmapper,node_supplyctl,node_supplysvc,node_supplymapper,node_ordersctl,node_ordersvc,node_ordermapper toneMint
class node_userrepo,node_productrepo,node_supplyrepo,node_orderrepo toneRose
```

## Components

### Client UI

Static browser pages and frontend scripts

- [Browser JS](https://github.com/pashtet482/autoshop/blob/master/src/main/resources/static/js/api.js): frontend js · Client-side API calls and page logic · `src/main/resources/static/js/api.js`
- [Static Pages](https://github.com/pashtet482/autoshop/blob/master/src/main/resources/static/index.html): html ui · Browser-served application pages · `src/main/resources/static/index.html`

### Platform

Application bootstrap, security, config, and error handling

- [AutoShop](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/AutoshopApplication.java): Spring Boot app · Application entry point and runtime bootstrap · `src/main/java/com/example/autoshop/AutoshopApplication.java`
- [Security](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/SecurityConfig.java): spring security · Central auth, authorization, and security bean wiring · `src/main/java/com/example/autoshop/SecurityConfig.java`
- [Security Beans](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/SecurityBeansConfig.java): security config · Supporting security bean definitions · `src/main/java/com/example/autoshop/SecurityBeansConfig.java`
- [Static Config](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/StaticResourceConfig.java): web config · Static resource handling and public asset exposure · `src/main/java/com/example/autoshop/StaticResourceConfig.java`
- [Errors](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/exceptions/GlobalExceptionHandler.java): exception handler · Central REST exception-to-response mapping · `src/main/java/com/example/autoshop/exceptions/GlobalExceptionHandler.java`

### Business Domains

Main application subsystems organized by business area

- [Users API](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/users/controller/UserController.java): rest controller · Account, profile, and password endpoints · `src/main/java/com/example/autoshop/users/controller/UserController.java`
- [User Service](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/users/service/UserService.java): domain service · User account and password business logic · `src/main/java/com/example/autoshop/users/service/UserService.java`
- [User Details](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/users/service/CustomUserDetailsService.java): security service · Database-backed user lookup for security · `src/main/java/com/example/autoshop/users/service/CustomUserDetailsService.java`
- [Products API](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/products/controller/ProductController.java): rest controller · Catalog, brand, and category endpoints · `src/main/java/com/example/autoshop/products/controller/ProductController.java`
- [Catalog Service](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/products/service/ProductService.java): domain service · Product, brand, and category business logic · `src/main/java/com/example/autoshop/products/service/ProductService.java`
- [Product Mapper](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/products/mapper/ProductMapper.java): dto mapper · Entity-to-DTO translation for catalog data · `src/main/java/com/example/autoshop/products/mapper/ProductMapper.java`
- [Supply API](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/supply/controller/SupplyController.java): rest controller · Supplier, warehouse, and incoming supply endpoints · `src/main/java/com/example/autoshop/supply/controller/SupplyController.java`
- [Supply Service](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/supply/service/SupplyService.java): domain service · Procurement and inbound inventory business logic · `src/main/java/com/example/autoshop/supply/service/SupplyService.java`
- [Supply Mapper](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/supply/mapper/SupplyMapper.java): dto mapper · Entity-to-DTO translation for supply flows · `src/main/java/com/example/autoshop/supply/mapper/SupplyMapper.java`
- [Orders API](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/orders/controller/OrderController.java): rest controller · Order lifecycle and receipt endpoints · `src/main/java/com/example/autoshop/orders/controller/OrderController.java`
- [Order Service](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/orders/service/OrderService.java): domain service · Order processing and receipt generation logic · `src/main/java/com/example/autoshop/orders/service/OrderService.java`
- [Order Mapper](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/orders/mapper/OrderMapper.java): dto mapper · Entity-to-DTO translation for orders and line items · `src/main/java/com/example/autoshop/orders/mapper/OrderMapper.java`

### Persistence

Repositories and database-facing integration points

- [User Repo](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/users/repository/UserRepository.java): jpa repository · Persistence for users and price levels · `src/main/java/com/example/autoshop/users/repository/UserRepository.java`
- [Product Repo](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/products/repository/ProductRepository.java): jpa repository · Persistence for products, attributes, and stock · `src/main/java/com/example/autoshop/products/repository/ProductRepository.java`
- [Supply Repo](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/supply/repository/SupplyRepository.java): jpa repository · Persistence for supplies, items, suppliers, and warehouses · `src/main/java/com/example/autoshop/supply/repository/SupplyRepository.java`
- [Order Repo](https://github.com/pashtet482/autoshop/blob/master/src/main/java/com/example/autoshop/orders/repository/OrderRepository.java): jpa repository · Persistence for orders · `src/main/java/com/example/autoshop/orders/repository/OrderRepository.java`

## Connections

- Browser JS → Users API: calls · Frontend invokes account endpoints
- Browser JS → Products API: calls · Frontend invokes catalog endpoints
- Browser JS → Supply API: calls · Frontend invokes supply endpoints
- Browser JS → Orders API: calls · Frontend invokes order endpoints
- Static Pages → Browser JS: uses · Static pages load and use the browser API layer
- Security → User Details: auth lookup · Security delegates user lookup to the custom user details service
- Security → Security Beans: wires · Security configuration relies on dedicated security beans
- Security → Static Config: permits static · Security and web config separate public assets from protected routes
- Users API → User Service: delegates · Controller stays thin and forwards to service layer
- User Service → User Repo: persists · User operations read and write through repositories
- User Service → Errors: throws · Password and validation failures are handled centrally
- Products API → Catalog Service: delegates · Catalog requests flow into domain services
- Catalog Service → Product Mapper: maps · Service uses DTO/entity translation for API boundaries
- Catalog Service → Product Repo: persists · Catalog state is stored via JPA repositories
- Supply API → Supply Service: delegates · Supply requests flow into inbound inventory logic
- Supply Service → Supply Mapper: maps · Service converts between DTOs and entities
- Supply Service → Supply Repo: persists · Supply, supplier, and warehouse data are stored through repositories
- Orders API → Order Service: delegates · Order requests flow into lifecycle logic
- Order Service → Order Mapper: maps · Order service uses DTO/entity translation
- Order Service → Order Repo: persists · Order state is stored through JPA repositories
- Order Service → Errors: throws · Order errors are normalized by the global handler
- Supply Service → Product Repo: updates stock · Inbound inventory affects shared product stock state
- Order Service → Product Repo: reads stock · Orders depend on product and availability data
- AutoShop → Security: boots · Application starts with security and web configuration
- AutoShop → Errors: registers · Core application includes centralized error handling
