# zera-interdisciplinar/ms-artificial-intelligence-core architecture

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

- Interactive diagram: https://gitdiagram.com/zera-interdisciplinar/ms-artificial-intelligence-core
- Repository: https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core

## Overview

Zera is a multi-agent assistant for electronic-waste management. Users submit messages through the API or optional MCP tool; the service validates unit access, hydrates conversation state, routes work to specialist agents, and returns a guarded response. Other documented capabilities include FAQ and inventory queries, equipment-failure predictions, disposal reports, conversation history, preferences, and PDF storage. The excerpts show the API, service setup, and some agent behavior; several specialist implementations and storage adapters are unsampled, so their links are limited to indexed references or omitted where uncertain.

Main entry points: [`multi_agent/service.py`](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/service.py) (Multi-agent service), [`multi_agent/graph.py`](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/graph.py) (Agent graph), [`_internal/mcp/server.py`](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/_internal/mcp/server.py) (MCP server), [`_internal/api/router.py`](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/_internal/api/router.py) (HTTP API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API and access"]
  node_api["HTTP API<br/>[router.py]"]
  node_handlers["Message handlers"]
  node_mcp["MCP server<br/>[server.py]"]
  node_auth["Bearer authorization<br/>[auth.py]"]
end

subgraph group_core["Conversation runtime"]
  node_service["Multi-agent service<br/>[service.py]"]
  node_graph["Agent graph<br/>[graph.py]"]
end

subgraph group_specialists["Specialist agents"]
  node_orchestrator["Intent routing<br/>[orchestrator.py]"]
  node_guardrail["Input / output guardrails<br/>[guardrail.py]"]
  node_faq["FAQ answers<br/>[faq.py]"]
  node_inventory["Inventory lookup<br/>[inventory.py]"]
  node_prediction["Failure prediction<br/>[predict_model.py]"]
  node_report["Disposal reports<br/>[report.py]"]
  node_formatter["Response formatting<br/>[formatter.py]"]
  node_judge["Answer review<br/>[judge.py]"]
end

subgraph group_persistence["State and reports"]
  node_repository[("Conversation repository<br/>[multi_agent.py]")]
  node_checkpoint[("Redis checkpoints")]
  node_pdf["PDF renderer<br/>[pdf.py]"]
  node_storage["PDF storage<br/>[service.py]"]
end

subgraph group_integrations["External services"]
  node_admin["Admin Core"]
  node_inventorysvc["Inventory service"]
  node_predictsvc["Prediction service"]
end

node_user(("User / host"))

node_user -->|"submits request"| node_api
node_api -->|"routes requests"| node_handlers
node_handlers -->|"processes messages"| node_service
node_user -->|"calls tool"| node_mcp
node_mcp -->|"checks bearer"| node_auth
node_mcp -->|"processes message"| node_service
node_service -->|"resolves user unit"| node_admin
node_service -->|"reads and writes history"| node_repository
node_service -.->|"persists thread state"| node_checkpoint
node_service -->|"builds and invokes"| node_graph
node_graph -->|"dispatches route"| node_orchestrator
node_graph -->|"dispatches agent"| node_inventory
node_graph -->|"dispatches review"| node_judge
node_service -->|"sets up agents"| node_guardrail
node_service -->|"sets up agent"| node_faq
node_service -->|"sets up agent"| node_inventory
node_service -->|"sets up agent"| node_prediction
node_service -->|"sets up agent"| node_report
node_service -->|"sets up agent"| node_formatter
node_service -->|"sets up agent"| node_judge
node_service -.->|"queries inventory"| node_inventorysvc
node_service -.->|"requests predictions"| node_predictsvc
node_service -->|"renders report PDF"| node_pdf
node_service -->|"stores report"| node_storage
node_storage -->|"uses renderer"| node_pdf

click node_api "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/_internal/api/router.py"
click node_handlers "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/_internal/api/multi_agent_handlers.py"
click node_mcp "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/_internal/mcp/server.py"
click node_auth "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/_internal/mcp/auth.py"
click node_service "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/service.py"
click node_graph "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/graph.py"
click node_orchestrator "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/agents/orchestrator.py"
click node_guardrail "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/agents/guardrail.py"
click node_faq "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/agents/faq.py"
click node_inventory "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/agents/inventory.py"
click node_prediction "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/agents/predict_model.py"
click node_report "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/agents/report.py"
click node_formatter "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/agents/formatter.py"
click node_judge "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/agents/judge.py"
click node_repository "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/repository/multi_agent.py"
click node_checkpoint "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/async_redis_saver.py"
click node_pdf "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/_internal/storage/pdf.py"
click node_storage "https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/_internal/storage/service.py"

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_api,node_handlers,node_mcp,node_auth,node_user toneBlue
class node_service,node_graph toneAmber
class node_orchestrator,node_guardrail,node_faq,node_inventory,node_prediction,node_report,node_formatter,node_judge toneMint
class node_repository,node_checkpoint,node_pdf,node_storage toneRose
class node_admin,node_inventorysvc,node_predictsvc toneIndigo
```

## Components

### API and access

- [HTTP API](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/_internal/api/router.py): `_internal/api/router.py`
- [Message handlers](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/_internal/api/multi_agent_handlers.py): `_internal/api/multi_agent_handlers.py`
- [MCP server](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/_internal/mcp/server.py): `_internal/mcp/server.py`
- [Bearer authorization](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/_internal/mcp/auth.py): `_internal/mcp/auth.py`

### Conversation runtime

- [Multi-agent service](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/service.py): `multi_agent/service.py`
- [Agent graph](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/graph.py): `multi_agent/graph.py`

### Specialist agents

- [Intent routing](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/agents/orchestrator.py): `multi_agent/agents/orchestrator.py`
- [Input / output guardrails](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/agents/guardrail.py): `multi_agent/agents/guardrail.py`
- [FAQ answers](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/agents/faq.py): `multi_agent/agents/faq.py`
- [Inventory lookup](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/agents/inventory.py): `multi_agent/agents/inventory.py`
- [Failure prediction](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/agents/predict_model.py): `multi_agent/agents/predict_model.py`
- [Disposal reports](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/agents/report.py): `multi_agent/agents/report.py`
- [Response formatting](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/agents/formatter.py): `multi_agent/agents/formatter.py`
- [Answer review](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/agents/judge.py): `multi_agent/agents/judge.py`

### State and reports

- [Conversation repository](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/repository/multi_agent.py): `repository/multi_agent.py`
- [Redis checkpoints](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/multi_agent/async_redis_saver.py): `multi_agent/async_redis_saver.py`
- [PDF renderer](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/_internal/storage/pdf.py): `_internal/storage/pdf.py`
- [PDF storage](https://github.com/zera-interdisciplinar/ms-artificial-intelligence-core/blob/main/_internal/storage/service.py): `_internal/storage/service.py`

### External services

- **Admin Core**
- **Inventory service**
- **Prediction service**

### Other components

- **User / host**

## Connections

- User / host → HTTP API: submits request (evidence: `_internal/api/router.py`)
- HTTP API → Message handlers: routes requests (evidence: `_internal/api/router.py`)
- Message handlers → Multi-agent service: processes messages (evidence: `_internal/api/multi_agent_handlers.py`)
- User / host → MCP server: calls tool (evidence: `_internal/mcp/server.py`)
- MCP server → Bearer authorization: checks bearer (evidence: `_internal/mcp/server.py`)
- MCP server → Multi-agent service: processes message (evidence: `_internal/mcp/server.py`)
- Multi-agent service → Admin Core: resolves user unit (evidence: `multi_agent/service.py`)
- Multi-agent service → Conversation repository: reads and writes history (evidence: `multi_agent/service.py`)
- Multi-agent service → Redis checkpoints: persists thread state
- Multi-agent service → Agent graph: builds and invokes (evidence: `multi_agent/service.py`)
- Agent graph → Intent routing: dispatches route (evidence: `multi_agent/graph.py`)
- Agent graph → Inventory lookup: dispatches agent (evidence: `multi_agent/graph.py`)
- Agent graph → Answer review: dispatches review (evidence: `multi_agent/graph.py`)
- Multi-agent service → Input / output guardrails: sets up agents (evidence: `multi_agent/service.py`)
- Multi-agent service → FAQ answers: sets up agent (evidence: `multi_agent/service.py`)
- Multi-agent service → Inventory lookup: sets up agent (evidence: `multi_agent/service.py`)
- Multi-agent service → Failure prediction: sets up agent (evidence: `multi_agent/service.py`)
- Multi-agent service → Disposal reports: sets up agent (evidence: `multi_agent/service.py`)
- Multi-agent service → Response formatting: sets up agent (evidence: `multi_agent/service.py`)
- Multi-agent service → Answer review: sets up agent (evidence: `multi_agent/service.py`)
- Multi-agent service → Inventory service: queries inventory
- Multi-agent service → Prediction service: requests predictions
- Multi-agent service → PDF renderer: renders report PDF (evidence: `multi_agent/service.py`)
- Multi-agent service → PDF storage: stores report (evidence: `multi_agent/service.py`)
- PDF storage → PDF renderer: uses renderer (evidence: `_internal/storage/service.py`)
