How eltonriva1/curso-udemy-comunicacao-microsservicos works
Project Type and Purpose
• This is a microservices-based system composed of three services—Auth-API, Product-API, and Sales-API—containerized with Docker and orchestrated via Docker Compose.
• Purpose: demonstrate synchronous communication (HTTP/Feign), asynchronous messaging (RabbitMQ), JWT-based security, and containerized deployment.
High-Level File-Structure Analysis
• Top-level:
• README.md and docker-compose.yml
• auth-api (Node.js/Express)
• product-api (Java/Spring Boot)
• sales-api (Node.js/Express)
• Each service folder contains source code (controllers, services, repositories), configuration (DB, auth, RabbitMQ), and Docker files.
• product-api uses Spring Boot modules (controllers, services, repositories, Feign client, RabbitMQ listener), auth-api and sales-api use Express middleware for JWT and RabbitMQ setup.
Key Architectural Insights from README
• Three microservices with dedicated data stores:
• Auth-API → PostgreSQL
• Product-API → PostgreSQL
• Sales-API → MongoDB
• Shared RabbitMQ broker for asynchronous events (order placements, stock updates).
• Synchronous calls via HTTP/Feign for inter-service requests (e.g., Sales→Product, Product→Sales).
• JWT authentication enforced by Auth-API; checked by middleware/interceptor in Product and Sales services.
Components
a. Service Containers (rectangles):
• Auth-API (Node.js)
• Product-API (Spring Boot)
• Sales-API (Node.js)
• PostgreSQL instance for Auth & Product
• MongoDB instance for Sales
• RabbitMQ
Relationships and Data Flows
• Client → HTTP → Auth-API (login/register) → JWT issued
• Client → HTTP (with JWT) → Product-API / Sales-API
• Product-API and Sales-API → HTTP (Feign) → Auth-API for token verification
• Sales-API (OrderController) → HTTP (Feign) → Product-API (e.g., check stock)
• Sales-API → publish “order placed” event → RabbitMQ exchange/queue
• Product-API → subscribe to stock-update queue → update inventory
• Product-API → when appropriate, publish “stock changed” event → RabbitMQ
• Sales-API → subscribe to “sales confirmation” queue → update order status
Architectural Patterns & Design Principles
• Microservices—each service independently deployable, own database
• Layered architecture within each service: Controllers → Services → Repositories
• API security via JWT, enforced by middleware/interceptors
• Synchronous RPC-like calls via Feign (Spring) and HTTP clients (Node.js)
• Event–driven asynchronous communication via RabbitMQ
• Containerization for environment consistency