# zera-interdisciplinar/ms-inventory architecture

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

- Interactive diagram: https://gitdiagram.com/zera-interdisciplinar/ms-inventory
- Repository: https://github.com/zera-interdisciplinar/ms-inventory

## Overview

ms-inventory is a Zera inventory microservice for tracking equipment across registration, approval, stock, maintenance, evaluation, and disposal. Its main workflow begins with an authenticated user using the HTTP API; item use cases manage state transitions and history, with persistence in Neo4j. Separate capabilities cover catalog management, dashboards, rules and alerts, failure prediction, photo storage, and MCP tools for the AI assistant. The README documents these subsystem roles and integrations; source excerpts additionally show item-controller dispatch and photo-storage implementations, but not most use-case or adapter internals.

Main entry points: [`src/main/java/com/zera/ms_inventory/infrastructure/http/controller`](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/infrastructure/http/controller) (HTTP controllers), [`src/main/java/com/zera/ms_inventory/core/usecase/item`](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/item) (Item lifecycle), [`src/main/java/com/zera/ms_inventory/infrastructure/persistence/neo4j`](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/infrastructure/persistence/neo4j) (Neo4j persistence), [`src/main/java/com/zera/ms_inventory/core/usecase/model`](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/model) (Catalog management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_http["HTTP controllers"]
  node_security["JWT authorization"]
end

subgraph group_inventory["Inventory domain"]
  node_itemflow["Item lifecycle"]
  node_catalog["Catalog management"]
  node_categories["Categories"]
  node_materials["Material catalog"]
  node_disposal["Disposal records"]
  node_domain["Domain entities"]
end

subgraph group_operations["Operational insights"]
  node_dashboard["Dashboard metrics"]
  node_rules["Rules and alerts"]
  node_rulejob["Rule evaluation job"]
  node_prediction["Failure prediction"]
  node_predictionjob["Prediction job"]
end

subgraph group_adapters["Infrastructure adapters"]
  node_neo4j[("Neo4j persistence")]
  node_photos["Photo storage"]
end

subgraph group_assistant["Assistant interface"]
  node_mcp["MCP tools"]
end

node_user(("Authenticated user"))
node_gcs[("Google Cloud Storage")]
node_admin["Administrative core"]
node_predictor["Prediction service"]
node_assistant(("AI assistant"))
node_gemini["Gemini embeddings"]

node_user -->|"calls API"| node_http
node_http -->|"authorizes"| node_security
node_http -->|"dispatches"| node_itemflow
node_http -->|"dispatches"| node_catalog
node_http -->|"dispatches"| node_categories
node_http -->|"dispatches"| node_disposal
node_http -->|"dispatches"| node_dashboard
node_http -->|"dispatches"| node_rules
node_http -.->|"dispatches"| node_prediction
node_itemflow -->|"changes state"| node_domain
node_catalog -->|"uses catalog"| node_materials
node_catalog -->|"manages models"| node_domain
node_categories -->|"manages categories"| node_domain
node_disposal -->|"records disposal"| node_domain
node_dashboard -.->|"reads metrics"| node_neo4j
node_rules -.->|"evaluates inventory"| node_neo4j
node_rulejob -->|"triggers evaluation"| node_rules
node_rules -->|"sends alerts"| node_admin
node_predictionjob -->|"triggers update"| node_prediction
node_prediction -->|"requests forecasts"| node_predictor
node_itemflow -.->|"uploads photos"| node_photos
node_photos -->|"stores photos"| node_gcs
node_mcp -->|"provides tools"| node_assistant
node_assistant -->|"invokes tools"| node_mcp
node_mcp -.->|"queries inventory"| node_itemflow
node_itemflow -->|"persists items"| node_neo4j
node_catalog -->|"persists catalog"| node_neo4j
node_disposal -.->|"persists records"| node_neo4j
node_mcp -.->|"uses embeddings"| node_gemini

click node_http "https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/infrastructure/http/controller"
click node_security "https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/infrastructure/security"
click node_itemflow "https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/item"
click node_catalog "https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/model"
click node_categories "https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/category"
click node_materials "https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/material"
click node_disposal "https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/disposal"
click node_domain "https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/domain/entity"
click node_dashboard "https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/dashboard"
click node_rules "https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/rule"
click node_rulejob "https://github.com/zera-interdisciplinar/ms-inventory/blob/main/src/main/java/com/zera/ms_inventory/infrastructure/job/RuleEvaluationJob.java"
click node_prediction "https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/prediction"
click node_predictionjob "https://github.com/zera-interdisciplinar/ms-inventory/blob/main/src/main/java/com/zera/ms_inventory/infrastructure/job/FailurePredictionJob.java"
click node_neo4j "https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/infrastructure/persistence/neo4j"
click node_photos "https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/infrastructure/storage"
click node_mcp "https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/infrastructure/mcp/tools"

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_http,node_security,node_user toneBlue
class node_itemflow,node_catalog,node_categories,node_materials,node_disposal,node_domain,node_gcs toneAmber
class node_dashboard,node_rules,node_rulejob,node_prediction,node_predictionjob toneMint
class node_neo4j,node_photos toneRose
class node_mcp,node_admin,node_predictor,node_assistant,node_gemini toneIndigo
```

## Components

### API and access

- [HTTP controllers](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/infrastructure/http/controller): `src/main/java/com/zera/ms_inventory/infrastructure/http/controller`
- [JWT authorization](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/infrastructure/security): `src/main/java/com/zera/ms_inventory/infrastructure/security`

### Inventory domain

- [Item lifecycle](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/item): `src/main/java/com/zera/ms_inventory/core/usecase/item`
- [Catalog management](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/model): `src/main/java/com/zera/ms_inventory/core/usecase/model`
- [Categories](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/category): `src/main/java/com/zera/ms_inventory/core/usecase/category`
- [Material catalog](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/material): `src/main/java/com/zera/ms_inventory/core/usecase/material`
- [Disposal records](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/disposal): `src/main/java/com/zera/ms_inventory/core/usecase/disposal`
- [Domain entities](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/domain/entity): `src/main/java/com/zera/ms_inventory/core/domain/entity`

### Operational insights

- [Dashboard metrics](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/dashboard): `src/main/java/com/zera/ms_inventory/core/usecase/dashboard`
- [Rules and alerts](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/rule): `src/main/java/com/zera/ms_inventory/core/usecase/rule`
- [Rule evaluation job](https://github.com/zera-interdisciplinar/ms-inventory/blob/main/src/main/java/com/zera/ms_inventory/infrastructure/job/RuleEvaluationJob.java): `src/main/java/com/zera/ms_inventory/infrastructure/job/RuleEvaluationJob.java`
- [Failure prediction](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/core/usecase/prediction): `src/main/java/com/zera/ms_inventory/core/usecase/prediction`
- [Prediction job](https://github.com/zera-interdisciplinar/ms-inventory/blob/main/src/main/java/com/zera/ms_inventory/infrastructure/job/FailurePredictionJob.java): `src/main/java/com/zera/ms_inventory/infrastructure/job/FailurePredictionJob.java`

### Infrastructure adapters

- [Neo4j persistence](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/infrastructure/persistence/neo4j): `src/main/java/com/zera/ms_inventory/infrastructure/persistence/neo4j`
- [Photo storage](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/infrastructure/storage): `src/main/java/com/zera/ms_inventory/infrastructure/storage`

### Assistant interface

- [MCP tools](https://github.com/zera-interdisciplinar/ms-inventory/tree/main/src/main/java/com/zera/ms_inventory/infrastructure/mcp/tools): `src/main/java/com/zera/ms_inventory/infrastructure/mcp/tools`

### Other components

- **Authenticated user**
- **Google Cloud Storage**
- **Administrative core**
- **Prediction service**
- **AI assistant**
- **Gemini embeddings**

## Connections

- Authenticated user → HTTP controllers: calls API (evidence: `README.md`)
- HTTP controllers → JWT authorization: authorizes (evidence: `README.md`)
- HTTP controllers → Item lifecycle: dispatches (evidence: `src/main/java/com/zera/ms_inventory/infrastructure/http/controller/ItemController.java`)
- HTTP controllers → Catalog management: dispatches (evidence: `src/main/java/com/zera/ms_inventory/infrastructure/http/controller/ModelController.java`)
- HTTP controllers → Categories: dispatches (evidence: `README.md`)
- HTTP controllers → Disposal records: dispatches (evidence: `README.md`)
- HTTP controllers → Dashboard metrics: dispatches (evidence: `README.md`)
- HTTP controllers → Rules and alerts: dispatches (evidence: `README.md`)
- HTTP controllers → Failure prediction: dispatches
- Item lifecycle → Domain entities: changes state (evidence: `README.md`)
- Catalog management → Material catalog: uses catalog (evidence: `README.md`)
- Catalog management → Domain entities: manages models (evidence: `README.md`)
- Categories → Domain entities: manages categories (evidence: `README.md`)
- Disposal records → Domain entities: records disposal (evidence: `README.md`)
- Dashboard metrics → Neo4j persistence: reads metrics
- Rules and alerts → Neo4j persistence: evaluates inventory
- Rule evaluation job → Rules and alerts: triggers evaluation (evidence: `README.md`)
- Rules and alerts → Administrative core: sends alerts (evidence: `README.md`)
- Prediction job → Failure prediction: triggers update (evidence: `README.md`)
- Failure prediction → Prediction service: requests forecasts (evidence: `README.md`)
- Item lifecycle → Photo storage: uploads photos
- Photo storage → Google Cloud Storage: stores photos (evidence: `src/main/java/com/zera/ms_inventory/infrastructure/storage/GcsPhotoStorage.java`)
- MCP tools → AI assistant: provides tools (evidence: `README.md`)
- AI assistant → MCP tools: invokes tools (evidence: `README.md`)
- MCP tools → Item lifecycle: queries inventory (evidence: `src/main/java/com/zera/ms_inventory/infrastructure/mcp/tools/SearchInventoryTool.java`)
- Item lifecycle → Neo4j persistence: persists items (evidence: `README.md`)
- Catalog management → Neo4j persistence: persists catalog (evidence: `README.md`)
- Disposal records → Neo4j persistence: persists records
- MCP tools → Gemini embeddings: uses embeddings
