How jonathan25sam/practica6-sistemas-distribuidos works
1. This repository is a small Spring-based microservices system for a franchise business domain, split into four independently runnable modules: eureka-server, api-gateway, ms-inventario, and ms-ventas.
2. The architectural center is service discovery via Eureka Server. Both business services register there, and the Gateway uses the registry to route traffic dynamically instead of hardcoding service addresses.
3. API Gateway is the single external entry point on port 8080. It acts as the front door for clients and forwards requests to backend services based on discovered service instances. The README makes clear that clients should not call the business services directly.
4. MS-Inventario is the inventory domain service on port 8082. Its code structure is a classic Spring Boot layered service: controller for HTTP endpoints, entity for the domain model, and repository for persistence access.
5. The only visible domain entity in inventory is CorteCarne, which suggests the service manages a product/catalog-like stock model centered on meat cuts. The repository layer (CorteCarneRepository) indicates data access is abstracted behind Spring Data.
6. The inventory service uses an in-memory H2 database per the README, so inventory state is volatile and initialized on startup. This makes it a self-contained data source for the sales service to query during runtime.
7. MS-Ventas is the sales/orchestration service on port 8083. Its main role is not persistence but coordination: it exposes a business endpoint and calls inventory internally through InventarioClient.
8. InventarioClient strongly indicates OpenFeign is used for synchronous service-to-service communication. In other words, sales depends on inventory through a service contract, not through direct database access or shared storage.
9. The main business flow described by the repository is: external client calls the Gateway, Gateway routes to ms-ventas, and ms-ventas then queries ms-inventario to assemble the final response. This creates a two-hop request path with the Gateway as the first boundary and Eureka enabling service lookup.
10. The important architectural boundaries are therefore:
- Edge boundary: API Gateway
- Discovery boundary: Eureka Server
- Inventory/data boundary: MS-Inventario with H2 persistence
- Orchestration boundary: MS-Ventas consuming inventory through Feign
11. Startup order matters because discovery must exist before the services and Gateway can register and resolve endpoints. The README explicitly requires starting Eureka first, then inventory, then sales, then the Gateway, followed by a short stabilization delay for registration/heartbeats.
12. From an architecture diagram perspective, the key arrows are: client → Gateway → Sales → Inventory, with both Sales and Inventory also pointing to Eureka for registration/discovery. The only persistent data store in this repo is the embedded H2 database inside inventory; the other modules are stateless services around routing and orchestration.
Main entry points: ApiGatewayApplication.java API Gateway · MsVentasApplication.java MS Ventas · CorteCarneRepository.java CorteCarne Repo · CorteCarneController.java CorteCarne API
Components 11
Edge
External access and routing
- Client · Calls the system through the gateway
- API Gateway · Single entry point on port 8080
api-gateway/src/main/java/com/franquicia/apigateway/ApiGatewayApplication.java
Discovery
Service registry and lookup
- Eureka Server · Service registry for discovery
eureka-server/src/main/java/com/franquicia/eurekaserver/EurekaServerApplication.java
Sales
Order orchestration service
- MS Ventas · Sales/orchestration service on port 8083
ms-ventas/src/main/java/com/franquicia/msventas/MsVentasApplication.java - Ventas API · Business endpoint exposed to clients
ms-ventas/src/main/java/com/franquicia/msventas/VentasController.java - Inventario Client · Sync calls into inventory service
ms-ventas/src/main/java/com/franquicia/msventas/InventarioClient.java
Inventory
Stock domain service
- MS Inventario · Inventory service on port 8082
ms-inventario/src/main/java/com/franquicia/msinventario/MsInventarioApplication.java - CorteCarne API · Inventory HTTP endpoints
ms-inventario/src/main/java/com/franquicia/msinventario/controller/CorteCarneController.java - CorteCarne · Inventory domain model
ms-inventario/src/main/java/com/franquicia/msinventario/entity/CorteCarne.java - CorteCarne Repo · Spring Data access layer
ms-inventario/src/main/java/com/franquicia/msinventario/repository/CorteCarneRepository.java - H2 DB · In-memory inventory storage
Connections 12
- Client → API Gateway: requests · External traffic enters here
- API Gateway → Eureka Server: discovers routes · Gateway resolves backend services via registry
- API Gateway → MS Ventas: routes to · Forwards client traffic to sales service
- MS Ventas → Eureka Server: registers · Sales service joins discovery
- MS Inventario → Eureka Server: registers · Inventory service joins discovery
- Ventas API → Inventario Client: delegates · Controller uses Feign client for inventory lookup
- Inventario Client → CorteCarne API: calls · Feign request to inventory API
- CorteCarne API → CorteCarne Repo: uses · Controller reads/writes through repository
- CorteCarne Repo → CorteCarne: maps · Repository persists the domain entity
- CorteCarne Repo → H2 DB: stores in · Inventory state lives in embedded H2
- MS Ventas → Ventas API: hosts · Application exposes the sales controller
- MS Inventario → CorteCarne API: hosts · Application exposes inventory endpoints