# mr-mtd/springboot_mcp_orchestrator architecture

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

- Interactive diagram: https://gitdiagram.com/mr-mtd/springboot_mcp_orchestrator
- Repository: https://github.com/mr-mtd/springboot_mcp_orchestrator

## Overview

This is a Spring Boot chat API that lets a React client ask natural-language questions answered using tools exposed by a transport MCP server. The request flows through the chat endpoint and ChatService, which maintains conversation context, consults the model, and supplies metered MCP tool callbacks; the reply includes the answer, tool-call details, and token usage. The README documents the model/tool interaction and operational capabilities. Some configuration and integrations are represented from documentation and the source index, not inspected implementation excerpts.

Main entry points: [`src/main/java/io/github/mrmtd/orchestrator/service/ChatService.java`](https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/service/ChatService.java) (Chat service), [`src/main/java/io/github/mrmtd/orchestrator/controller/ChatController.java`](https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/controller/ChatController.java) (Chat endpoint), [`src/main/java/io/github/mrmtd/orchestrator/mcp/MeteredToolCallback.java`](https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/mcp/MeteredToolCallback.java) (Metered callbacks), [`src/main/java/io/github/mrmtd/orchestrator/exception`](https://github.com/mr-mtd/springboot_mcp_orchestrator/tree/main/src/main/java/io/github/mrmtd/orchestrator/exception) (Service exceptions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and HTTP"]
  node_endpoint["Chat endpoint"]
  node_payloads["Chat payloads"]
  node_cors["CORS policy<br/>[CorsConfig.java]"]
  node_requestid["Request IDs"]
  node_app["Application startup"]
  node_openapi["OpenAPI docs<br/>[OpenApiConfig.java]"]
end

subgraph group_chat["Chat orchestration"]
  node_service["Chat service<br/>[ChatService.java]"]
  node_chatconfig["Chat client setup"]
  node_memory[("Session memory")]
  node_metered["Metered callbacks"]
end

subgraph group_integrations["External services"]
  node_openai{{"OpenAI API"}}
  node_mcp{{"Transport MCP server"}}
end

subgraph group_operations["Errors and telemetry"]
  node_errors["Problem responses"]
  node_exceptions["Service exceptions"]
  node_metrics["Chat and tool metrics<br/>[ChatService.java]"]
end

node_client(("React client"))

node_client -->|"posts chat"| node_endpoint
node_endpoint -->|"accepts and returns"| node_payloads
node_endpoint -->|"delegates chat"| node_service
node_endpoint -->|"returns reply"| node_client
node_cors -->|"allows browser"| node_client
node_requestid -.->|"filters requests"| node_endpoint
node_service -.->|"uses chat client"| node_chatconfig
node_service -->|"keeps session"| node_memory
node_service -->|"sends prompt"| node_openai
node_openai -->|"returns answer or tools"| node_service
node_service -->|"wraps tool callbacks"| node_metered
node_metered -->|"calls MCP tools"| node_mcp
node_mcp -->|"returns tool results"| node_metered
node_service -->|"raises failures"| node_exceptions
node_errors -->|"maps exceptions"| node_exceptions
node_service -->|"records chat metrics"| node_metrics
node_metered -->|"records tool metrics"| node_metrics

click node_endpoint "https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/controller/ChatController.java"
click node_payloads "https://github.com/mr-mtd/springboot_mcp_orchestrator/tree/main/src/main/java/io/github/mrmtd/orchestrator/model"
click node_cors "https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/config/CorsConfig.java"
click node_requestid "https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/filter/RequestIdFilter.java"
click node_service "https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/service/ChatService.java"
click node_chatconfig "https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/config/ChatClientConfig.java"
click node_memory "https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/config/ChatClientConfig.java"
click node_metered "https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/mcp/MeteredToolCallback.java"
click node_errors "https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/exception/GlobalExceptionHandler.java"
click node_exceptions "https://github.com/mr-mtd/springboot_mcp_orchestrator/tree/main/src/main/java/io/github/mrmtd/orchestrator/exception"
click node_metrics "https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/service/ChatService.java"
click node_app "https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/OrchestratorApplication.java"
click node_openapi "https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/config/OpenApiConfig.java"

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_endpoint,node_payloads,node_cors,node_requestid,node_app,node_openapi,node_client toneBlue
class node_service,node_chatconfig,node_memory,node_metered toneAmber
class node_openai,node_mcp toneMint
class node_errors,node_exceptions,node_metrics toneRose
```

## Components

### API and HTTP

- [Chat endpoint](https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/controller/ChatController.java): `src/main/java/io/github/mrmtd/orchestrator/controller/ChatController.java`
- [Chat payloads](https://github.com/mr-mtd/springboot_mcp_orchestrator/tree/main/src/main/java/io/github/mrmtd/orchestrator/model): `src/main/java/io/github/mrmtd/orchestrator/model`
- [CORS policy](https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/config/CorsConfig.java): `src/main/java/io/github/mrmtd/orchestrator/config/CorsConfig.java`
- [Request IDs](https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/filter/RequestIdFilter.java): `src/main/java/io/github/mrmtd/orchestrator/filter/RequestIdFilter.java`
- [Application startup](https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/OrchestratorApplication.java): `src/main/java/io/github/mrmtd/orchestrator/OrchestratorApplication.java`
- [OpenAPI docs](https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/config/OpenApiConfig.java): `src/main/java/io/github/mrmtd/orchestrator/config/OpenApiConfig.java`

### Chat orchestration

- [Chat service](https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/service/ChatService.java): `src/main/java/io/github/mrmtd/orchestrator/service/ChatService.java`
- [Chat client setup](https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/config/ChatClientConfig.java): `src/main/java/io/github/mrmtd/orchestrator/config/ChatClientConfig.java`
- [Session memory](https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/config/ChatClientConfig.java): `src/main/java/io/github/mrmtd/orchestrator/config/ChatClientConfig.java`
- [Metered callbacks](https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/mcp/MeteredToolCallback.java): `src/main/java/io/github/mrmtd/orchestrator/mcp/MeteredToolCallback.java`

### External services

- **OpenAI API**
- **Transport MCP server**

### Errors and telemetry

- [Problem responses](https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/exception/GlobalExceptionHandler.java): `src/main/java/io/github/mrmtd/orchestrator/exception/GlobalExceptionHandler.java`
- [Service exceptions](https://github.com/mr-mtd/springboot_mcp_orchestrator/tree/main/src/main/java/io/github/mrmtd/orchestrator/exception): `src/main/java/io/github/mrmtd/orchestrator/exception`
- [Chat and tool metrics](https://github.com/mr-mtd/springboot_mcp_orchestrator/blob/main/src/main/java/io/github/mrmtd/orchestrator/service/ChatService.java): `src/main/java/io/github/mrmtd/orchestrator/service/ChatService.java`

### Other components

- **React client**

## Connections

- React client → Chat endpoint: posts chat (evidence: `README.md`)
- Chat endpoint → Chat payloads: accepts and returns (evidence: `src/main/java/io/github/mrmtd/orchestrator/controller/ChatController.java`)
- Chat endpoint → Chat service: delegates chat (evidence: `src/main/java/io/github/mrmtd/orchestrator/controller/ChatController.java`)
- Chat endpoint → React client: returns reply (evidence: `README.md`)
- CORS policy → React client: allows browser (evidence: `README.md`)
- Request IDs → Chat endpoint: filters requests
- Chat service → Chat client setup: uses chat client
- Chat service → Session memory: keeps session (evidence: `README.md`)
- Chat service → OpenAI API: sends prompt (evidence: `README.md`)
- OpenAI API → Chat service: returns answer or tools (evidence: `README.md`)
- Chat service → Metered callbacks: wraps tool callbacks (evidence: `src/main/java/io/github/mrmtd/orchestrator/service/ChatService.java`)
- Metered callbacks → Transport MCP server: calls MCP tools (evidence: `README.md`)
- Transport MCP server → Metered callbacks: returns tool results (evidence: `README.md`)
- Chat service → Service exceptions: raises failures (evidence: `src/main/java/io/github/mrmtd/orchestrator/service/ChatService.java`)
- Problem responses → Service exceptions: maps exceptions (evidence: `src/main/java/io/github/mrmtd/orchestrator/exception/GlobalExceptionHandler.java`)
- Chat service → Chat and tool metrics: records chat metrics (evidence: `src/main/java/io/github/mrmtd/orchestrator/service/ChatService.java`)
- Metered callbacks → Chat and tool metrics: records tool metrics (evidence: `src/main/java/io/github/mrmtd/orchestrator/mcp/MeteredToolCallback.java`)
