# tensormax/internship-euron architecture

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

- Interactive diagram: https://gitdiagram.com/tensormax/internship-euron
- Repository: https://github.com/tensormax/internship-euron

## Overview

AgentX is a legal multi-agent framework whose main workflow accepts a task (or uploaded PDF), runs it asynchronously through a LangGraph workflow of specialist agents, and returns a synthesized result with pollable status and logs. The README documents specialist routing, risk hand-offs, shared memory, optional conversation history, and dynamic agent management. The graph also captures the Next.js workspace and legacy UI, plus key runtime foundations. Some orchestration internals and frontend-to-API calls were not shown; uncertain links are omitted.

Main entry points: [`agentx/app/main.py`](https://github.com/tensormax/internship-euron/blob/main/agentx/app/main.py) (FastAPI application), [`agentx/app/services/task_runner.py`](https://github.com/tensormax/internship-euron/blob/main/agentx/app/services/task_runner.py) (Task runner), [`agentx/app/orchestrator/graph.py`](https://github.com/tensormax/internship-euron/blob/main/agentx/app/orchestrator/graph.py) (Workflow graph), [`agentx/app/agents/registry.py`](https://github.com/tensormax/internship-euron/blob/main/agentx/app/agents/registry.py) (Agent registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_workspace["Next.js workspace<br/>[workspace.tsx]"]
  node_legacy["Legacy UI<br/>[app.js]"]
end

subgraph group_api["API and tasks"]
  node_app["FastAPI application<br/>[main.py]"]
  node_task_routes["Task routes<br/>[tasks.py]"]
  node_schemas["API contracts<br/>[schemas.py]"]
  node_ingestion["PDF extraction<br/>[pdf.py]"]
  node_runner["Task runner<br/>[task_runner.py]"]
  node_agent_routes["Agent management<br/>[agents.py]"]
  node_log_routes["Log routes<br/>[logs.py]"]
  node_conversation_routes["Conversation routes<br/>[conversations.py]"]
end

subgraph group_workflow["Agent workflow"]
  node_graph["Workflow graph<br/>[graph.py]"]
  node_router["Agent router<br/>[router.py]"]
  node_state_model["Workflow state<br/>[state.py]"]
  node_contract_agent["Contract review<br/>[contract_review.py]"]
  node_case_agent["Case analysis<br/>[case_analysis.py]"]
  node_risk_agent["Risk analysis<br/>[risk_analysis.py]"]
  node_agent_base["Agent base<br/>[base.py]"]
  node_registry["Agent registry<br/>[registry.py]"]
  node_synthesis["Answer synthesis<br/>[synthesis.py]"]
end

subgraph group_state["Memory and history"]
  node_memory["Memory factory<br/>[store.py]"]
  node_memory_backends[("Memory backends")]
  node_history["History service<br/>[history_service.py]"]
  node_conversation_db[("Conversation models<br/>[models.py]")]
end

subgraph group_foundation["Runtime foundations"]
  node_logging["Task logging<br/>[logging.py]"]
  node_security["API security<br/>[security.py]"]
  node_config["Settings<br/>[config.py]"]
  node_exceptions["Error handling<br/>[exceptions.py]"]
end

node_user(("Client"))
node_llm{{"OpenRouter LLM"}}

node_user -.->|"uses"| node_workspace
node_user -.->|"uses"| node_legacy
node_workspace -.->|"calls API"| node_app
node_legacy -.->|"calls API"| node_app
node_app -->|"mounts"| node_task_routes
node_app -->|"mounts"| node_agent_routes
node_app -->|"mounts"| node_log_routes
node_app -->|"mounts"| node_conversation_routes
node_task_routes -->|"extracts PDF"| node_ingestion
node_task_routes -->|"submits task"| node_runner
node_task_routes -->|"uses contracts"| node_schemas
node_runner -->|"runs workflow"| node_graph
node_runner -->|"persists prompts"| node_history
node_runner -->|"persists response"| node_history
node_graph -->|"routes agents"| node_router
node_graph -->|"updates state"| node_state_model
node_graph -->|"gets agents"| node_registry
node_graph -->|"synthesizes reports"| node_synthesis
node_graph -->|"persists context"| node_memory
node_registry -->|"registers"| node_contract_agent
node_registry -->|"registers"| node_case_agent
node_registry -->|"registers"| node_risk_agent
node_contract_agent -->|"extends"| node_agent_base
node_contract_agent -->|"requests analysis"| node_llm
node_case_agent -.->|"requests analysis"| node_llm
node_risk_agent -.->|"requests analysis"| node_llm
node_agent_base -->|"loads and saves"| node_memory
node_memory -->|"selects backend"| node_memory_backends
node_synthesis -->|"requests synthesis"| node_llm
node_agent_routes -->|"manages agents"| node_registry
node_agent_routes -->|"rebuilds graph"| node_graph
node_log_routes -->|"reads task logs"| node_runner
node_runner -->|"captures events"| node_logging
node_conversation_routes -->|"reads and writes"| node_history
node_history -->|"persists records"| node_conversation_db
node_app -->|"creates store"| node_memory
node_app -->|"seeds agents"| node_registry
node_app -->|"initializes service"| node_history
node_app -->|"creates runner"| node_runner
node_app -->|"configures security"| node_security
node_security -->|"reads settings"| node_config
node_logging -->|"reads settings"| node_config
node_app -->|"registers handlers"| node_exceptions
node_runner -->|"uses contracts"| node_schemas
node_memory -->|"uses records"| node_schemas

click node_workspace "https://github.com/tensormax/internship-euron/blob/main/agentx/frontend/components/agentx/workspace.tsx"
click node_legacy "https://github.com/tensormax/internship-euron/blob/main/agentx/web/app.js"
click node_app "https://github.com/tensormax/internship-euron/blob/main/agentx/app/main.py"
click node_task_routes "https://github.com/tensormax/internship-euron/blob/main/agentx/app/api/routes/tasks.py"
click node_schemas "https://github.com/tensormax/internship-euron/blob/main/agentx/app/api/schemas.py"
click node_ingestion "https://github.com/tensormax/internship-euron/blob/main/agentx/app/ingestion/pdf.py"
click node_runner "https://github.com/tensormax/internship-euron/blob/main/agentx/app/services/task_runner.py"
click node_agent_routes "https://github.com/tensormax/internship-euron/blob/main/agentx/app/api/routes/agents.py"
click node_log_routes "https://github.com/tensormax/internship-euron/blob/main/agentx/app/api/routes/logs.py"
click node_conversation_routes "https://github.com/tensormax/internship-euron/blob/main/agentx/app/api/routes/conversations.py"
click node_graph "https://github.com/tensormax/internship-euron/blob/main/agentx/app/orchestrator/graph.py"
click node_router "https://github.com/tensormax/internship-euron/blob/main/agentx/app/orchestrator/router.py"
click node_state_model "https://github.com/tensormax/internship-euron/blob/main/agentx/app/orchestrator/state.py"
click node_contract_agent "https://github.com/tensormax/internship-euron/blob/main/agentx/app/agents/contract_review.py"
click node_case_agent "https://github.com/tensormax/internship-euron/blob/main/agentx/app/agents/case_analysis.py"
click node_risk_agent "https://github.com/tensormax/internship-euron/blob/main/agentx/app/agents/risk_analysis.py"
click node_agent_base "https://github.com/tensormax/internship-euron/blob/main/agentx/app/agents/base.py"
click node_registry "https://github.com/tensormax/internship-euron/blob/main/agentx/app/agents/registry.py"
click node_synthesis "https://github.com/tensormax/internship-euron/blob/main/agentx/app/orchestrator/synthesis.py"
click node_memory "https://github.com/tensormax/internship-euron/blob/main/agentx/app/memory/store.py"
click node_memory_backends "https://github.com/tensormax/internship-euron/tree/main/agentx/app/memory/backends"
click node_history "https://github.com/tensormax/internship-euron/blob/main/agentx/app/services/history_service.py"
click node_conversation_db "https://github.com/tensormax/internship-euron/blob/main/agentx/app/db/models.py"
click node_logging "https://github.com/tensormax/internship-euron/blob/main/agentx/app/core/logging.py"
click node_security "https://github.com/tensormax/internship-euron/blob/main/agentx/app/core/security.py"
click node_config "https://github.com/tensormax/internship-euron/blob/main/agentx/app/config.py"
click node_exceptions "https://github.com/tensormax/internship-euron/blob/main/agentx/app/core/exceptions.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_legacy,node_user toneBlue
class node_app,node_task_routes,node_schemas,node_ingestion,node_runner,node_agent_routes,node_log_routes,node_conversation_routes toneAmber
class node_graph,node_router,node_state_model,node_contract_agent,node_case_agent,node_risk_agent,node_agent_base,node_registry,node_synthesis,node_llm toneMint
class node_memory,node_memory_backends,node_history,node_conversation_db toneRose
class node_logging,node_security,node_config,node_exceptions toneIndigo
```

## Components

### User interfaces

- [Next.js workspace](https://github.com/tensormax/internship-euron/blob/main/agentx/frontend/components/agentx/workspace.tsx): `agentx/frontend/components/agentx/workspace.tsx`
- [Legacy UI](https://github.com/tensormax/internship-euron/blob/main/agentx/web/app.js): `agentx/web/app.js`

### API and tasks

- [FastAPI application](https://github.com/tensormax/internship-euron/blob/main/agentx/app/main.py): `agentx/app/main.py`
- [Task routes](https://github.com/tensormax/internship-euron/blob/main/agentx/app/api/routes/tasks.py): `agentx/app/api/routes/tasks.py`
- [API contracts](https://github.com/tensormax/internship-euron/blob/main/agentx/app/api/schemas.py): `agentx/app/api/schemas.py`
- [PDF extraction](https://github.com/tensormax/internship-euron/blob/main/agentx/app/ingestion/pdf.py): `agentx/app/ingestion/pdf.py`
- [Task runner](https://github.com/tensormax/internship-euron/blob/main/agentx/app/services/task_runner.py): `agentx/app/services/task_runner.py`
- [Agent management](https://github.com/tensormax/internship-euron/blob/main/agentx/app/api/routes/agents.py): `agentx/app/api/routes/agents.py`
- [Log routes](https://github.com/tensormax/internship-euron/blob/main/agentx/app/api/routes/logs.py): `agentx/app/api/routes/logs.py`
- [Conversation routes](https://github.com/tensormax/internship-euron/blob/main/agentx/app/api/routes/conversations.py): `agentx/app/api/routes/conversations.py`

### Agent workflow

- [Workflow graph](https://github.com/tensormax/internship-euron/blob/main/agentx/app/orchestrator/graph.py): `agentx/app/orchestrator/graph.py`
- [Agent router](https://github.com/tensormax/internship-euron/blob/main/agentx/app/orchestrator/router.py): `agentx/app/orchestrator/router.py`
- [Workflow state](https://github.com/tensormax/internship-euron/blob/main/agentx/app/orchestrator/state.py): `agentx/app/orchestrator/state.py`
- [Contract review](https://github.com/tensormax/internship-euron/blob/main/agentx/app/agents/contract_review.py): `agentx/app/agents/contract_review.py`
- [Case analysis](https://github.com/tensormax/internship-euron/blob/main/agentx/app/agents/case_analysis.py): `agentx/app/agents/case_analysis.py`
- [Risk analysis](https://github.com/tensormax/internship-euron/blob/main/agentx/app/agents/risk_analysis.py): `agentx/app/agents/risk_analysis.py`
- [Agent base](https://github.com/tensormax/internship-euron/blob/main/agentx/app/agents/base.py): `agentx/app/agents/base.py`
- [Agent registry](https://github.com/tensormax/internship-euron/blob/main/agentx/app/agents/registry.py): `agentx/app/agents/registry.py`
- [Answer synthesis](https://github.com/tensormax/internship-euron/blob/main/agentx/app/orchestrator/synthesis.py): `agentx/app/orchestrator/synthesis.py`

### Memory and history

- [Memory factory](https://github.com/tensormax/internship-euron/blob/main/agentx/app/memory/store.py): `agentx/app/memory/store.py`
- [Memory backends](https://github.com/tensormax/internship-euron/tree/main/agentx/app/memory/backends): `agentx/app/memory/backends`
- [History service](https://github.com/tensormax/internship-euron/blob/main/agentx/app/services/history_service.py): `agentx/app/services/history_service.py`
- [Conversation models](https://github.com/tensormax/internship-euron/blob/main/agentx/app/db/models.py): `agentx/app/db/models.py`

### Runtime foundations

- [Task logging](https://github.com/tensormax/internship-euron/blob/main/agentx/app/core/logging.py): `agentx/app/core/logging.py`
- [API security](https://github.com/tensormax/internship-euron/blob/main/agentx/app/core/security.py): `agentx/app/core/security.py`
- [Settings](https://github.com/tensormax/internship-euron/blob/main/agentx/app/config.py): `agentx/app/config.py`
- [Error handling](https://github.com/tensormax/internship-euron/blob/main/agentx/app/core/exceptions.py): `agentx/app/core/exceptions.py`

### Other components

- **Client**
- **OpenRouter LLM**

## Connections

- Client → Next.js workspace: uses
- Client → Legacy UI: uses
- Next.js workspace → FastAPI application: calls API
- Legacy UI → FastAPI application: calls API
- FastAPI application → Task routes: mounts (evidence: `agentx/app/main.py`)
- FastAPI application → Agent management: mounts (evidence: `agentx/app/main.py`)
- FastAPI application → Log routes: mounts (evidence: `agentx/app/main.py`)
- FastAPI application → Conversation routes: mounts (evidence: `agentx/app/main.py`)
- Task routes → PDF extraction: extracts PDF (evidence: `agentx/app/api/routes/tasks.py`)
- Task routes → Task runner: submits task (evidence: `agentx/app/api/routes/tasks.py`)
- Task routes → API contracts: uses contracts (evidence: `agentx/app/api/routes/tasks.py`)
- Task runner → Workflow graph: runs workflow (evidence: `agentx/app/services/task_runner.py`)
- Task runner → History service: persists prompts (evidence: `agentx/app/services/task_runner.py`)
- Task runner → History service: persists response (evidence: `agentx/app/services/task_runner.py`)
- Workflow graph → Agent router: routes agents (evidence: `agentx/app/orchestrator/graph.py`)
- Workflow graph → Workflow state: updates state (evidence: `agentx/app/orchestrator/graph.py`)
- Workflow graph → Agent registry: gets agents (evidence: `agentx/app/orchestrator/graph.py`)
- Workflow graph → Answer synthesis: synthesizes reports (evidence: `README.md`)
- Workflow graph → Memory factory: persists context (evidence: `README.md`)
- Agent registry → Contract review: registers (evidence: `agentx/scripts/seed_agents.py`)
- Agent registry → Case analysis: registers (evidence: `agentx/scripts/seed_agents.py`)
- Agent registry → Risk analysis: registers (evidence: `agentx/scripts/seed_agents.py`)
- Contract review → Agent base: extends (evidence: `agentx/app/agents/contract_review.py`)
- Contract review → OpenRouter LLM: requests analysis (evidence: `agentx/app/agents/contract_review.py`)
- Case analysis → OpenRouter LLM: requests analysis
- Risk analysis → OpenRouter LLM: requests analysis
- Agent base → Memory factory: loads and saves (evidence: `agentx/app/agents/base.py`)
- Memory factory → Memory backends: selects backend (evidence: `agentx/app/memory/store.py`)
- Answer synthesis → OpenRouter LLM: requests synthesis (evidence: `agentx/app/orchestrator/synthesis.py`)
- Agent management → Agent registry: manages agents (evidence: `agentx/app/api/routes/agents.py`)
- Agent management → Workflow graph: rebuilds graph (evidence: `agentx/app/api/routes/agents.py`)
- Log routes → Task runner: reads task logs (evidence: `agentx/app/api/routes/logs.py`)
- Task runner → Task logging: captures events (evidence: `README.md`)
- Conversation routes → History service: reads and writes (evidence: `agentx/app/api/routes/conversations.py`)
- History service → Conversation models: persists records (evidence: `agentx/app/services/history_service.py`)
- FastAPI application → Memory factory: creates store (evidence: `agentx/app/main.py`)
- FastAPI application → Agent registry: seeds agents (evidence: `agentx/app/main.py`)
- FastAPI application → History service: initializes service (evidence: `agentx/app/main.py`)
- FastAPI application → Task runner: creates runner (evidence: `agentx/app/main.py`)
- FastAPI application → API security: configures security (evidence: `agentx/app/main.py`)
- API security → Settings: reads settings (evidence: `agentx/app/core/security.py`)
- Task logging → Settings: reads settings (evidence: `agentx/app/core/logging.py`)
- FastAPI application → Error handling: registers handlers (evidence: `agentx/app/main.py`)
- Task runner → API contracts: uses contracts (evidence: `agentx/app/services/task_runner.py`)
- Memory factory → API contracts: uses records (evidence: `agentx/app/memory/store.py`)
