How kelsonthony/algafood-api works
Project type and purpose
• AlgaFood API is a Java Spring Boot microservice exposing a REST API for food ordering.
• It follows Domain-Driven Design, uses OAuth2 for security, persists to MySQL, caches in Redis, migrates schema with Flyway, sends email notifications and product‐photo storage, and is deployed via Docker/ECS on AWS.
File structure for logical layers
• src/main/java/com/kelsonthony/algafood/api ⇒ HTTP Controllers & DTO assemblers (API layer).
• .core & .domain ⇒ configuration, security, email, validation, domain model, repositories, services (Business & Domain layer).
• .infrastructure ⇒ JPA repository implementations, email storage & template processors, report/pdf services, storage adapters (Persistence & Integration layer).
• resources/db/migration ⇒ Flyway migrations.
• resources/templates ⇒ email & OAuth login pages.
• Dockerfile, docker-compose.yml, nginx/ ⇒ containerization & proxy.
Relationships & interactions
• Client → (HTTPS) → NGINX → Spring Boot API
• API → Auth server (token validation/grant)
• API → MySQL via Spring Data JPA
• API → Redis cache for read-heavy endpoints
• API → S3 (via StorageService) to upload/download images
• Domain events in API → EmailService → SMTP or mock adapter
• Business/report requests → ReportService → Jasper → returns PDF
• API logs → Loggly via Spring Cloud/Logback
Architectural patterns & principles
• Layered (Controller → Service → Repository → External)
• Domain-Driven Design (Entities, Repositories, Services, Events)
• Hexagonal-ish ports/adapters in infrastructure
• DTO/Assembler pattern for API-domain mapping
• OAuth2 Authorization & Resource Server in same Spring Boot app
Final checklist
• Labels: technology + role (e.g., “Redis Cache”, “Flyway Migration”).