Skip to content
STACK IT FAST

Cosmo (WunderGraph)

Curated OSSHybridFederated GraphQL API Gateway6-20 People

Audited from github.com/wundergraph/cosmo

WunderGraph Cosmo is an open-source GraphQL Federation platform providing a schema registry, composition checks, analytics, and a runtime router for building and operating federated GraphQL APIs on-prem or as a managed service.

Language
TypeScript
Database
PostgreSQL
Hosting
Docker
License
Apache-2.0
Running for
2 years
Team
6-20 People

Why this architecture

Splitting the Go router (runtime query execution) from the TypeScript Controlplane (schema registry and management) lets Cosmo scale and deploy the performance-critical data path independently, while a dedicated ClickHouse-backed metrics service keeps high-volume usage analytics off the primary Postgres database.

Tech stack by layer

12 technologies · audited Sep 17, 2026
Frontend & UI
  • Next.jsPowers the Studio web app used to manage federated graphs, schema checks, and analytics.
  • Radix UIProvides headless UI primitives (dialog, dropdown, accordion, popover) for the Studio interface.
  • GraphiQLEmbedded GraphQL IDE for exploring federated schemas, included at the workspace root.
Backend & APIs
  • TypeScriptImplements the Controlplane API, CLI (wgc), CDN server, and graphqlmetrics ingestion service.
  • GoImplements the Cosmo Router, the GraphQL federation gateway that serves runtime traffic.
  • ConnectRPCRPC framework used between the CLI, Studio, and Controlplane, generated from Protobuf definitions.
Data & Persistence
  • PostgreSQLSystem of record for the Controlplane (organizations, graphs, schema versions), managed with Drizzle.
  • DrizzleORM and migration tool for the Controlplane Postgres schema, driven by drizzle-kit generate/check.
  • ClickHouseStores GraphQL usage metrics and traces ingested by the graphqlmetrics service, migrated via dbmate.
Infrastructure & Deploy
  • KeycloakHandles authentication and organization/user management for the platform, run as its own service.
  • DockerEvery service (controlplane, router, cdn-server, graphqlmetrics, keycloak) ships its own Dockerfile.
  • HelmOfficial Helm charts deploy the full platform to Kubernetes, released through dedicated CI workflows.
  • NATSEvent-driven subscriptions and federated GraphQL subscription delivery, per the project blog posts.(inferred)

Cosmo (WunderGraph) architecture diagram

Open SVG
Cosmo (WunderGraph) architecture diagramGraphQL clients → Cosmo Router (GraphQL); Cosmo Router → Subgraphs (federated queries); Cosmo Router → CDN server (fetch config); Cosmo Router → graphqlmetrics (usage); graphqlmetrics → ClickHouse (write); Studio → Controlplane (ConnectRPC); wgc CLI → Controlplane (ConnectRPC); Controlplane → PostgreSQL (Drizzle); Controlplane → CDN server (publish schema); Controlplane → Keycloak (auth)CLIENTSSERVICESWORKERS & JOBSDATA & STORAGEEXTERNALGraphQL clientsqueries · subscriptionsStudioNext.js · Radix UIwgc CLIschema checksCosmo RouterGo federation gatewayControlplaneTypeScript · ConnectRPCCDN servercomposed schemasgraphqlmetricsusage ingestionPostgreSQLDrizzleClickHouseusage metricsSubgraphsyour GraphQL servicesKeycloakauthfetch configpublish schemaGraphQLusagewriteConnectRPCConnectRPCDrizzlefederated queriesauth
How the main components of Cosmo (WunderGraph) connect, drawn from the audited repository.
Diagram as text
  • GraphQL clients (queries · subscriptions) → Cosmo Router (Go federation gateway): GraphQL
  • Cosmo Router (Go federation gateway) → Subgraphs (your GraphQL services): federated queries
  • Cosmo Router (Go federation gateway) → CDN server (composed schemas): fetch config
  • Cosmo Router (Go federation gateway) → graphqlmetrics (usage ingestion): usage
  • graphqlmetrics (usage ingestion) → ClickHouse (usage metrics): write
  • Studio (Next.js · Radix UI) → Controlplane (TypeScript · ConnectRPC): ConnectRPC
  • wgc CLI (schema checks) → Controlplane (TypeScript · ConnectRPC): ConnectRPC
  • Controlplane (TypeScript · ConnectRPC) → PostgreSQL (Drizzle): Drizzle
  • Controlplane (TypeScript · ConnectRPC) → CDN server (composed schemas): publish schema
  • Controlplane (TypeScript · ConnectRPC) → Keycloak (auth): auth

Key architectural decisions

7 decisions
  1. 01

    The platform is a pnpm/Turborepo-style monorepo split across TypeScript and Go workspaces

    pnpm-workspace.yaml lists controlplane, cli, studio, router, router-plugin, cdn-server, graphqlmetrics, connect, protographic, and more as independent packages, while router, aws-lambda-router, connect-go, demo, and graphqlmetrics ship their own go.mod files for the Go-based components.

  2. 02

    Runtime traffic and control-plane management are separate services in separate languages

    The Cosmo Router (router/package.json, a Go binary) handles live federated GraphQL query execution, while the Controlplane (controlplane/package.json, TypeScript) handles schema registry, composition checks, and organization management, so router performance is not coupled to the Node.js control-plane runtime.

  3. 03

    The Controlplane schema is managed with Drizzle, not Prisma or raw SQL

    controlplane/package.json defines db:generate, db:check, and db:drop scripts around drizzle-kit against drizzle.config.ts, giving the TypeScript control-plane typed, code-first Postgres migrations.

  4. 04

    Usage analytics run through a dedicated Go service writing to ClickHouse

    graphqlmetrics/go.mod depends on github.com/ClickHouse/clickhouse-go/v2 and github.com/amacneil/dbmate/v2, and the controlplane package.json exposes a separate ch:migrate script (pnpm ch:migrate) alongside its Postgres db:migrate script, keeping the high-volume metrics path off the primary OLTP database.

  5. 05

    Auth is delegated to Keycloak rather than a custom identity system

    docker-compose.yml runs a keycloak service built from the keycloak/ directory (with its own Dockerfile) that imports a preconfigured realm.json, and the Controlplane is configured with KC_DB_URL_HOST pointing at the same Postgres instance used for application data.

  6. 06

    Inter-service RPC uses ConnectRPC over Protobuf instead of plain REST or GraphQL

    The root package.json generate script runs pnpm buf generate against proto/wg/cosmo/platform, proto/wg/cosmo/notifications, proto/wg/cosmo/common, and proto/wg/cosmo/node, and graphqlmetrics/go.mod depends on connectrpc.com/connect, so the CLI, Studio, and Controlplane share generated, typed clients.

  7. 07

    The CLI (wgc) can build as a TypeScript/Node tool or a standalone compiled binary

    cli/package.json defines both a build script (tsc, for npm distribution) and a build:bun script (bun build --compile --production --outfile wgc), giving users either an npm-installed CLI or a single native executable.

How Cosmo (WunderGraph) is built

How WunderGraph Cosmo is structured

Cosmo is a pnpm workspace monorepo (pnpm-workspace.yaml) mixing TypeScript and Go packages: controlplane (schema registry and API, TypeScript), router (federation gateway, Go), cli (the wgc command-line tool), studio (the Next.js management UI), cdn-server (serves composed schemas to routers), graphqlmetrics (Go, usage analytics), keycloak (auth, with its own Dockerfile), connect and proto (shared ConnectRPC/Protobuf definitions), and router-plugin. The root package.json generate script runs buf generate against the proto/wg/cosmo/* definitions, producing the typed clients that let these otherwise-separate services and languages talk to each other consistently.

Frontend

The Studio (studio/package.json) is a Next.js application styled with Radix UI primitives (@radix-ui/react-accordion, -dialog, -dropdown-menu, -popover, and more) and Monaco Editor (@monaco-editor/react, with a copy-monaco postinstall step) for schema and query editing. It communicates with the Controlplane over ConnectRPC (@connectrpc/connect, @connectrpc/connect-web, @connectrpc/connect-query), using the same generated Protobuf clients as the CLI. A root-level GraphiQL setup (graphiql, @graphiql/toolkit, @graphiql/plugin-explorer in the top-level package.json) provides an embedded GraphQL IDE.

Backend & APIs

The Controlplane (controlplane/package.json) is the TypeScript service managing organizations, federated graphs, schema checks, and composition; it runs with tsx watch src/index.ts in development and compiles with tsc for production (NODE_ENV=production node dist/index.js). The Cosmo Router (router/package.json, a Go module) is the separately versioned runtime component that actually serves federated GraphQL queries; its package.json exists mainly to drive versioned Docker image releases (postversion triggers image-release.yml) rather than to hold JavaScript dependencies. Communication between the CLI, Studio, and Controlplane runs over ConnectRPC (connectrpc.com/connect in graphqlmetrics/go.mod, @connectrpc/connect in the TypeScript packages), generated from the shared .proto definitions.

Data & persistence

PostgreSQL is the Controlplane's system of record, run as the postgres service in docker-compose.yml and managed through Drizzle: controlplane/package.json defines db:generate, db:check, db:drop, and drizzle:up scripts driven by drizzle-kit against drizzle.config.ts. GraphQL usage metrics and traces take a separate path into ClickHouse: graphqlmetrics/go.mod depends on github.com/ClickHouse/clickhouse-go/v2, migrations run through github.com/amacneil/dbmate/v2 against the clickhouse/migrations directory, and the Controlplane exposes this as its own ch:migrate script distinct from the Postgres db:migrate script.

Realtime / collaboration

The project's own engineering blog posts, linked from the README, describe federated GraphQL subscriptions implemented with NATS for event-driven delivery and custom epoll/kqueue-based scaling in the Go router; this is corroborated by the repository's graphql-federation and graphql-router topics but the NATS integration itself is not directly visible in the sampled manifests, so it is treated as inferred rather than manifest-confirmed.

Build, test & deploy

CI is split into dozens of per-service GitHub Actions workflows: controlplane-ci.yaml, router-ci.yaml, cli-ci.yaml, studio-ci.yaml, composition-ci.yaml, graphqlmetrics-ci.yaml, cdn-ci.yaml, keycloak-ci.yaml, and connect-go-ci.yaml each test their own package independently, while helm-ci.yaml, helm-release.yaml, and helm-deployment.yaml validate and publish the Kubernetes charts. Release automation is per-component too: router-binary-release.yaml, cli-binary-release.yaml, and aws-router-binary-release.yaml build platform binaries, while image-release.yml is triggered per-service via each package's postversion npm hook (visible in both controlplane/package.json and router/package.json).

Self-hosting notes

docker-compose.yml runs the full local stack behind Docker Compose profiles (dev, debug), including Postgres, Keycloak (with a pre-imported realm.json), and optional Jaeger and Prometheus containers for testing OpenTelemetry instrumentation. For production, official Helm charts (built and released via helm-release.yaml) deploy the platform to Kubernetes, and the README explicitly documents a "Platform Engineer" path using the Helm chart alongside a "Developer" path running just the router locally and an "Architect" path using examples/full-cosmo-docker.

What to copy (and what not to)

Separating the performance-sensitive Go router from the TypeScript Controlplane, connected only through generated ConnectRPC/Protobuf clients (proto/wg/cosmo/*), is a strong pattern for platforms where the data plane and control plane have very different scaling and latency requirements. Routing high-volume usage metrics to ClickHouse through a dedicated Go ingestion service (graphqlmetrics), while keeping transactional data in Postgres via Drizzle, is worth copying for any platform that needs both OLTP consistency and fast analytical queries — but it does mean operating and migrating two different database engines (db:migrate and ch:migrate as separate scripts) instead of one.

Sources & repo audit

Audited
Sep 17, 2026
Commit
26545dc
License
Apache-2.0

Independent analysis of repository at github.com/wundergraph/cosmo. Spotted an inaccuracy? Use the claim form to request a correction.

Show this stack on your README or website
Tech stack of Cosmo (WunderGraph)
[![Tech stack of Cosmo (WunderGraph) on STACK IT FAST](https://stackitfast.com/badge/cosmo-wundergraph.svg)](https://stackitfast.com/project/cosmo-wundergraph)

Paste it into your README. It shows your current stack and links to this page.

Use this stack

Scaffold it with your agent

Paste this prompt into Claude Code, Cursor, Windsurf or AGY to start a project with Cosmo (WunderGraph)'s architecture.

  1. 1Copy the promptThe full markdown spec, with every layer and decision.
  2. 2Open your AI toolClaude Code, Cursor, Windsurf or Copilot, in a new repo.
  3. 3Paste and scaffoldUse it as the first instruction; review before you ship.
use-this-stack.md · 61 lines · 8.3 KB
# MISSION: Scaffold "Cosmo (WunderGraph)" Production Architecture
You are an expert Senior Staff Software Architect and Full-Stack Engineer. Your mission is to scaffold and implement a production-grade, highly reliable, and modular codebase following the proven architecture of **Cosmo (WunderGraph)**.
---
## 1. PROJECT SPECIFICATIONS & BENCHMARK
- **Reference Architecture**: Cosmo (WunderGraph)
- **What It Does**: WunderGraph Cosmo is an open-source GraphQL Federation platform providing a schema registry, composition checks, analytics, and a runtime router for building and operating federated GraphQL APIs on-prem or as a managed service.
- **Domain & Category**: Federated GraphQL API Gateway
- **Production Scale**: 6-20 People
- **Development Mode**: HYBRID
- **Architectural Rationale**: Splitting the Go router (runtime query execution) from the TypeScript Controlplane (schema registry and management) lets Cosmo scale and deploy the performance-critical data path independently, while a dedicated ClickHouse-backed metrics service keeps high-volume usage analytics off the primary Postgres database.
- **Live Website Reference**: https://wundergraph.com/cosmo
- **Source Repository**: https://github.com/wundergraph/cosmo
---
## 2. PRODUCTION TECH STACK
- **Full Stack Array**: TypeScript, Go, PostgreSQL, ClickHouse, Drizzle, Keycloak, ConnectRPC, Next.js, NATS, Protocol Buffers, Helm, Docker
- **Primary Language(s)**: TypeScript, Go, HTML
- **License of the reference repo**: Apache-2.0
- **Frontend**: Next.js — Powers the Studio web app used to manage federated graphs, schema checks, and analytics.; Radix UI — Provides headless UI primitives (dialog, dropdown, accordion, popover) for the Studio interface.; GraphiQL — Embedded GraphQL IDE for exploring federated schemas, included at the workspace root.
- **Backend & APIs**: TypeScript — Implements the Controlplane API, CLI (wgc), CDN server, and graphqlmetrics ingestion service.; Go — Implements the Cosmo Router, the GraphQL federation gateway that serves runtime traffic.; ConnectRPC — RPC framework used between the CLI, Studio, and Controlplane, generated from Protobuf definitions.
- **Data & persistence**: PostgreSQL — System of record for the Controlplane (organizations, graphs, schema versions), managed with Drizzle.; Drizzle — ORM and migration tool for the Controlplane Postgres schema, driven by drizzle-kit generate/check.; ClickHouse — Stores GraphQL usage metrics and traces ingested by the graphqlmetrics service, migrated via dbmate.
- **Infrastructure & deploy**: Keycloak — Handles authentication and organization/user management for the platform, run as its own service.; Docker — Every service (controlplane, router, cdn-server, graphqlmetrics, keycloak) ships its own Dockerfile.; Helm — Official Helm charts deploy the full platform to Kubernetes, released through dedicated CI workflows.; NATS — Event-driven subscriptions and federated GraphQL subscription delivery, per the project blog posts.
---
## 3. KEY ARCHITECTURAL DECISIONS (audited from https://github.com/wundergraph/cosmo @ 26545dc)
1. **The platform is a pnpm/Turborepo-style monorepo split across TypeScript and Go workspaces**: pnpm-workspace.yaml lists controlplane, cli, studio, router, router-plugin, cdn-server, graphqlmetrics, connect, protographic, and more as independent packages, while router, aws-lambda-router, connect-go, demo, and graphqlmetrics ship their own go.mod files for the Go-based components.
2. **Runtime traffic and control-plane management are separate services in separate languages**: The Cosmo Router (router/package.json, a Go binary) handles live federated GraphQL query execution, while the Controlplane (controlplane/package.json, TypeScript) handles schema registry, composition checks, and organization management, so router performance is not coupled to the Node.js control-plane runtime.
3. **The Controlplane schema is managed with Drizzle, not Prisma or raw SQL**: controlplane/package.json defines db:generate, db:check, and db:drop scripts around drizzle-kit against drizzle.config.ts, giving the TypeScript control-plane typed, code-first Postgres migrations.
4. **Usage analytics run through a dedicated Go service writing to ClickHouse**: graphqlmetrics/go.mod depends on github.com/ClickHouse/clickhouse-go/v2 and github.com/amacneil/dbmate/v2, and the controlplane package.json exposes a separate ch:migrate script (pnpm ch:migrate) alongside its Postgres db:migrate script, keeping the high-volume metrics path off the primary OLTP database.
5. **Auth is delegated to Keycloak rather than a custom identity system**: docker-compose.yml runs a keycloak service built from the keycloak/ directory (with its own Dockerfile) that imports a preconfigured realm.json, and the Controlplane is configured with KC_DB_URL_HOST pointing at the same Postgres instance used for application data.
6. **Inter-service RPC uses ConnectRPC over Protobuf instead of plain REST or GraphQL**: The root package.json generate script runs pnpm buf generate against proto/wg/cosmo/platform, proto/wg/cosmo/notifications, proto/wg/cosmo/common, and proto/wg/cosmo/node, and graphqlmetrics/go.mod depends on connectrpc.com/connect, so the CLI, Studio, and Controlplane share generated, typed clients.
7. **The CLI (wgc) can build as a TypeScript/Node tool or a standalone compiled binary**: cli/package.json defines both a build script (tsc, for npm distribution) and a build:bun script (bun build --compile --production --outfile wgc), giving users either an npm-installed CLI or a single native executable.
---
## 4. NON-NEGOTIABLE ARCHITECTURAL GUARDRAILS
1. **Monorepo & Modular Separation**:
   - Structure as a Turborepo monorepo with strict package boundaries:
     - `apps/web`: Application UI, routing, layouts, and server endpoints.
     - `packages/ui`: Shared design tokens, CSS variables, and Radix UI primitive components.
     - `packages/db`: Database schemas, client singleton, declarative migrations, and seed scripts.
     - `packages/config`: Shared TypeScript, ESLint, and build configurations.
2. **Strict Type Safety & Zero `any` Policy**:
   - Enable `strict: true`, `noImplicitAny: true`, and `strictNullChecks: true`.
   - Validate ALL external inputs, API request bodies, and query parameters with **Zod** schemas before execution.
3. **Frontend & Rendering Guidelines**:
   - Utilize Next.js 15 App Router: default to React Server Components (RSC) for data fetching. Handle mutations through Server Actions with Zod validation. Keep 'use client' directives restricted strictly to interactive leaf components.
4. **Design System & Aesthetics**:
   - Keep every color, radius, shadow and font in a single token file (CSS variables) and consume tokens everywhere; never hardcode hex values in components.
   - Prefer crisp 1px borders and one subtle shadow scale over blurry default shadows. Pair one sans-serif for body/headings with one monospace for tags, badges, metrics, and code.
5. **Data Layer & Reliability**:
   - Write declarative schema definitions with foreign keys, composite indexes on queried filters, and automated timestamp triggers.
   - Use connection pooling and prepared statements for serverless database execution.
---
## 5. STEP-BY-STEP SCAFFOLDING ROADMAP
- **Phase 1: Workspace & Root Config**: Initialize package manager, monorepo configuration (`turbo.json`, `tsconfig.base.json`, `package.json`).
- **Phase 2: Database Schema & Client**: Set up the data layer (PostgreSQL, Drizzle, ClickHouse): client, connection pool, models, and migration scripts.
- **Phase 3: Design Tokens & UI Primitives**: Build accessible `Button`, `Input`, `Card`, `Badge`, and layout wrappers inside `packages/ui`.
- **Phase 4: Core Application Routes & Handlers**: Implement primary authentication, user session handling, and application routes.
- **Phase 5: Quality Assurance & Build Verification**: Run `tsc --noEmit`, ESLint, Prettier, and smoke test suites to ensure zero compilation or runtime errors.
---
## 6. EXECUTION INSTRUCTIONS
1. Review all specifications, architectural guardrails, and stack choices above.
2. Present the full monorepo directory tree structure.
3. Systematically generate the complete, production-ready codebase according to the 5-phase roadmap above — starting with the root workspace setup, followed by the database schema, UI design system package, and full-stack application routes until the repository is fully scaffolded and ready to run.
Scaffolded something with this prompt?
Would you pick this stack for a federated graphql api gateway project?

Frequently asked about Cosmo (WunderGraph)

What is WunderGraph Cosmo built with?

Cosmo is a polyglot monorepo: a Go router for federated GraphQL traffic, a TypeScript Controlplane using Drizzle over PostgreSQL, a Go graphqlmetrics service writing to ClickHouse, and a Next.js Studio, all managed as pnpm workspaces.

Does Cosmo need a separate database for the router?

No. The Cosmo Router (router/package.json) fetches composed schemas at runtime; PostgreSQL and ClickHouse are used by the Controlplane and graphqlmetrics service, not by the router itself.

Can I self-host WunderGraph Cosmo?

Yes. Every service (controlplane, router, cdn-server, graphqlmetrics, keycloak) has its own Dockerfile, docker-compose.yml runs the full local stack, and official Helm charts deploy the platform to Kubernetes.

How does Cosmo store GraphQL usage metrics and traces?

A dedicated Go service, graphqlmetrics, ingests usage data into ClickHouse, migrated with dbmate, keeping analytics separate from the PostgreSQL database that Drizzle manages for the Controlplane.

What handles authentication in Cosmo?

Keycloak, run as its own container defined in docker-compose.yml with an imported realm.json, provides identity and organization/user management for the platform.

One email a month: new deep dives and stack trends

New source-audited architectures, head-to-head comparisons and the monthly stack report. No spam, unsubscribe anytime.

use-this-stack.md