---
url: /architecture.md
---

# Architecture

MUCGPT uses a modern microservices architecture optimized for scalability and maintainability:

* **Frontend**: User interface layer built with React (based on a template from [Microsoft Azure](https://github.com/Azure-Samples/azure-search-openai-demo)); receives agent runs as an [AG-UI](https://docs.ag-ui.com/) event stream
* **API Gateway**: Entry point for all client requests, based on the Spring-based [RefArch gateway](https://refarch.oss.muenchen.de/gateway.html) with OAuth2/OpenID Connect
* **Core service**: LLM agent orchestration (LangGraph / Deep Agents), tool integration, document parsing, and server-side conversation persistence
* **Assistant service**: Configuration management for assistants — creation, modification, and sharing
* **PostgreSQL**: Database for persistence
* **Keycloak**: Authentication and user management

![MUCGPT architecture overview](./architecture.png){.light-only}
![MUCGPT architecture overview (dark mode)](./architecture-dark.png){.dark-only}

## Components in detail

The user talks to a Java **API gateway** that handles OpenID Connect login and token validation (single sign-on via Keycloak). Behind it, two Python **FastAPI** services split the work:

* **MUCGPT-Core** orchestrates the LLM agent with [LangGraph](https://www.langchain.com/langgraph) and Deep Agents, exposes local and MCP tools, parses uploaded documents (via Xberg), and persists conversations and canvas documents in PostgreSQL.
* **MUCGPT-Assistants** manages assistant configurations and their sharing scope, using the LDAP department tree for organizational scoping.

The core service connects to any **OpenAI-compatible LLM gateway or provider**, optional **MCP servers** for additional tools, optional **tracing** via [Langfuse](https://langfuse.com/), and an optional **document parsing service** (Xberg). Redis/Valkey serves as the cache layer for MCP tool metadata, the LDAP directory tree, and compliance verifications.

## Deep dive

Detailed runtime diagrams live in the development section: [AG-UI streaming](./development/ag-ui-streaming.md), the [Deep-Agent runtime](./development/deep-agent-runtime.md), and [Tools & MCP](./development/tools-mcp.md).
