# micro/go-micro architecture

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

- Interactive diagram: https://gitdiagram.com/micro/go-micro
- Repository: https://github.com/micro/go-micro

## Overview

Go Micro is a distributed-systems framework whose documented product spans RPC services, discovery and messaging, plus agents that use services as tools. A user can chat with the framework’s agent from the terminal; agents use models, conversation history and tools, with background tasks and recovery. Services can also be exposed to other applications and agents through the HTTP/MCP gateway. The graph preserves these major branches and names core runtime layers. Relationships are limited to README statements and indexed source references; unsampled implementation details are not inferred.

Main entry points: [`agent/agent.go`](https://github.com/micro/go-micro/blob/master/agent/agent.go) (Agent Runtime), [`service/service.go`](https://github.com/micro/go-micro/blob/master/service/service.go) (Service Lifecycle), [`client/rpc_client.go`](https://github.com/micro/go-micro/blob/master/client/rpc_client.go) (RPC Client), [`cmd/micro/gateway/server.go`](https://github.com/micro/go-micro/blob/master/cmd/micro/gateway/server.go) (HTTP Gateway)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_service_runtime["Service Runtime"]
  node_service["Service Lifecycle<br/>[service.go]"]
  node_rpc_server["RPC Server<br/>[server.go]"]
  node_rpc_router["RPC Routing<br/>[rpc_router.go]"]
  node_flow["Durable Flows<br/>[steps.go]"]
end

subgraph group_agent_runtime["Agent Runtime"]
  node_agent["Agent Runtime<br/>[agent.go]"]
  node_agent_tasks["Background Tasks<br/>[tasks.go]"]
  node_agent_history["Conversation History<br/>[memory.go]"]
  node_agent_recovery["Recovery<br/>[checkpoint.go]"]
  node_models["Model Providers<br/>[model.go]"]
  node_litellm["LiteLLM Provider<br/>[litellm.go]"]
end

subgraph group_connectivity["Connectivity"]
  node_rpc_client["RPC Client<br/>[rpc_client.go]"]
  node_discovery["Service Discovery<br/>[registry.go]"]
  node_messaging["Messaging<br/>[broker.go]"]
  node_storage[("Storage<br/>[store.go]")]
  node_configuration["Configuration<br/>[config.go]"]
end

subgraph group_integration["External Interfaces"]
  node_terminal_chat["Terminal Chat<br/>[chat.go]"]
  node_gateway["HTTP Gateway<br/>[server.go]"]
  node_mcp["MCP Gateway<br/>[mcp.go]"]
  node_web_service["Web Service<br/>[service.go]"]
end

node_user(("User"))

node_user -->|"starts chat"| node_terminal_chat
node_terminal_chat -.->|"invokes agent"| node_agent
node_agent -->|"uses models"| node_models
node_agent -->|"uses history"| node_agent_history
node_agent -->|"supports tasks"| node_agent_tasks
node_agent -->|"supports recovery"| node_agent_recovery
node_agent -->|"uses client"| node_rpc_client
node_agent -->|"stores tasks"| node_storage
node_litellm -->|"implements model"| node_models
node_service -->|"starts server"| node_rpc_server
node_service -->|"uses client"| node_rpc_client
node_service -->|"scopes state"| node_storage
node_rpc_server -.->|"routes requests"| node_rpc_router
node_rpc_client -->|"discovers services"| node_discovery
node_rpc_client -->|"publishes messages"| node_messaging
node_flow -.->|"coordinates services"| node_service
node_gateway -->|"exposes MCP"| node_mcp
node_gateway -->|"exposes services"| node_service
node_web_service -->|"registers service"| node_discovery

click node_terminal_chat "https://github.com/micro/go-micro/blob/master/cmd/micro/chat/chat.go"
click node_agent "https://github.com/micro/go-micro/blob/master/agent/agent.go"
click node_agent_tasks "https://github.com/micro/go-micro/blob/master/agent/tasks.go"
click node_agent_history "https://github.com/micro/go-micro/blob/master/agent/memory.go"
click node_agent_recovery "https://github.com/micro/go-micro/blob/master/agent/checkpoint.go"
click node_models "https://github.com/micro/go-micro/blob/master/model/model.go"
click node_litellm "https://github.com/micro/go-micro/blob/master/model/litellm/litellm.go"
click node_service "https://github.com/micro/go-micro/blob/master/service/service.go"
click node_rpc_server "https://github.com/micro/go-micro/blob/master/server/server.go"
click node_rpc_router "https://github.com/micro/go-micro/blob/master/server/rpc_router.go"
click node_rpc_client "https://github.com/micro/go-micro/blob/master/client/rpc_client.go"
click node_discovery "https://github.com/micro/go-micro/blob/master/registry/registry.go"
click node_messaging "https://github.com/micro/go-micro/blob/master/broker/broker.go"
click node_storage "https://github.com/micro/go-micro/blob/master/store/store.go"
click node_configuration "https://github.com/micro/go-micro/blob/master/config/config.go"
click node_flow "https://github.com/micro/go-micro/blob/master/flow/steps.go"
click node_gateway "https://github.com/micro/go-micro/blob/master/cmd/micro/gateway/server.go"
click node_mcp "https://github.com/micro/go-micro/blob/master/gateway/mcp/mcp.go"
click node_web_service "https://github.com/micro/go-micro/blob/master/web/service.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_service,node_rpc_server,node_rpc_router,node_flow,node_user toneBlue
class node_agent,node_agent_tasks,node_agent_history,node_agent_recovery,node_models,node_litellm toneAmber
class node_rpc_client,node_discovery,node_messaging,node_storage,node_configuration toneMint
class node_terminal_chat,node_gateway,node_mcp,node_web_service toneRose
```

## Components

### Service Runtime

- [Service Lifecycle](https://github.com/micro/go-micro/blob/master/service/service.go): `service/service.go`
- [RPC Server](https://github.com/micro/go-micro/blob/master/server/server.go): `server/server.go`
- [RPC Routing](https://github.com/micro/go-micro/blob/master/server/rpc_router.go): `server/rpc_router.go`
- [Durable Flows](https://github.com/micro/go-micro/blob/master/flow/steps.go): `flow/steps.go`

### Agent Runtime

- [Agent Runtime](https://github.com/micro/go-micro/blob/master/agent/agent.go): `agent/agent.go`
- [Background Tasks](https://github.com/micro/go-micro/blob/master/agent/tasks.go): `agent/tasks.go`
- [Conversation History](https://github.com/micro/go-micro/blob/master/agent/memory.go): `agent/memory.go`
- [Recovery](https://github.com/micro/go-micro/blob/master/agent/checkpoint.go): `agent/checkpoint.go`
- [Model Providers](https://github.com/micro/go-micro/blob/master/model/model.go): `model/model.go`
- [LiteLLM Provider](https://github.com/micro/go-micro/blob/master/model/litellm/litellm.go): `model/litellm/litellm.go`

### Connectivity

- [RPC Client](https://github.com/micro/go-micro/blob/master/client/rpc_client.go): `client/rpc_client.go`
- [Service Discovery](https://github.com/micro/go-micro/blob/master/registry/registry.go): `registry/registry.go`
- [Messaging](https://github.com/micro/go-micro/blob/master/broker/broker.go): `broker/broker.go`
- [Storage](https://github.com/micro/go-micro/blob/master/store/store.go): `store/store.go`
- [Configuration](https://github.com/micro/go-micro/blob/master/config/config.go): `config/config.go`

### External Interfaces

- [Terminal Chat](https://github.com/micro/go-micro/blob/master/cmd/micro/chat/chat.go): `cmd/micro/chat/chat.go`
- [HTTP Gateway](https://github.com/micro/go-micro/blob/master/cmd/micro/gateway/server.go): `cmd/micro/gateway/server.go`
- [MCP Gateway](https://github.com/micro/go-micro/blob/master/gateway/mcp/mcp.go): `gateway/mcp/mcp.go`
- [Web Service](https://github.com/micro/go-micro/blob/master/web/service.go): `web/service.go`

### Other components

- **User**

## Connections

- User → Terminal Chat: starts chat (evidence: `README.md`)
- Terminal Chat → Agent Runtime: invokes agent
- Agent Runtime → Model Providers: uses models (evidence: `README.md`)
- Agent Runtime → Conversation History: uses history (evidence: `README.md`)
- Agent Runtime → Background Tasks: supports tasks (evidence: `README.md`)
- Agent Runtime → Recovery: supports recovery (evidence: `README.md`)
- Agent Runtime → RPC Client: uses client
- Agent Runtime → Storage: stores tasks
- LiteLLM Provider → Model Providers: implements model (evidence: `model/litellm/litellm.go`)
- Service Lifecycle → RPC Server: starts server (evidence: `service/service.go`)
- Service Lifecycle → RPC Client: uses client (evidence: `service/service.go`)
- Service Lifecycle → Storage: scopes state (evidence: `service/service.go`)
- RPC Server → RPC Routing: routes requests
- RPC Client → Service Discovery: discovers services (evidence: `client/rpc_client.go`)
- RPC Client → Messaging: publishes messages (evidence: `client/rpc_client.go`)
- Durable Flows → Service Lifecycle: coordinates services
- HTTP Gateway → MCP Gateway: exposes MCP (evidence: `cmd/micro/gateway/server.go`)
- HTTP Gateway → Service Lifecycle: exposes services (evidence: `README.md`)
- Web Service → Service Discovery: registers service (evidence: `web/service.go`)
