How pashtet482/autoshop works
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: OrderService.java Order Service · api.js Browser JS · SupplyService.java Supply Service · SecurityConfig.java Security
Components 23
Client UI
Static browser pages and frontend scripts
- Browser JS · Client-side API calls and page logic
src/main/resources/static/js/api.js - Static Pages · Browser-served application pages
src/main/resources/static/index.html
Platform
Application bootstrap, security, config, and error handling
- AutoShop · Application entry point and runtime bootstrap
src/main/java/com/example/autoshop/AutoshopApplication.java - Security · Central auth, authorization, and security bean wiring
src/main/java/com/example/autoshop/SecurityConfig.java - Security Beans · Supporting security bean definitions
src/main/java/com/example/autoshop/SecurityBeansConfig.java - Static Config · Static resource handling and public asset exposure
src/main/java/com/example/autoshop/StaticResourceConfig.java - Errors · 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 · Account, profile, and password endpoints
src/main/java/com/example/autoshop/users/controller/UserController.java - User Service · User account and password business logic
src/main/java/com/example/autoshop/users/service/UserService.java - User Details · Database-backed user lookup for security
src/main/java/com/example/autoshop/users/service/CustomUserDetailsService.java - Products API · Catalog, brand, and category endpoints
src/main/java/com/example/autoshop/products/controller/ProductController.java - Catalog Service · Product, brand, and category business logic
src/main/java/com/example/autoshop/products/service/ProductService.java - Product Mapper · Entity-to-DTO translation for catalog data
src/main/java/com/example/autoshop/products/mapper/ProductMapper.java - Supply API · Supplier, warehouse, and incoming supply endpoints
src/main/java/com/example/autoshop/supply/controller/SupplyController.java - Supply Service · Procurement and inbound inventory business logic
src/main/java/com/example/autoshop/supply/service/SupplyService.java - Supply Mapper · Entity-to-DTO translation for supply flows
src/main/java/com/example/autoshop/supply/mapper/SupplyMapper.java - Orders API · Order lifecycle and receipt endpoints
src/main/java/com/example/autoshop/orders/controller/OrderController.java - Order Service · Order processing and receipt generation logic
src/main/java/com/example/autoshop/orders/service/OrderService.java - Order 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 · Persistence for users and price levels
src/main/java/com/example/autoshop/users/repository/UserRepository.java - Product Repo · Persistence for products, attributes, and stock
src/main/java/com/example/autoshop/products/repository/ProductRepository.java - Supply Repo · Persistence for supplies, items, suppliers, and warehouses
src/main/java/com/example/autoshop/supply/repository/SupplyRepository.java - Order Repo · Persistence for orders
src/main/java/com/example/autoshop/orders/repository/OrderRepository.java
Connections 25
- 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