How davidd23b/notmess-backend works
Project Type and Purpose
• This is a Spring Boot–based REST API backend (no UI layer in this repo).
• It exposes HTTP endpoints to manage “NotMess” domain entities (Albaran, Appcc*, Producto, Usuario, etc.) and handles authentication via JWT.
• It persists data in a PostgreSQL database using Spring Data JPA and provides auxiliary services for CSV import and image handling.
High-Level Architecture Components
a. Entry Point
• NotMessBackendApplication.java: boots the Spring context and embedded Tomcat.
b. API Layer (Controllers)
• Packages under controller/ (e.g., AuthController, ProductoController, AppccController, etc.).
• Exposes REST endpoints, input DTOs → output DTOs, orchestrates service calls.
c. Security Layer
• SecurityConfig, JwtAuthFilter, JwtUtil, CustomUserDetailsService, AuthenticationEntryPoint.
• Intercepts HTTP calls, authenticates via JWT, authorizes roles.
d. Service Layer
• service/ + impl/ (e.g., ProductoServiceImpl, AuthServiceImpl): business rules, transaction management.
• CsvService, ImagenService for file operations.
e. Repository/Data Access
• repository/ interfaces extending JpaRepository for CRUD.
• model/ JPA entities correspond to SQL scripts in resources/SQL.
f. Persistence
• PostgreSQL database, schema defined in SQL/*.sql files.
g. External Actors
• Clients (frontend UI, mobile apps, Postman) that call the REST API.
• Possibly external file storage if images are offloaded.
Component Relationships and Data Flows
• Client → HTTP(S) → JwtAuthFilter → Controller
• Controller → Service → Repository → PostgreSQL
• Service may call CsvService or ImagenService for filesystem or S3 operations.
• SecurityConfig wires JwtAuthFilter before controllers.
• DTO mappers convert between entities and DTOs.
Architectural Patterns and Principles
• Layered Architecture (Controller → Service → Repository).
• Dependency Injection via Spring.
• JWT-based stateless authentication.
• DTO + Mapper pattern to decouple API models from persistence models.
• Exception handling via GlobalExceptionHandler.
2. “Client” actor outside.
• Controllers layer at top.
• Security component (JwtAuthFilter) between Client and Controllers.
• Service layer below Controllers.
• Repository layer below Services.
5. Notes on SQL scripts under resources/SQL as deployment artifacts.
• Controllers (blue), Services (green), Repositories (orange), Security (red), Database (brown).