Layers Architecture Index
This directory contains comprehensive documentation of the five-layer architecture used in Smart Supply Pro’s backend system.
Available Sections
Core Layers Documentation
- Controller Layer - HTTP API entry point, request routing, authorization
- Service Layer - Business logic orchestration, transaction management
- Repository Layer - Data access abstraction, queries, persistence
- Model Layer - JPA entities, relationships, domain objects
- Infrastructure & Cross-Cutting Concerns - Configuration, security, validation, exception handling, mapping
Controller Components (Detailed)
The Controller Layer has been broken down into focused guides:
- Routing - URL mapping and HTTP methods
- Validation - Input validation and constraints
- Authorization - Authentication and role checks
- DTO Conversion (Inbound) - JSON → Object mapping
- DTO Conversion (Outbound) - Object → JSON mapping
- Response Building - HTTP status codes and responses
- Core Controllers - SupplierController, InventoryItemController, etc.
- Error Handling Flow - Exception mapping to HTTP responses
- Best Practices - Standards and guidelines
- Request/Response Lifecycle - Complete flow through the layer
- Integration - How controller connects to service layer
- Testing - Unit and integration testing strategies
Service Components (Detailed)
The Service Layer has been broken down into focused guides:
- Core Services Overview - SupplierService, InventoryItemService, StockHistoryService, AnalyticsService
- Supplier Service - Supplier management operations
- Inventory Item Service - Item lifecycle and stock tracking
- Stock History Service - Immutable audit trail management
- Analytics Service - Business intelligence and reporting
- Service Patterns - Dependency injection, transactions, validation
- Dependency Injection - Constructor-based DI pattern
- Transaction Management - @Transactional boundaries
- Exception Translation - Domain exceptions → HTTP responses
- Data Transformation - DTO ↔︎ Entity mapping
- Validation Strategy - Business rule validation
- Audit Logging - Tracking changes with createdBy/updatedBy
- Interaction Diagram - Service operation flow
- Cross-Cutting Concerns - Exception handling and logging
- Testing - Unit testing with Mockito
- Integration - How service layer connects to others
- Best Practices - Service design guidelines
Model Components (Detailed)
The Model Layer has been broken down into focused guides:
- Supplier Entity - Inventory goods providers
- Inventory Item Entity - Products/items in inventory
- Stock History Entity - Immutable audit trail
- App User Entity - OAuth2 users and authentication
- Enumerations - Role and StockChangeReason types
- Entity Relationships - Supplier → Item → StockHistory, User relationships
- JPA Annotations - @Entity, @Column, @ManyToOne, @Version, etc.
- Design Patterns - Audit fields, optimistic locking, denormalization
- Data Integrity - Primary keys, unique constraints, foreign keys
- Model Lifecycle - Transient → Managed → Persistent states
- Best Practices - Lombok, fetch strategies, immutability
Quick Navigation by Role
Developers
- Start with Overview for the big picture
- Review Controller Layer to understand endpoint structure
- Check Routing for endpoint mapping
- Check Service Layer for business logic patterns
- Check Service Patterns for design patterns
- Reference Best Practices for standards
Database Administrators
- Review Repository Layer for queries and indexing
- Check Model Layer to understand entities and relationships
- Review Entity Relationships for schema design
- Reference Data Integrity for constraints
- Check Service Layer for transaction patterns
Security/DevOps
- Review Security for authentication details
- Check Configuration for environment setup
- Reference Best Practices for standards
New Team Members
- Start with Overview
- Read Best Practices
- Review specific layers as needed