How rafaeldsal/ecommerce-service works
Project Type and Purpose
• This is a monolithic backend service—a Spring Boot e-commerce API (“Minha Prata”) that exposes REST endpoints for user, product, order, category, payment, authentication, and order‐history management. It applies clean architecture principles (layered design) and integrates with external systems (MySQL, Redis, Kafka, external CEP and Mail services).
File Structure Analysis
• Top-level:
• pom.xml, Docker Compose (MySQL)
• src/main/java/com/rafaeldsal/ws/minhaprata/…
• src/main/resources/application.properties (app config, DB, JWT)
• Layered packages under com/rafaeldsal/ws/minhaprata:
• configuration (security, Kafka, Redis)
• controller (REST endpoints)
• dto (request/response payloads)
• exception (error handling)
• integration (external REST/mail services)
• listener & consumer (Redis expirations, Kafka consumers)
• producer (Kafka producers)
• mapper (DTO↔entity mapping)
• model (JPA entities, Redis models, enums)
• repository (Spring Data JPA + Redis)
• service & service.impl (business logic)
• utils (helper classes)
• Test folder contains unit tests.
README Insights
• Describes a layered architecture (configuration, controller, service, repository).
• Uses Java 17, Spring Boot (Web, Data JPA, Security), Flyway, Docker Compose for MySQL, JWT auth.
• Emphasizes clean architecture and SOLID.
Diagramming Guidance
a. Main Components
1. API Layer (Controllers)
2. Service Layer (Service interfaces + implementations)
3. Data Layer
– JPA Repositories → MySQL
– Redis Repositories → Redis (caching, recovery codes, pending orders)
4. Integration Layer
– External CEP REST service
– External Mail service
5. Messaging Infrastructure
– Kafka Producer → “payment-intent” topic
– Kafka Consumers → payment status updates, notifications
6. Security Layer
– JWT filter, AuthenticationAspect, SecurityConfig
b. Relationships & Interactions
– HTTP requests → Controllers → Services → Repositories / integration / producers
– Services publish events via KafkaProducer → Kafka topics
– Kafka Consumers listen to topics → update DB or notify clients
– Redis listener reacts to key expirations → invokes business logic
– Controllers secured by SecurityFilter → AuthenticationAspect → JWT validation
c. Architectural Patterns & Principles
– Layered (Presentation, Business, Data)
– Dependency Injection (Spring)
– Publish–Subscribe (Kafka)
– Event-Driven (Kafka + Redis keyspace notifications)
– Clean Architecture (separation of concerns, DTOs, mappers, interfaces)
– SOLID (single responsibility: controllers, services, repositories)
d. Key Technologies
– Spring Boot (Web MVC, DI, Security)
– Spring Data JPA + Flyway → MySQL
– Spring Data Redis
– Spring for Apache Kafka
– JWT (bearer tokens)
– Docker Compose (MySQL container)
– Lombok, MapStruct (for mappers if used), Maven