How cdocamposanchez/get-a-book works
Project Type and Purpose
• This is a Java Spring Boot monolithic backend service exposing REST APIs for a book-ordering application (“Gab”).
• Layers follow a clean‐architecture style: presentation (controllers), application (use‐cases + DTOs + mappers), domain (entities, value objects, exceptions), infrastructure (persistence, security, external integrations).
Main Components
a. Client (Frontend)
b. Backend Service (“Gab” Application)
– Presentation Layer (Spring MVC Controllers)
– Application Layer (Use-cases orchestrating business logic; DTOs & Mappers)
– Domain Layer (Domain Models, Value Objects, Domain Exceptions)
– Infrastructure Layer
• Persistence: JPA Entities → Repositories → Database
• Security: JWT Provider, Filters, CustomUserDetailsService
• External Services: Cloudinary (image storage), Stripe (payments), SMTP (emails), Caching
• Configuration Modules (CORS, Cache, Security, Dotenv Loader)
c. Database
– Relational DB (MySQL/Postgres; defined by application.yml)
– Show Entities ↔ DB Tables
d. External Services
– Cloudinary API
– Stripe API
– SMTP Email Server
e. Other Services
– Cache (e.g., Redis) if enabled in CacheConfig
Relationships & Data Flow
• Frontend → (HTTPS/REST) → Controllers
• Controllers → Use‐cases (calls to application services)
• Use‐cases → Domain Models & Repositories
• Repositories → Database
• Use‐cases/Infrastructure → External Services (Cloudinary, Stripe, SMTP)
• Security Filter Chain intercepts Frontend requests, validates JWT, populates Authentication for Controllers
Architectural Patterns & Principles
• Layered (Onion/Clean) architecture separating business logic from delivery and infrastructure
• DTOs + Mappers isolate domain from external models
• Use‐cases encapsulate application business rules
• Spring Security for authentication/authorization (JWT-based)
• Specification pattern for querying (BookSpecification)
• Exception handling with a GlobalExceptionHandler
Essential Details to Capture
• The “frontend branch” (Client) calling REST endpoints
• Secure perimeter: JwtAuthFilter → Controllers
• Use‐cases grouped by domain (book, order, user)
• Technologies: Spring Boot, Spring MVC, Spring Security, Spring Data JPA, Hibernate, Cloudinary SDK, Stripe SDK, Java Mail