This document describes the system architecture, design patterns, and technical decisions for the Autobank application.
Autobank is a modern web application built using a layered architecture pattern with clear separation of concerns. The system follows Spring Boot conventions and implements RESTful API design principles.
┌─────────────────────────────────────────────────────────────┐
│ Frontend (Not in scope) │
└─────────────────────────┬───────────────────────────────────┘
│ HTTP/REST API
┌─────────────────────────▼───────────────────────────────────┐
│ Spring Boot Application │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Security │ │ Web │ │ Error │ │
│ │ Filter │ │ Config │ │ Handling │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ Controller Layer │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Auth │ │ Receipt │ │ Committee │ │
│ │ Controller │ │ Controller │ │ Controller │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ ┌─────────────┐ ┌─────────────┐ │
│ │ Admin │ │ Economic │ │
│ │ Controller │ │ Controller │ │
│ └─────────────┘ └─────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ Service Layer │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Receipt │ │ Auth │ │ Committee │ │
│ │ Service │ │ Service │ │ Service │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Blob │ │ Attachment │ │ Review │ │
│ │ Service │ │ Service │ │ Service │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ Repository Layer │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Receipt │ │ User │ │ Committee │ │
│ │ Repository │ │ Repository │ │ Repository │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ Data Layer │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ JPA/ │ │ Entity │ │ DTO │ │
│ │ Hibernate │ │ Models │ │ Classes │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────▼───────────────────────────────────┐
│ External Dependencies │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Azure │ │ Auth0 │ │ Azure │ │
│ │ SQL Server │ │ OAuth2 │ │ Blob │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────┘
The application follows a traditional layered architecture with clear separation of concerns:
- Controller Layer: Handles HTTP requests and responses
- Service Layer: Contains business logic and orchestration
- Repository Layer: Manages data access and persistence
- Data Layer: Entity models and DTOs
Uses Spring's dependency injection container for:
- Loose coupling between components
- Easy testing and mocking
- Configuration management
- Bean lifecycle management
Implements Spring Data JPA repositories for:
- Abstraction over data access
- Automatic query generation
- Custom query methods
- Transaction management
Uses Data Transfer Objects for:
- API request/response models
- Data transformation between layers
- Validation and serialization
- Decoupling internal models from API contracts
- Spring Boot 3.x: Main application framework
- Spring Security: Authentication and authorization
- Spring Data JPA: Data access layer
- Spring Web: REST API development
- Microsoft SQL Server: Primary database (Azure)
- Hibernate: ORM implementation
- HikariCP: Connection pooling (default in Spring Boot)
- OAuth2: Authentication protocol
- JWT: Token-based authentication
- Auth0: Identity provider
- Spring Security: Security framework
- Azure Blob Storage: File attachment storage
- Azure Storage SDK: Integration library
- Gradle: Build automation
- Docker: Containerization
- Azure: Cloud platform
- HTTP request/response handling
- Input validation
- Authentication/authorization checks
- Error handling
- Response formatting
AuthenticationController: User authenticationReceiptController: Receipt management for usersAdminReceiptController: Admin receipt operationsCommitteeController: Committee managementEconomicrequestController: Economic request handling
- RESTful API design
- HTTP status code conventions
- Consistent error responses
- Request/response DTOs
- Business logic implementation
- Transaction management
- Data validation
- External service integration
- Complex operations orchestration
ReceiptService: Core receipt business logicReceiptAdminService: Admin-specific operationsAuthenticationService: User authentication logicBlobService: File storage operationsCommitteeService: Committee management
- Service facade pattern
- Transaction boundaries
- Business rule validation
- External service abstraction
- Data access abstraction
- Query execution
- Entity mapping
- Database transaction handling
ReceiptRepository: Receipt data accessOnlineUserRepository: User data accessCommitteeRepository: Committee data accessAttachmentRepository: File metadata access
- Spring Data JPA auto-implementation
- Custom query methods
- Specification pattern for complex queries
- Pagination and sorting support
- JPA entity annotations
- Relationship mappings
- Validation constraints
- Audit fields
- Request/response models
- Data transformation
- Validation annotations
- Serialization control
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Client │ │ Autobank │ │ Auth0 │
│ │ │ Server │ │ │
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘
│ │ │
│ 1. Login Request │ │
├─────────────────►│ │
│ │ 2. Redirect to │
│ │ Auth0 │
│ ├─────────────────►│
│ │ │
│ 3. Auth0 Login │ │
├─────────────────────────────────────►│
│ │ │
│ 4. JWT Token │ │
◄─────────────────────────────────────┤
│ │ │
│ 5. API Request │ │
│ with JWT │ │
├─────────────────►│ │
│ │ 6. Validate JWT │
│ ├─────────────────►│
│ │ │
│ │ 7. Token Valid │
│ ◄─────────────────┤
│ │ │
│ 8. API Response │ │
◄─────────────────┤ │
- Regular Users: Can create and view their own receipts
- Admin Users: Can view all receipts and create reviews
- Committee-Based: Admin status determined by committee membership
- JWT token validation
- Audience validation
- Issuer validation
- Environment-based security (dev/prod)
- CORS configuration
1. User submits receipt via API
2. Controller validates request
3. Service processes business logic
4. Attachments uploaded to Azure Blob
5. Receipt saved to database
6. Response returned to user
1. Admin requests receipt list
2. Service checks admin privileges
3. Repository fetches all receipts
4. Admin selects receipt to review
5. Admin submits review decision
6. Service validates and saves review
7. Receipt status updated
- Global exception handler
- Custom business exceptions
- Validation error handling
- HTTP status code mapping
{
"error": "Error Type",
"message": "Human-readable message",
"timestamp": "2023-12-01T10:30:00Z",
"path": "/api/endpoint"
}