How aserg-ufmg/micro-livraria works
Project Type and Purpose
• This is a didactic, full-stack microservices demo (“Micro-Livraria”) built in Node.js.
• It consists of four services—Frontend, Controller, Inventory, Shipping—and illustrates:
• REST between browser and Controller
• gRPC (Protocol Buffers) between Controller and the two backend services
• Containerization (Docker) and end-to-end testing (Cypress)
High-Level Architectural Components
a. User Agent (Browser/Cypress)
b. Frontend Service (services/frontend)
c. Controller Service (services/controller)
d. Inventory Service (services/inventory)
e. Shipping Service (services/shipping)
f. Proto Definitions (proto/*.proto)
g. (Optional) Docker artifacts for service isolation
h. Configuration & Orchestration (package.json scripts, Dockerfiles, potential load-balancer/Kubernetes)
Component Interactions and Data Flow
• Browser ←(HTTP REST)→ Controller
• GET /products
• GET /shipping/:cep
• GET /product/:id
• Controller ←(gRPC)→ Inventory
• InventoryService.SearchAllProducts
• InventoryService.SearchProductByID
• Controller ←(gRPC)→ Shipping
• ShippingService.GetShippingRate
• Inventory reads from a local JSON (products.json); Shipping computes rates in-memory.
Architectural Patterns & Design Principles
• Microservices: each service is a single responsibility, independently deployable.
• API Gateway / Façade (Controller): translations between REST and gRPC.
• Interface Definition Layer (proto files): central contract for RPC stubs.
• Polyglot communication: REST for external clients, gRPC for high-performance internal calls.
• Containerization: Dockerfiles for isolating services in containers; potential orchestration.