# acerolaz/agentinsurflow architecture

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

- Interactive diagram: https://gitdiagram.com/acerolaz/agentinsurflow
- Repository: https://github.com/acerolaz/agentinsurflow

## Overview

AgentInsurFlow is an automotive-insurance casework assistant exposed through a single public gateway. A manager uses the gateway’s workspace to start and review a deterministic agent-cluster evaluation; the cluster uses MCP tools for case data, risk/price calculations, and cited insurance-law answers, then saves a draft for human review. Separate RAG ingestion and underwriting administration support that workflow, alongside trace and checkpoint storage. The README documents the service boundaries and capabilities; sampled files confirm selected wiring, but unsampled runtime links are shown only where documented.

Main entry points: [`gateway/src/AgentInsurFlow.Gateway.Api/Program.cs`](https://github.com/acerolaz/agentinsurflow/blob/main/gateway/src/AgentInsurFlow.Gateway.Api/Program.cs) (Public gateway), [`agentic-cluster/agentinsurflow_cluster/application/agents.py`](https://github.com/acerolaz/agentinsurflow/blob/main/agentic-cluster/agentinsurflow_cluster/application/agents.py) (Saga and agents), [`serveur-mcp/agentinsurflow_mcp/application/outils.py`](https://github.com/acerolaz/agentinsurflow/blob/main/serveur-mcp/agentinsurflow_mcp/application/outils.py) (MCP tool server), [`rag/agentinsurflow_rag/api/app.py`](https://github.com/acerolaz/agentinsurflow/blob/main/rag/agentinsurflow_rag/api/app.py) (RAG API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public access"]
  node_workspace["Manager workspace<br/>[app.js]"]
  node_gateway["Public gateway<br/>[Program.cs]"]
end

subgraph group_agents["Agent evaluation"]
  node_cluster_api["Cluster API<br/>[routes.py]"]
  node_saga["Saga and agents<br/>[agents.py]"]
  node_checkpoint[("Saga checkpoints<br/>[checkpoint.py]")]
end

subgraph group_knowledge["Legal knowledge"]
  node_rag_api["RAG API<br/>[app.py]"]
  node_rag_search["Cited-answer search<br/>[repondre.py]"]
  node_ingestion["Corpus ingestion<br/>[ingest.py]"]
  node_corpus_db[("Corpus database<br/>[corpus.py]")]
end

subgraph group_casework["Case administration"]
  node_admin_api["Underwriting administration<br/>[Program.cs]"]
  node_case_db[("Case records")]
  node_trace_db[("Trace repository")]
end

subgraph group_integrations["Tools and integrations"]
  node_mcp["MCP tool server<br/>[outils.py]"]
  node_legifrance["Légifrance<br/>[client.py]"]
  node_calc["Risk and premium calculation<br/>[function_app.py]"]
  node_foundry["Azure AI Foundry"]
end

node_manager(("Insurance manager"))

node_manager -->|"uses"| node_workspace
node_workspace -->|"sends requests"| node_gateway
node_gateway -->|"routes requests"| node_cluster_api
node_gateway -->|"routes requests"| node_rag_api
node_gateway -->|"routes requests"| node_admin_api
node_cluster_api -->|"starts or resumes"| node_saga
node_saga -->|"saves state"| node_checkpoint
node_saga -->|"calls tools"| node_mcp
node_saga -->|"requests drafting"| node_foundry
node_mcp -->|"searches law"| node_rag_api
node_mcp -->|"writes case draft"| node_admin_api
node_mcp -->|"requests calculation"| node_calc
node_rag_api -->|"serves answers"| node_rag_search
node_ingestion -->|"fetches law"| node_legifrance
node_ingestion -->|"ingests corpus"| node_corpus_db
node_rag_search -->|"searches corpus"| node_corpus_db
node_admin_api -->|"reads and writes"| node_case_db
node_gateway -->|"exports traces"| node_trace_db

click node_workspace "https://github.com/acerolaz/agentinsurflow/blob/main/gateway/src/AgentInsurFlow.Gateway.Api/wwwroot/app/app.js"
click node_gateway "https://github.com/acerolaz/agentinsurflow/blob/main/gateway/src/AgentInsurFlow.Gateway.Api/Program.cs"
click node_cluster_api "https://github.com/acerolaz/agentinsurflow/blob/main/agentic-cluster/agentinsurflow_cluster/api/routes.py"
click node_saga "https://github.com/acerolaz/agentinsurflow/blob/main/agentic-cluster/agentinsurflow_cluster/application/agents.py"
click node_checkpoint "https://github.com/acerolaz/agentinsurflow/blob/main/agentic-cluster/agentinsurflow_cluster/infrastructure/langgraph/checkpoint.py"
click node_mcp "https://github.com/acerolaz/agentinsurflow/blob/main/serveur-mcp/agentinsurflow_mcp/application/outils.py"
click node_rag_api "https://github.com/acerolaz/agentinsurflow/blob/main/rag/agentinsurflow_rag/api/app.py"
click node_rag_search "https://github.com/acerolaz/agentinsurflow/blob/main/rag/agentinsurflow_rag/application/use_cases/repondre.py"
click node_ingestion "https://github.com/acerolaz/agentinsurflow/blob/main/rag/agentinsurflow_rag/cli/ingest.py"
click node_legifrance "https://github.com/acerolaz/agentinsurflow/blob/main/rag/agentinsurflow_rag/infrastructure/legifrance/client.py"
click node_corpus_db "https://github.com/acerolaz/agentinsurflow/blob/main/rag/agentinsurflow_rag/infrastructure/postgres/corpus.py"
click node_admin_api "https://github.com/acerolaz/agentinsurflow/blob/main/underwriting-admin/src/AgentInsurFlow.UnderwritingAdmin.Api/Program.cs"
click node_case_db "https://github.com/acerolaz/agentinsurflow/blob/main/underwriting-admin/src/AgentInsurFlow.UnderwritingAdmin.Infrastructure/Dossiers/DossiersServices.cs"
click node_trace_db "https://github.com/acerolaz/agentinsurflow/blob/main/underwriting-admin/src/AgentInsurFlow.UnderwritingAdmin.Infrastructure/Traces/ConnexionsTraces.cs"
click node_calc "https://github.com/acerolaz/agentinsurflow/blob/main/fonction-calcul/function_app.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_workspace,node_gateway toneBlue
class node_cluster_api,node_saga,node_checkpoint toneAmber
class node_rag_api,node_rag_search,node_ingestion,node_corpus_db toneMint
class node_admin_api,node_case_db,node_trace_db toneRose
class node_mcp,node_legifrance,node_calc,node_foundry,node_manager toneIndigo
```

## Components

### Public access

- [Manager workspace](https://github.com/acerolaz/agentinsurflow/blob/main/gateway/src/AgentInsurFlow.Gateway.Api/wwwroot/app/app.js): `gateway/src/AgentInsurFlow.Gateway.Api/wwwroot/app/app.js`
- [Public gateway](https://github.com/acerolaz/agentinsurflow/blob/main/gateway/src/AgentInsurFlow.Gateway.Api/Program.cs): `gateway/src/AgentInsurFlow.Gateway.Api/Program.cs`

### Agent evaluation

- [Cluster API](https://github.com/acerolaz/agentinsurflow/blob/main/agentic-cluster/agentinsurflow_cluster/api/routes.py): `agentic-cluster/agentinsurflow_cluster/api/routes.py`
- [Saga and agents](https://github.com/acerolaz/agentinsurflow/blob/main/agentic-cluster/agentinsurflow_cluster/application/agents.py): `agentic-cluster/agentinsurflow_cluster/application/agents.py`
- [Saga checkpoints](https://github.com/acerolaz/agentinsurflow/blob/main/agentic-cluster/agentinsurflow_cluster/infrastructure/langgraph/checkpoint.py): `agentic-cluster/agentinsurflow_cluster/infrastructure/langgraph/checkpoint.py`

### Legal knowledge

- [RAG API](https://github.com/acerolaz/agentinsurflow/blob/main/rag/agentinsurflow_rag/api/app.py): `rag/agentinsurflow_rag/api/app.py`
- [Cited-answer search](https://github.com/acerolaz/agentinsurflow/blob/main/rag/agentinsurflow_rag/application/use_cases/repondre.py): `rag/agentinsurflow_rag/application/use_cases/repondre.py`
- [Corpus ingestion](https://github.com/acerolaz/agentinsurflow/blob/main/rag/agentinsurflow_rag/cli/ingest.py): `rag/agentinsurflow_rag/cli/ingest.py`
- [Corpus database](https://github.com/acerolaz/agentinsurflow/blob/main/rag/agentinsurflow_rag/infrastructure/postgres/corpus.py): `rag/agentinsurflow_rag/infrastructure/postgres/corpus.py`

### Case administration

- [Underwriting administration](https://github.com/acerolaz/agentinsurflow/blob/main/underwriting-admin/src/AgentInsurFlow.UnderwritingAdmin.Api/Program.cs): `underwriting-admin/src/AgentInsurFlow.UnderwritingAdmin.Api/Program.cs`
- [Case records](https://github.com/acerolaz/agentinsurflow/blob/main/underwriting-admin/src/AgentInsurFlow.UnderwritingAdmin.Infrastructure/Dossiers/DossiersServices.cs): `underwriting-admin/src/AgentInsurFlow.UnderwritingAdmin.Infrastructure/Dossiers/DossiersServices.cs`
- [Trace repository](https://github.com/acerolaz/agentinsurflow/blob/main/underwriting-admin/src/AgentInsurFlow.UnderwritingAdmin.Infrastructure/Traces/ConnexionsTraces.cs): `underwriting-admin/src/AgentInsurFlow.UnderwritingAdmin.Infrastructure/Traces/ConnexionsTraces.cs`

### Tools and integrations

- [MCP tool server](https://github.com/acerolaz/agentinsurflow/blob/main/serveur-mcp/agentinsurflow_mcp/application/outils.py): `serveur-mcp/agentinsurflow_mcp/application/outils.py`
- [Légifrance](https://github.com/acerolaz/agentinsurflow/blob/main/rag/agentinsurflow_rag/infrastructure/legifrance/client.py): `rag/agentinsurflow_rag/infrastructure/legifrance/client.py`
- [Risk and premium calculation](https://github.com/acerolaz/agentinsurflow/blob/main/fonction-calcul/function_app.py): `fonction-calcul/function_app.py`
- **Azure AI Foundry**

### Other components

- **Insurance manager**

## Connections

- Insurance manager → Manager workspace: uses (evidence: `README.md`)
- Manager workspace → Public gateway: sends requests (evidence: `gateway/src/AgentInsurFlow.Gateway.Api/wwwroot/app/app.js`)
- Public gateway → Cluster API: routes requests (evidence: `README.md`)
- Public gateway → RAG API: routes requests (evidence: `README.md`)
- Public gateway → Underwriting administration: routes requests (evidence: `README.md`)
- Cluster API → Saga and agents: starts or resumes (evidence: `agentic-cluster/agentinsurflow_cluster/api/routes.py`)
- Saga and agents → Saga checkpoints: saves state (evidence: `agentic-cluster/agentinsurflow_cluster/api/app.py`)
- Saga and agents → MCP tool server: calls tools
- Saga and agents → Azure AI Foundry: requests drafting (evidence: `README.md`)
- MCP tool server → RAG API: searches law (evidence: `README.md`)
- MCP tool server → Underwriting administration: writes case draft (evidence: `README.md`)
- MCP tool server → Risk and premium calculation: requests calculation
- RAG API → Cited-answer search: serves answers (evidence: `rag/agentinsurflow_rag/api/app.py`)
- Corpus ingestion → Légifrance: fetches law (evidence: `rag/agentinsurflow_rag/cli/ingest.py`)
- Corpus ingestion → Corpus database: ingests corpus (evidence: `README.md`)
- Cited-answer search → Corpus database: searches corpus (evidence: `README.md`)
- Underwriting administration → Case records: reads and writes (evidence: `underwriting-admin/src/AgentInsurFlow.UnderwritingAdmin.Infrastructure/Dossiers/DossiersServices.cs`)
- Public gateway → Trace repository: exports traces (evidence: `README.md`)
