# amoylab/unla architecture

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

- Interactive diagram: https://gitdiagram.com/amoylab/unla
- Repository: https://github.com/amoylab/unla

## Overview

Unla is a Go MCP gateway with a web management UI. Operators sign in, configure tenant-scoped MCP servers and API-backed tools, and persist/version those configurations; MCP clients then invoke the gateway over SSE or Streamable HTTP, which routes configured calls to API or MCP backends and returns MCP results. The graph also captures authentication, sessions, configuration storage and synchronization, and the documented OpenAPI conversion capability. Some backend handlers and UI modules were not sampled, so uncertain implementation-level links are omitted or documented from the README.

Main entry points: [`web/src/App.tsx`](https://github.com/amoylab/unla/blob/main/web/src/App.tsx) (Management App), [`internal/core/server.go`](https://github.com/amoylab/unla/blob/main/internal/core/server.go) (MCP Server), [`cmd/apiserver/main.go`](https://github.com/amoylab/unla/blob/main/cmd/apiserver/main.go) (Management API), [`cmd/mcp-gateway/main.go`](https://github.com/amoylab/unla/blob/main/cmd/mcp-gateway/main.go) (Gateway Process)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_management["Management UI"]
  node_webapp["Management App<br/>[App.tsx]"]
  node_login["Login<br/>[login.tsx]"]
  node_gatewayui["Gateway Manager"]
  node_configeditor["Config Editor<br/>[ConfigEditor.tsx]"]
  node_openapiimport["OpenAPI Import<br/>[OpenAPIImport.tsx]"]
  node_capabilities["Capabilities Viewer<br/>[capabilities.tsx]"]
  node_versions["Config Versions"]
  node_users["User Management"]
  node_tenants["Tenant Management"]
end

subgraph group_control["Control Plane"]
  node_apiserver["Management API<br/>[main.go]"]
  node_authhandlers["Auth and Tenant Handlers<br/>[auth.go]"]
  node_oauth["OAuth Support<br/>[oauth.go]"]
end

subgraph group_runtime["MCP Runtime"]
  node_gatewayprocess["Gateway Process<br/>[main.go]"]
  node_mcpserver["MCP Server<br/>[server.go]"]
  node_toolhandler["Tool Response Handling<br/>[handler.go]"]
  node_template["Template Rendering<br/>[renderer.go]"]
end

subgraph group_persistence["Persistence"]
  node_sessions[("Session Store<br/>[session.go]")]
  node_mcpstore[("MCP Config Store<br/>[store.go]")]
  node_userdb[("User Database<br/>[database.go]")]
  node_notifier["Config Notifier<br/>[notifier.go]"]
end

subgraph group_integrations["Backend Integrations"]
  node_api["Configured APIs"]
  node_backendmcp["Existing MCP Servers"]
  node_converter["OpenAPI Converter<br/>[converter.go]"]
end

node_operator(("Operator"))
node_mcpclient(("MCP Client"))

node_operator -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_login
node_webapp -->|"routes to"| node_gatewayui
node_webapp -->|"routes to"| node_capabilities
node_webapp -->|"routes to"| node_versions
node_webapp -->|"routes to"| node_users
node_webapp -->|"routes to"| node_tenants
node_gatewayui -->|"renders"| node_configeditor
node_gatewayui -->|"renders"| node_openapiimport
node_gatewayui -->|"manages configs"| node_apiserver
node_login -.->|"authenticates"| node_apiserver
node_users -.->|"manages users"| node_apiserver
node_tenants -.->|"manages tenants"| node_apiserver
node_apiserver -->|"routes requests"| node_authhandlers
node_authhandlers -->|"reads and writes"| node_userdb
node_apiserver -->|"initializes"| node_mcpstore
node_apiserver -->|"initializes"| node_notifier
node_authhandlers -.->|"uses"| node_oauth
node_openapiimport -.->|"imports spec"| node_converter
node_operator -->|"converts spec"| node_converter
node_mcpclient -->|"invokes tools"| node_mcpserver
node_gatewayprocess -->|"starts"| node_mcpserver
node_gatewayprocess -->|"initializes"| node_mcpstore
node_gatewayprocess -->|"initializes"| node_sessions
node_gatewayprocess -->|"initializes"| node_notifier
node_mcpserver -->|"loads config"| node_mcpstore
node_mcpserver -->|"uses sessions"| node_sessions
node_mcpserver -->|"handles responses"| node_toolhandler
node_toolhandler -->|"renders templates"| node_template
node_mcpserver -->|"calls configured APIs"| node_api
node_mcpserver -->|"proxies MCP"| node_backendmcp

click node_webapp "https://github.com/amoylab/unla/blob/main/web/src/App.tsx"
click node_login "https://github.com/amoylab/unla/blob/main/web/src/pages/auth/login.tsx"
click node_gatewayui "https://github.com/amoylab/unla/blob/main/web/src/pages/gateway/gateway-manager.tsx"
click node_configeditor "https://github.com/amoylab/unla/blob/main/web/src/pages/gateway/components/ConfigEditor.tsx"
click node_openapiimport "https://github.com/amoylab/unla/blob/main/web/src/pages/gateway/components/OpenAPIImport.tsx"
click node_capabilities "https://github.com/amoylab/unla/blob/main/web/src/pages/gateway/capabilities.tsx"
click node_versions "https://github.com/amoylab/unla/blob/main/web/src/pages/gateway/config-versions.tsx"
click node_users "https://github.com/amoylab/unla/blob/main/web/src/pages/users/user-management.tsx"
click node_tenants "https://github.com/amoylab/unla/blob/main/web/src/pages/users/tenant-management.tsx"
click node_apiserver "https://github.com/amoylab/unla/blob/main/cmd/apiserver/main.go"
click node_authhandlers "https://github.com/amoylab/unla/blob/main/internal/apiserver/handler/auth.go"
click node_oauth "https://github.com/amoylab/unla/blob/main/internal/auth/oauth.go"
click node_gatewayprocess "https://github.com/amoylab/unla/blob/main/cmd/mcp-gateway/main.go"
click node_mcpserver "https://github.com/amoylab/unla/blob/main/internal/core/server.go"
click node_toolhandler "https://github.com/amoylab/unla/blob/main/internal/core/handler.go"
click node_template "https://github.com/amoylab/unla/blob/main/internal/template/renderer.go"
click node_sessions "https://github.com/amoylab/unla/blob/main/internal/mcp/session/session.go"
click node_mcpstore "https://github.com/amoylab/unla/blob/main/internal/mcp/storage/store.go"
click node_userdb "https://github.com/amoylab/unla/blob/main/internal/apiserver/database/database.go"
click node_notifier "https://github.com/amoylab/unla/blob/main/internal/mcp/storage/notifier/notifier.go"
click node_converter "https://github.com/amoylab/unla/blob/main/pkg/openapi/converter.go"

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_webapp,node_login,node_gatewayui,node_configeditor,node_openapiimport,node_capabilities,node_versions,node_users,node_tenants,node_mcpclient toneBlue
class node_apiserver,node_authhandlers,node_oauth toneAmber
class node_gatewayprocess,node_mcpserver,node_toolhandler,node_template toneMint
class node_sessions,node_mcpstore,node_userdb,node_notifier toneRose
class node_api,node_backendmcp,node_converter,node_operator toneIndigo
```

## Components

### Management UI

- [Management App](https://github.com/amoylab/unla/blob/main/web/src/App.tsx): `web/src/App.tsx`
- [Login](https://github.com/amoylab/unla/blob/main/web/src/pages/auth/login.tsx): `web/src/pages/auth/login.tsx`
- [Gateway Manager](https://github.com/amoylab/unla/blob/main/web/src/pages/gateway/gateway-manager.tsx): `web/src/pages/gateway/gateway-manager.tsx`
- [Config Editor](https://github.com/amoylab/unla/blob/main/web/src/pages/gateway/components/ConfigEditor.tsx): `web/src/pages/gateway/components/ConfigEditor.tsx`
- [OpenAPI Import](https://github.com/amoylab/unla/blob/main/web/src/pages/gateway/components/OpenAPIImport.tsx): `web/src/pages/gateway/components/OpenAPIImport.tsx`
- [Capabilities Viewer](https://github.com/amoylab/unla/blob/main/web/src/pages/gateway/capabilities.tsx): `web/src/pages/gateway/capabilities.tsx`
- [Config Versions](https://github.com/amoylab/unla/blob/main/web/src/pages/gateway/config-versions.tsx): `web/src/pages/gateway/config-versions.tsx`
- [User Management](https://github.com/amoylab/unla/blob/main/web/src/pages/users/user-management.tsx): `web/src/pages/users/user-management.tsx`
- [Tenant Management](https://github.com/amoylab/unla/blob/main/web/src/pages/users/tenant-management.tsx): `web/src/pages/users/tenant-management.tsx`

### Control Plane

- [Management API](https://github.com/amoylab/unla/blob/main/cmd/apiserver/main.go): `cmd/apiserver/main.go`
- [Auth and Tenant Handlers](https://github.com/amoylab/unla/blob/main/internal/apiserver/handler/auth.go): `internal/apiserver/handler/auth.go`
- [OAuth Support](https://github.com/amoylab/unla/blob/main/internal/auth/oauth.go): `internal/auth/oauth.go`

### MCP Runtime

- [Gateway Process](https://github.com/amoylab/unla/blob/main/cmd/mcp-gateway/main.go): `cmd/mcp-gateway/main.go`
- [MCP Server](https://github.com/amoylab/unla/blob/main/internal/core/server.go): `internal/core/server.go`
- [Tool Response Handling](https://github.com/amoylab/unla/blob/main/internal/core/handler.go): `internal/core/handler.go`
- [Template Rendering](https://github.com/amoylab/unla/blob/main/internal/template/renderer.go): `internal/template/renderer.go`

### Persistence

- [Session Store](https://github.com/amoylab/unla/blob/main/internal/mcp/session/session.go): `internal/mcp/session/session.go`
- [MCP Config Store](https://github.com/amoylab/unla/blob/main/internal/mcp/storage/store.go): `internal/mcp/storage/store.go`
- [User Database](https://github.com/amoylab/unla/blob/main/internal/apiserver/database/database.go): `internal/apiserver/database/database.go`
- [Config Notifier](https://github.com/amoylab/unla/blob/main/internal/mcp/storage/notifier/notifier.go): `internal/mcp/storage/notifier/notifier.go`

### Backend Integrations

- **Configured APIs**
- **Existing MCP Servers**
- [OpenAPI Converter](https://github.com/amoylab/unla/blob/main/pkg/openapi/converter.go): `pkg/openapi/converter.go`

### Other components

- **Operator**
- **MCP Client**

## Connections

- Operator → Management App: uses (evidence: `README.md`)
- Management App → Login: routes to (evidence: `web/src/App.tsx`)
- Management App → Gateway Manager: routes to (evidence: `web/src/App.tsx`)
- Management App → Capabilities Viewer: routes to (evidence: `web/src/App.tsx`)
- Management App → Config Versions: routes to (evidence: `web/src/App.tsx`)
- Management App → User Management: routes to (evidence: `web/src/App.tsx`)
- Management App → Tenant Management: routes to (evidence: `web/src/App.tsx`)
- Gateway Manager → Config Editor: renders (evidence: `web/src/pages/gateway/gateway-manager.tsx`)
- Gateway Manager → OpenAPI Import: renders (evidence: `web/src/pages/gateway/gateway-manager.tsx`)
- Gateway Manager → Management API: manages configs (evidence: `README.md`)
- Login → Management API: authenticates
- User Management → Management API: manages users
- Tenant Management → Management API: manages tenants
- Management API → Auth and Tenant Handlers: routes requests (evidence: `cmd/apiserver/main.go`)
- Auth and Tenant Handlers → User Database: reads and writes (evidence: `internal/apiserver/handler/auth.go`)
- Management API → MCP Config Store: initializes (evidence: `cmd/apiserver/main.go`)
- Management API → Config Notifier: initializes (evidence: `cmd/apiserver/main.go`)
- Auth and Tenant Handlers → OAuth Support: uses
- OpenAPI Import → OpenAPI Converter: imports spec
- Operator → OpenAPI Converter: converts spec (evidence: `README.md`)
- MCP Client → MCP Server: invokes tools (evidence: `README.md`)
- Gateway Process → MCP Server: starts (evidence: `cmd/mcp-gateway/main.go`)
- Gateway Process → MCP Config Store: initializes (evidence: `cmd/mcp-gateway/main.go`)
- Gateway Process → Session Store: initializes (evidence: `cmd/mcp-gateway/main.go`)
- Gateway Process → Config Notifier: initializes (evidence: `cmd/mcp-gateway/main.go`)
- MCP Server → MCP Config Store: loads config (evidence: `internal/core/server.go`)
- MCP Server → Session Store: uses sessions (evidence: `internal/core/server.go`)
- MCP Server → Tool Response Handling: handles responses (evidence: `internal/core/server.go`)
- Tool Response Handling → Template Rendering: renders templates (evidence: `internal/core/handler.go`)
- MCP Server → Configured APIs: calls configured APIs (evidence: `README.md`)
- MCP Server → Existing MCP Servers: proxies MCP (evidence: `README.md`)
