# leandro12rk/sistemadegestiondeinventario architecture

> Architecture diagram of the GitHub repository leandro12rk/sistemadegestiondeinventario, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/leandro12rk/sistemadegestiondeinventario
- Repository: https://github.com/leandro12rk/sistemadegestiondeinventario

## Overview

1. **Repository shape**
   - This is a **multi-module Maven monorepo** for a Spring Boot microservices system.
   - Top-level modules in the tree are: `eureka-server`, `gateway-service`, `product-service`, `inventory-service`, and `purchase-service`.
   - A `docker/` folder provides database bootstrap SQL and a Compose setup, so the runtime architecture includes both application services and dedicated PostgreSQL instances.

2. **Overall request path**
   - The expected entry point for external clients is the **Gateway Service**.
   - From there, requests are routed to the domain services rather than calling them directly.
   - Service-to-service lookup is handled through **Eureka discovery**, so the services are designed to find each other dynamically.

3. **Service discovery boundary**
   - `eureka-server` is the **registry** for the microservices.
   - Each business service is a separate Spring Boot application and likely registers itself with Eureka at startup.
   - This is the main infrastructure boundary that decouples routing from fixed host/port addresses.

4. **Gateway boundary**
   - `gateway-service` is the **single ingress layer**.
   - It sits between clients and the internal services, which is the primary edge boundary in the system.
   - No domain logic is present here in the tree; its role is infrastructure routing.

5. **Product service: master data and catalog**
   - `product-service` is the most feature-rich service and appears to be the **source of truth for catalog/master data**.
   - It contains separate controller/service/repository layers for:
     - `product`
     - `category`
     - `supplier`
   - It also includes DTOs, projections, and centralized exception handling, which suggests this service exposes both CRUD-style APIs and read-optimized query endpoints.

6. **Product service internal layering**
   - The package structure is classic Spring layered architecture:
     - `controller` for HTTP APIs
     - `service` for business rules
     - `repository` for persistence
     - `model` for JPA entities
     - `dto` and `projection` for API/view shaping
     - `exception` for consistent error responses
   - This makes `product-service` the main domain boundary for master records.

7. **Inventory service: stock and movement tracking**
   - `inventory-service` focuses on **inventory state and auditability**.
   - Its controllers are split by use case:
     - `inventory`
     - `stockMovements`
     - `goodsReceipts`
   - The presence of `StockMovementsModel` and `GoodReceiptsModel` indicates the service stores both current stock and the events that affect it.

8. **Inventory service dependency on Product service**
   - `inventory-service` includes a `client/product/ProductClient.java`, which indicates a **Feign-style remote call dependency** on the product service.
   - It also has a `ProductDTO`, so inventory operations likely enrich or validate stock data against product metadata.
   - This is a one-way dependency: inventory consumes product data, but product does not appear to depend on inventory.

9. **Purchase service: procurement workflow**
   - `purchase-service` handles **purchase orders and order details**.
   - Its controllers are split into:
     - `purchaseOrders`
     - `purchaseOrderDetails`
   - The model/repository split follows the same pattern as the other services, suggesting purchase data is persisted and managed independently.

10. **Purchase service dependencies**
   - `purchase-service` has Feign clients for both `product` and `supplier`.
   - That means purchase flows likely resolve product and supplier information from external service APIs rather than duplicating those tables locally.
   - This service is the main consumer of multiple master-data domains.

11. **Persistence architecture**
   - The README and Docker files indicate a **database-per-service** approach.
   - The Compose/SQL assets create separate PostgreSQL databases for:
     - products
     - inventory
     - purchases
   - This is an important architectural boundary: each service owns its own schema and lifecycle.

12. **Technology and runtime**
   - The services are built with **Java / Spring Boot**, using **Spring Data JPA** for persistence.
   - The README states **Spring Cloud / OpenFeign / Eureka** are part of the stack.
   - The tree does not show a config server implementation, even though the README mentions one; in this repository snapshot, the concrete platform pieces present are Eureka, Gateway, and the business services.

13. **Cross-service communication pattern**
   - The architecture is a mix of:
     - **synchronous HTTP calls** between services via Feign clients
     - **registry-based service discovery** via Eureka
     - **database isolation** per service
   - There is no evidence in the tree of messaging/queues or event streaming; the integration style appears primarily request/response.

14. **Operational structure**
   - Every service has its own `application.properties` and test class, so each is independently runnable and testable.
   - The repo is therefore organized for distributed deployment, but still manageable as a single source tree for development.

15. **Diagramming summary**
   - A good architecture diagram should show:
     - external clients entering through the gateway
     - gateway routing through Eureka-discovered services
     - product/inventory/purchase as separate bounded contexts
     - Feign-based calls from inventory and purchase back to product and supplier data
     - dedicated PostgreSQL databases per service under Docker

Main entry points: [`gateway-service/src/main/java/io/github/leandro12rk/gateway/GatewayServiceApplication.java`](https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/gateway-service/src/main/java/io/github/leandro12rk/gateway/GatewayServiceApplication.java) (Gateway), [`purchase-service/src/main/java/io/github/leandro12rk/purchase`](https://github.com/leandro12rk/sistemadegestiondeinventario/tree/main/purchase-service/src/main/java/io/github/leandro12rk/purchase) (Purchase Core), [`product-service/src/main/java/io/github/leandro12rk/product/ProductServiceApplication.java`](https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/product-service/src/main/java/io/github/leandro12rk/product/ProductServiceApplication.java) (Product Service), [`eureka-server/src/main/java/io/github/leandro12rk/eureka_server/EurekaServerApplication.java`](https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/eureka-server/src/main/java/io/github/leandro12rk/eureka_server/EurekaServerApplication.java) (Eureka)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_gateway["Gateway<br/>edge service"]
  node_eureka["Eureka<br/>registry"]
  node_product["Product Service<br/>catalog service"]
  node_product_api["Product APIs<br/>http controllers"]
  node_product_core["Product Core<br/>domain services"]
  node_product_data["Product Data<br/>persistence layer"]
  node_inventory["Inventory Service<br/>stock service"]
  node_inventory_api["Inventory APIs<br/>http controllers"]
  node_inventory_core["Inventory Core<br/>domain logic"]
  node_purchase["Purchase Service<br/>procurement service"]
  node_purchase_api["Purchase APIs<br/>http controllers"]
  node_purchase_core["Purchase Core<br/>domain logic"]
end

subgraph group_data["Data"]
  node_docker["Docker Assets<br/>deployment assets"]
  node_product_db[("Products DB<br/>postgres database<br/>[product_init.sql]")]
  node_inventory_db[("Inventory DB<br/>postgres database<br/>[inventory_init.sql]")]
  node_purchase_db[("Purchases DB<br/>postgres database<br/>[purchase_init.sql]")]
end

node_clients(("Clients<br/>external"))

node_clients -->|"HTTP requests"| node_gateway
node_gateway -.->|"discover services"| node_eureka
node_gateway -->|"route"| node_product
node_gateway -->|"route"| node_inventory
node_gateway -->|"route"| node_purchase
node_product -.->|"register"| node_eureka
node_inventory -.->|"register"| node_eureka
node_purchase -.->|"register"| node_eureka
node_product -->|"exposes"| node_product_api
node_product_api -->|"delegates"| node_product_core
node_product_core -->|"persists via"| node_product_data
node_inventory -->|"exposes"| node_inventory_api
node_inventory_api -->|"delegates"| node_inventory_core
node_inventory_core -.->|"lookup"| node_product
node_purchase -->|"exposes"| node_purchase_api
node_purchase_api -->|"delegates"| node_purchase_core
node_purchase_core -.->|"lookup"| node_product
node_purchase_core -.->|"via discovery"| node_gateway
node_purchase_core -.->|"discover services"| node_eureka
node_inventory_core -->|"stores in"| node_inventory_db
node_product_data -->|"stores in"| node_product_db
node_purchase_core -->|"stores in"| node_purchase_db
node_docker -->|"bootstraps"| node_product_db
node_docker -->|"bootstraps"| node_inventory_db
node_docker -->|"bootstraps"| node_purchase_db

click node_gateway "https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/gateway-service/src/main/java/io/github/leandro12rk/gateway/GatewayServiceApplication.java"
click node_eureka "https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/eureka-server/src/main/java/io/github/leandro12rk/eureka_server/EurekaServerApplication.java"
click node_product "https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/product-service/src/main/java/io/github/leandro12rk/product/ProductServiceApplication.java"
click node_product_api "https://github.com/leandro12rk/sistemadegestiondeinventario/tree/main/product-service/src/main/java/io/github/leandro12rk/product/controller"
click node_product_core "https://github.com/leandro12rk/sistemadegestiondeinventario/tree/main/product-service/src/main/java/io/github/leandro12rk/product/service"
click node_product_data "https://github.com/leandro12rk/sistemadegestiondeinventario/tree/main/product-service/src/main/java/io/github/leandro12rk/product/model"
click node_inventory "https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/inventory-service/src/main/java/io/github/leandro12rk/inventory/InventoryServiceApplication.java"
click node_inventory_api "https://github.com/leandro12rk/sistemadegestiondeinventario/tree/main/inventory-service/src/main/java/io/github/leandro12rk/inventory/controller"
click node_inventory_core "https://github.com/leandro12rk/sistemadegestiondeinventario/tree/main/inventory-service/src/main/java/io/github/leandro12rk/inventory"
click node_purchase "https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/purchase-service/src/main/java/io/github/leandro12rk/purchase/PurchaseServiceApplication.java"
click node_purchase_api "https://github.com/leandro12rk/sistemadegestiondeinventario/tree/main/purchase-service/src/main/java/io/github/leandro12rk/purchase/controller"
click node_purchase_core "https://github.com/leandro12rk/sistemadegestiondeinventario/tree/main/purchase-service/src/main/java/io/github/leandro12rk/purchase"
click node_docker "https://github.com/leandro12rk/sistemadegestiondeinventario/tree/main/docker"
click node_product_db "https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/docker/product_init.sql"
click node_inventory_db "https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/docker/inventory_init.sql"
click node_purchase_db "https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/docker/purchase_init.sql"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_gateway,node_eureka,node_product,node_product_api,node_product_core,node_product_data,node_inventory,node_inventory_api,node_inventory_core,node_purchase,node_purchase_api,node_purchase_core toneBlue
class node_docker,node_product_db,node_inventory_db,node_purchase_db toneAmber
class node_clients toneNeutral
```

## Components

### Runtime

Spring Boot services, gateway, and discovery registry.

- [Gateway](https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/gateway-service/src/main/java/io/github/leandro12rk/gateway/GatewayServiceApplication.java): edge service · Single ingress layer for client traffic. · `gateway-service/src/main/java/io/github/leandro12rk/gateway/GatewayServiceApplication.java`
- [Eureka](https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/eureka-server/src/main/java/io/github/leandro12rk/eureka_server/EurekaServerApplication.java): registry · Service discovery registry used by the microservices. · `eureka-server/src/main/java/io/github/leandro12rk/eureka_server/EurekaServerApplication.java`
- [Product Service](https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/product-service/src/main/java/io/github/leandro12rk/product/ProductServiceApplication.java): catalog service · Master data service for products, categories, and suppliers. · `product-service/src/main/java/io/github/leandro12rk/product/ProductServiceApplication.java`
- [Product APIs](https://github.com/leandro12rk/sistemadegestiondeinventario/tree/main/product-service/src/main/java/io/github/leandro12rk/product/controller): http controllers · HTTP endpoints for product, category, and supplier operations. · `product-service/src/main/java/io/github/leandro12rk/product/controller`
- [Product Core](https://github.com/leandro12rk/sistemadegestiondeinventario/tree/main/product-service/src/main/java/io/github/leandro12rk/product/service): domain services · Business logic, DTO shaping, projections, and exception handling. · `product-service/src/main/java/io/github/leandro12rk/product/service`
- [Product Data](https://github.com/leandro12rk/sistemadegestiondeinventario/tree/main/product-service/src/main/java/io/github/leandro12rk/product/model): persistence layer · JPA entities and repositories for product-domain storage. · `product-service/src/main/java/io/github/leandro12rk/product/model`
- [Inventory Service](https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/inventory-service/src/main/java/io/github/leandro12rk/inventory/InventoryServiceApplication.java): stock service · Tracks inventory state, stock movements, and goods receipts. · `inventory-service/src/main/java/io/github/leandro12rk/inventory/InventoryServiceApplication.java`
- [Inventory APIs](https://github.com/leandro12rk/sistemadegestiondeinventario/tree/main/inventory-service/src/main/java/io/github/leandro12rk/inventory/controller): http controllers · Endpoints for inventory, stock movement, and goods receipt flows. · `inventory-service/src/main/java/io/github/leandro12rk/inventory/controller`
- [Inventory Core](https://github.com/leandro12rk/sistemadegestiondeinventario/tree/main/inventory-service/src/main/java/io/github/leandro12rk/inventory): domain logic · Inventory models, repository-backed state, and product lookup client. · `inventory-service/src/main/java/io/github/leandro12rk/inventory`
- [Purchase Service](https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/purchase-service/src/main/java/io/github/leandro12rk/purchase/PurchaseServiceApplication.java): procurement service · Manages purchase orders and order details. · `purchase-service/src/main/java/io/github/leandro12rk/purchase/PurchaseServiceApplication.java`
- [Purchase APIs](https://github.com/leandro12rk/sistemadegestiondeinventario/tree/main/purchase-service/src/main/java/io/github/leandro12rk/purchase/controller): http controllers · Endpoints for purchase orders and order details. · `purchase-service/src/main/java/io/github/leandro12rk/purchase/controller`
- [Purchase Core](https://github.com/leandro12rk/sistemadegestiondeinventario/tree/main/purchase-service/src/main/java/io/github/leandro12rk/purchase): domain logic · Purchase models, repositories, and Feign clients to product and supplier services. · `purchase-service/src/main/java/io/github/leandro12rk/purchase`

### Data

Database ownership and Docker bootstrap assets.

- [Docker Assets](https://github.com/leandro12rk/sistemadegestiondeinventario/tree/main/docker): deployment assets · Compose and SQL bootstrap files for local infrastructure. · `docker`
- [Products DB](https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/docker/product_init.sql): postgres database · Dedicated PostgreSQL database for product-service. · `docker/product_init.sql`
- [Inventory DB](https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/docker/inventory_init.sql): postgres database · Dedicated PostgreSQL database for inventory-service. · `docker/inventory_init.sql`
- [Purchases DB](https://github.com/leandro12rk/sistemadegestiondeinventario/blob/main/docker/purchase_init.sql): postgres database · Dedicated PostgreSQL database for purchase-service. · `docker/purchase_init.sql`

### Other components

- **Clients**: external · External consumers of the system.

## Connections

- Clients → Gateway: HTTP requests · All external traffic enters through the gateway.
- Gateway → Eureka: discover services · Gateway relies on registry-based service discovery.
- Gateway → Product Service: route · Gateway forwards catalog requests to product-service.
- Gateway → Inventory Service: route · Gateway forwards inventory requests to inventory-service.
- Gateway → Purchase Service: route · Gateway forwards procurement requests to purchase-service.
- Product Service → Eureka: register · Product service participates in discovery.
- Inventory Service → Eureka: register · Inventory service participates in discovery.
- Purchase Service → Eureka: register · Purchase service participates in discovery.
- Product Service → Product APIs: exposes · Product service exposes its REST controllers.
- Product APIs → Product Core: delegates · Controllers delegate to business services and query shaping.
- Product Core → Product Data: persists via · Domain logic uses repositories and entities.
- Inventory Service → Inventory APIs: exposes · Inventory service exposes its REST controllers.
- Inventory APIs → Inventory Core: delegates · Controllers delegate to inventory logic and persistence.
- Inventory Core → Product Service: lookup · Inventory enriches or validates against product data.
- Purchase Service → Purchase APIs: exposes · Purchase service exposes its REST controllers.
- Purchase APIs → Purchase Core: delegates · Controllers delegate to purchase logic and persistence.
- Purchase Core → Product Service: lookup · Purchase flows resolve product data remotely.
- Purchase Core → Gateway: via discovery · Remote calls are supported by the shared discovery layer.
- Purchase Core → Eureka: discover services · Feign clients depend on registry-backed service resolution.
- Inventory Core → Inventory DB: stores in · Inventory state is kept in its own database.
- Product Data → Products DB: stores in · Product data is kept in its own database.
- Purchase Core → Purchases DB: stores in · Purchase data is kept in its own database.
- Docker Assets → Products DB: bootstraps · Docker assets provision the product database.
- Docker Assets → Inventory DB: bootstraps · Docker assets provision the inventory database.
- Docker Assets → Purchases DB: bootstraps · Docker assets provision the purchase database.
