Architecture Overview
Relevant source files
The following files were used as context for generating this wiki page:
Speakeasy provides an AI control plane to manage Model Context Protocol (MCP) servers, skills, and assistants. The system centralizes distribution, security enforcement, and observability for AI usage across an organization. It supports multiple AI providers including Claude, OpenAI, and Gemini while providing fine-grained permissions and threat detection.
Sources: README.md:1-25, CLAUDE.md:10-20
System Components
The project uses a monorepo structure containing the backend server, frontend dashboard, CLI, and function runner.
| Component | Description | Technologies |
|---|---|---|
| Server | Main Go backend providing HTTP-RPC APIs and workflow orchestration. | Go, Goa, Temporal |
| Dashboard | React-based frontend for managing resources and observing usage. | TypeScript, React, Tailwind |
| CLI | Tool for users to interact with Speakeasy services and manage deployments. | Go |
| Functions | Serverless runner for Speakeasy Functions and tool execution. | TypeScript, Node.js |
| Dev-IDP | Lightweight Go server replacing external identity services during local development. | Go, SQLite |
Sources: README.md:120-135, CLAUDE.md:40-60, CONTRIBUTING.md:70-80
Backend Architecture (server/)
The backend relies on the Goa framework for API design and Temporal for durable workflows. It implements a layered architecture:
- Design Layer: Goa design files define the public interface.
- Implementation Layer: Service logic resides in
internal/packages. - Data Access: Uses SQLc for PostgreSQL and Squirrel for ClickHouse telemetry queries.
- Background Tasks: Temporal manages asynchronous processes like deployments and activities.
The diagram shows the request flow from external clients through the Goa API layer to internal services and persistent storage.
Sources: README.md:120-135, CLAUDE.md:65-90, REVIEW.md:10-30, REVIEW.md:180-190
Data Flow and Persistence
Speakeasy utilizes two primary databases to separate transactional data from high-volume telemetry.
Transactional Storage (PostgreSQL)
PostgreSQL stores organizational data, project configurations, and audit logs.
- Multi-tenancy: Every table contains a
project_idand is scoped to an organization. - Audit Logging: Mutations produce audit entries within the same database transaction to ensure atomicity.
- Soft Deletes: Tables use
deleted_atcolumns rather than physical row deletion.
Sources: REVIEW.md:150-175, REVIEW.md:120-130
Observability Storage (ClickHouse)
ClickHouse handles AI session logs, tool-call analysis, and cost telemetry.
- OpenTelemetry: Built on an OpenTelemetry foundation for tracking AI usage.
- Resource Mapping: Maps usage to tokens or costs for budget measurement.
Sources: README.md:30-40, REVIEW.md:180-190
Local Development Environment
The project provides a specialized toolchain for local development using mise and pitchfork.
Local Identity Provider (dev-idp)
Local development replaces external identity services with dev-idp. It mounts two surfaces on a single port:
- OAuth 2.1: Handles non-interactive login and MCP authentication.
- WorkOS Emulator: Simulates organization and team management APIs.
This sequence illustrates the non-interactive login flow used in local development environments.
Sources: CONTRIBUTING.md:70-120
Process Management
pitchfork manages all local daemons (server, worker, dashboard, and dev-idp) in a single terminal. The ./zero script automates the setup, including dependency installation, TLS certificate generation, and database migrations.
Sources: CLAUDE.md:40-50, CONTRIBUTING.md:1-20
Security and RBAC
Speakeasy enforces security through real-time inspection and fine-grained access control.
Enforcement Mechanisms
- RBAC: Handlers verify scopes (e.g.,
project:write) before executing database work. - Audit Logging: Every mutation on a project-scoped resource is logged.
- PII Detection: Risk policies scan chat messages for secrets (Gitleaks), PII (Presidio), and prompt injection.
MCP Security
Managed assistants and external clients are treated as distinct audiences. Assistants work under exact-project scoping without requiring external OAuth connections.
Sources: REVIEW.md:100-115, REVIEW.md:135-145, server/internal/assistants/testdata/managed_assistant_instructions_05c5372.txt:40-55
Deployment and Infrastructure
The system supports parallel worktrees through worktrunk, allowing multiple stacks to run side-by-side with remapped ports.
The diagram depicts how multiple git worktrees interact with a single Docker engine while sharing specific services.
Sources: CONTRIBUTING.md:130-160