Langfuse is an open-source LLM observability and evaluation platform for tracing, evaluating, and managing prompts across AI applications, self-hostable via Docker or used as a managed cloud service.
- Language
- TypeScript
- Database
- PostgreSQL
- Hosting
- Docker
- Running for
- 1 year 8 months
- Team
- 6-20 people
Why this architecture
Storage is split by workload: Postgres via Prisma for relational app state, ClickHouse for high-volume trace analytics, and Redis-backed BullMQ for async jobs, while a separate Rust Axum service handles latency-sensitive LLM proxying outside the Node runtime.
Tech stack by layer
15 technologies · audited Sep 17, 2026- Next.jsRenders the web dashboard, API routes, and auth pages inside the web workspace.
- ReactBuilds the trace explorer, prompt playground, and settings UI.
- Radix UIProvides accessible primitives; select and focus-management behavior is patched.
- NextAuth.jsHandles dashboard auth sessions; patched across three pinned versions.
- Rustai-gateway is a standalone Axum-based Rust service that proxies LLM calls.
- BullMQQueues ingestion, evaluation, and billing jobs processed by the worker.
- Model Context ProtocolThe worker exposes an MCP endpoint so in-app agents can query traces.
- Vercel AI SDKPinned per-provider AI SDK forks evaluate LLM connections in the worker.
- PostgreSQLStores relational app state (projects, users, API keys) via Prisma.
- PrismaORM and migration tool for the Postgres schema in packages/shared/prisma.
- ClickHouseStores traces, observations, and scores at analytics scale.
- RedisBacks BullMQ queues and caching for the web app and worker.
- MinIOS3-compatible object storage for blob exports and media in local/dev compose.
- DockerEach service (web, worker, ai-gateway) ships its own multi-stage Dockerfile.
- TurborepoOrchestrates builds, tests, and dev servers across the pnpm workspace.
- GitHub ActionsRuns CI/CD: CodeQL, Snyk, Semgrep scans, preview deploys, and releases.
Langfuse architecture diagram
Open SVGDiagram as text
- Dashboard (React · Radix UI) → web (Next.js · NextAuth): UI
- SDKs & API clients (REST / OpenAPI) → web (Next.js · NextAuth): ingest API
- SDKs & API clients (REST / OpenAPI) → ai-gateway (Rust · Axum): LLM calls
- ai-gateway (Rust · Axum) → LLM providers: proxy
- web (Next.js · NextAuth) → PostgreSQL (Prisma): app state
- web (Next.js · NextAuth) → ClickHouse (traces & scores): trace queries
- web (Next.js · NextAuth) → Redis (queues · cache): enqueue
- Redis (queues · cache) → worker (Express · BullMQ): jobs
- worker (Express · BullMQ) → ClickHouse (traces & scores): write traces
- worker (Express · BullMQ) → Object storage (S3 / MinIO): blobs
Key architectural decisions
6 decisions- 01
Traces live in ClickHouse; app state lives in Postgres
Langfuse splits storage by access pattern: Postgres (modeled via Prisma in packages/shared/prisma) holds projects, users, and API keys, while ClickHouse absorbs the high-volume trace, observation, and score data, wired through the CLICKHOUSE_MIGRATION_URL variable in docker-compose.yml.
- 02
The AI gateway is a separate Rust service, not a Node module
ai-gateway/Cargo.toml defines a standalone Axum-based Rust binary with its own Dockerfile, keeping latency-sensitive LLM proxying out of the Next.js and worker Node processes so it can be scaled and deployed independently.
- 03
A native Rust addon backs performance-critical worker code
packages/native/Cargo.toml builds a napi-rs addon (langfuse-native) that the worker compiles before starting dev or build, per the @langfuse/native#build task in turbo.json, instead of implementing that logic in pure JavaScript.
- 04
Turborepo and pnpm workspaces bind web, worker, and ai-gateway together
pnpm-workspace.yaml lists web, worker, ai-gateway, packages/**, and ee as workspace members, and turbo.json defines cross-package task dependencies (build depends on db:generate) so a single turbo run build compiles every service consistently.
- 05
Enterprise features are isolated in a separately licensed ee/ package
The ee/ directory ships its own LICENSE and package.json as @langfuse/ee, importing @langfuse/shared via workspace:*, which keeps SSO and other paid features out of the root NOASSERTION-licensed open-source packages.
- 06
BullMQ and Redis queue ingestion and evaluation work asynchronously
worker/package.json depends on bullmq and ioredis; the worker consumes queued jobs (ingestion, evaluation, billing) so the web app API responses stay fast while heavier processing happens out of band.
How Langfuse is built
How Langfuse is structured
Langfuse is organized as a pnpm/Turborepo monorepo (pnpm-workspace.yaml, turbo.json) with three deployable services — web, worker, and ai-gateway — plus shared internal packages under packages/. The web workspace is the Next.js dashboard and public API; worker is a Node service that drains background jobs; ai-gateway is an independent Rust binary. Enterprise-only functionality lives in ee/, published as the separately licensed @langfuse/ee package and imported by web through workspace:*. Shared types, Prisma models, and ClickHouse migration SQL live in packages/shared, consumed by both web and worker.
Frontend
web is a Next.js application (web/next.config.mjs, web/package.json) that renders the dashboard, trace explorer, and prompt playground, using React for components and Radix UI primitives underneath — the repo carries patches for @radix-ui/react-select and @radix-ui/react-roving-focus, indicating close control over that dependency. Authentication runs through NextAuth.js, also patched across three versions (patches/next-auth@4.24.11.patch through 4.24.15.patch), for session handling on the dashboard. A web/.storybook directory and test-storybook script show component development happens partly in isolation via Storybook, and Playwright drives end-to-end tests (test:e2e in web/package.json).
Backend & APIs
The web package also hosts the public REST/OpenAPI surface, generated with Fern (fern/apis, the openapi:export script invoking fern-api@3.88.0). Background work — ingestion processing, evaluation runs, billing, and cache warming — is handled by worker, an Express-based Node service (worker/package.json depends on express) that consumes BullMQ queues backed by Redis (ioredis, bullmq dependencies). The worker also exposes a Model Context Protocol endpoint: docker-compose.yml sets LANGFUSE_MCP_BASE_URL so the web service can reach the worker for in-app agent MCP calls without redirecting the user-facing NEXTAUTH_URL. For LLM connectivity, the worker depends on pinned per-provider forks of the Vercel AI SDK (ai-sdk-openai-v4, ai-sdk-anthropic-v4, ai-sdk-amazon-bedrock-v4, ai-sdk-openai-compatible-v4) to evaluate model connections independent of a customer's chosen provider version.
Separately, ai-gateway is a Rust service built with the Axum framework (ai-gateway/Cargo.toml), compiled with its own cargo build --release --locked script and shipped in a dedicated multi-stage ai-gateway/Dockerfile. Keeping it out of the Node processes isolates latency-sensitive LLM proxying (and its OpenTelemetry instrumentation, per the opentelemetry-otlp dependency) from the rest of the stack, and lets it be deployed and scaled on its own.
Data & persistence
Relational application data — projects, users, API keys, and configuration — is modeled with Prisma against PostgreSQL; turbo.json's db:generate task takes packages/shared/prisma/schema.prisma as its input and every service depends on it before building. High-volume observability data (traces, observations, scores) goes to ClickHouse instead: docker-compose.yml configures CLICKHOUSE_MIGRATION_URL and the worker's ch:migrations:materialize script (in packages/shared/package.json) manages ClickHouse schema migrations via golang-migrate, compiled from source in .cursor/Dockerfile and .devcontainer/Dockerfile to avoid pulling in unused upstream drivers. Redis serves as both the BullMQ broker and a general cache, and MinIO provides S3-compatible object storage for blob exports in local and self-hosted compose setups (with AWS S3 as the implied production alternative, given the @aws-sdk/client-s3 dependency pinned in the pnpm catalog).
Build, test & deploy
Turborepo drives the workspace: turbo.json defines task dependencies so that, for example, every build task depends on db:generate, and worker-specific tasks (worker#dev, worker#test) depend on the native Rust addon (@langfuse/native#build) being compiled first via napi build. The repository pins Node 24 and pnpm 12.4.1 (package.json engines/packageManager fields) and enforces pnpm usage through a preinstall: npx only-allow pnpm script. CI runs an extensive set of GitHub Actions workflows — codeql.yml, semgrep.yml, snyk-web.yml, snyk-worker.yml, zizmor.yml for security scanning, plus preview-build.yml/preview-deactivate.yml for ephemeral preview environments and promote-main-to-production.yml/release.yml for shipping. Releases are cut with release-it, configured in package.json to bump version constants across web, worker, and packages/shared.
Self-hosting notes
Self-hosting runs through docker-compose.yml, which documents that only langfuse-web (port 3000) and minio (port 9090) should be exposed publicly, with Postgres, Redis, and ClickHouse bound to localhost. Each service has its own production Dockerfile (web/Dockerfile, worker/Dockerfile, ai-gateway/Dockerfile), all building from node:24-alpine (or rust:1.98.0 for the gateway) and using turbo prune to produce minimal, per-service build contexts. The README links a hosted docs/deployment/self-host guide alongside the managed Langfuse Cloud option, and scripts/nuke.sh plus the infra:dev:* npm scripts support tearing down and recreating the local Docker stack during development.
Sources & repo audit
- Audited
- Sep 17, 2026
- Commit
- 6e9f8eb
- License
- NOASSERTION
- Root package.json (pnpm workspace scripts, Turborepo build)
- docker-compose.yml (Postgres, ClickHouse, Redis, MinIO services)
- ai-gateway/Cargo.toml (Rust Axum LLM gateway)
- turbo.json (workspace task graph)
- packages/native/Cargo.toml (napi-rs native addon)
Independent analysis of repository at github.com/langfuse/langfuse. Spotted an inaccuracy? Use the claim form to request a correction.
Show this stack on your README or website
[](https://stackitfast.com/project/langfuse)Paste it into your README. It shows your current stack and links to this page.
Scaffold it with your agent
Paste this prompt into Claude Code, Cursor, Windsurf or AGY to start a project with Langfuse's architecture.
- 1Copy the promptThe full markdown spec, with every layer and decision.
- 2Open your AI toolClaude Code, Cursor, Windsurf or Copilot, in a new repo.
- 3Paste and scaffoldUse it as the first instruction; review before you ship.
# MISSION: Scaffold "Langfuse" 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 **Langfuse**.
---
## 1. PROJECT SPECIFICATIONS & BENCHMARK
- **Reference Architecture**: Langfuse
- **What It Does**: Langfuse is an open-source LLM observability and evaluation platform for tracing, evaluating, and managing prompts across AI applications, self-hostable via Docker or used as a managed cloud service.
- **Domain & Category**: LLM Observability
- **Production Scale**: 6-20 people
- **Development Mode**: AI-AGENT
- **Architectural Rationale**: Storage is split by workload: Postgres via Prisma for relational app state, ClickHouse for high-volume trace analytics, and Redis-backed BullMQ for async jobs, while a separate Rust Axum service handles latency-sensitive LLM proxying outside the Node runtime.
- **Live Website Reference**: https://langfuse.com
- **Source Repository**: https://github.com/langfuse/langfuse
---
## 2. PRODUCTION TECH STACK
- **Full Stack Array**: TypeScript, Next.js, React, PostgreSQL, ClickHouse, Redis, Rust, Prisma, BullMQ, Turborepo, MinIO, NextAuth.js, Radix UI, Model Context Protocol, Vercel AI SDK
- **Primary Language(s)**: TypeScript, Rust
- **License of the reference repo**: NOASSERTION
- **Frontend**: Next.js — Renders the web dashboard, API routes, and auth pages inside the web workspace.; React — Builds the trace explorer, prompt playground, and settings UI.; Radix UI — Provides accessible primitives; select and focus-management behavior is patched.; NextAuth.js — Handles dashboard auth sessions; patched across three pinned versions.
- **Backend & APIs**: Rust — ai-gateway is a standalone Axum-based Rust service that proxies LLM calls.; BullMQ — Queues ingestion, evaluation, and billing jobs processed by the worker.; Model Context Protocol — The worker exposes an MCP endpoint so in-app agents can query traces.; Vercel AI SDK — Pinned per-provider AI SDK forks evaluate LLM connections in the worker.
- **Data & persistence**: PostgreSQL — Stores relational app state (projects, users, API keys) via Prisma.; Prisma — ORM and migration tool for the Postgres schema in packages/shared/prisma.; ClickHouse — Stores traces, observations, and scores at analytics scale.; Redis — Backs BullMQ queues and caching for the web app and worker.; MinIO — S3-compatible object storage for blob exports and media in local/dev compose.
- **Infrastructure & deploy**: Docker — Each service (web, worker, ai-gateway) ships its own multi-stage Dockerfile.; Turborepo — Orchestrates builds, tests, and dev servers across the pnpm workspace.; GitHub Actions — Runs CI/CD: CodeQL, Snyk, Semgrep scans, preview deploys, and releases.
---
## 3. KEY ARCHITECTURAL DECISIONS (audited from https://github.com/langfuse/langfuse @ 6e9f8eb)
1. **Traces live in ClickHouse; app state lives in Postgres**: Langfuse splits storage by access pattern: Postgres (modeled via Prisma in packages/shared/prisma) holds projects, users, and API keys, while ClickHouse absorbs the high-volume trace, observation, and score data, wired through the CLICKHOUSE_MIGRATION_URL variable in docker-compose.yml.
2. **The AI gateway is a separate Rust service, not a Node module**: ai-gateway/Cargo.toml defines a standalone Axum-based Rust binary with its own Dockerfile, keeping latency-sensitive LLM proxying out of the Next.js and worker Node processes so it can be scaled and deployed independently.
3. **A native Rust addon backs performance-critical worker code**: packages/native/Cargo.toml builds a napi-rs addon (langfuse-native) that the worker compiles before starting dev or build, per the @langfuse/native#build task in turbo.json, instead of implementing that logic in pure JavaScript.
4. **Turborepo and pnpm workspaces bind web, worker, and ai-gateway together**: pnpm-workspace.yaml lists web, worker, ai-gateway, packages/**, and ee as workspace members, and turbo.json defines cross-package task dependencies (build depends on db:generate) so a single turbo run build compiles every service consistently.
5. **Enterprise features are isolated in a separately licensed ee/ package**: The ee/ directory ships its own LICENSE and package.json as @langfuse/ee, importing @langfuse/shared via workspace:*, which keeps SSO and other paid features out of the root NOASSERTION-licensed open-source packages.
6. **BullMQ and Redis queue ingestion and evaluation work asynchronously**: worker/package.json depends on bullmq and ioredis; the worker consumes queued jobs (ingestion, evaluation, billing) so the web app API responses stay fast while heavier processing happens out of band.
---
## 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, Prisma, ClickHouse, Redis, MinIO): 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.Frequently asked about Langfuse
What is Langfuse built with?
Langfuse is a TypeScript monorepo: a Next.js web app and a Node worker share Prisma-modeled Postgres data, ClickHouse stores high-volume trace data, and a separate Rust service (ai-gateway) proxies LLM calls.
Does Langfuse require ClickHouse to self-host?
Yes. The default docker-compose.yml wires the worker to ClickHouse via CLICKHOUSE_MIGRATION_URL alongside Postgres, Redis, and MinIO, so a self-hosted instance needs all four services running.
Can I self-host Langfuse?
Yes, the repository ships docker-compose.yml and per-service Dockerfiles for web, worker, and ai-gateway, distinct from the managed Langfuse Cloud offering linked from the README.
What language is the Langfuse AI gateway written in?
The ai-gateway service is written in Rust using the Axum web framework, defined in ai-gateway/Cargo.toml, and runs as its own Docker container distinct from the Node.js web and worker services.
What does the Langfuse architecture look like?
Three deployable services in a pnpm/Turborepo monorepo: a Next.js web app and public API, a Node worker draining BullMQ jobs from Redis, and a Rust AI gateway. Postgres stores app state, ClickHouse stores traces, and S3 stores blobs.
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.
Similar architectures
- OpenMAICClassicMulti-Agent Interactive AI Classroom · 6-20 peopleShares TypeScript · Next.js · React
- UmamiHybridWeb Analytics · SoloShares TypeScript · Next.js · React
- Mem0AI-agentAI Memory & Context Engine · 2-5 peopleShares TypeScript · PostgreSQL · Next.js
- Cal.comClassicScheduling SaaS · 6-20 peopleShares TypeScript · Next.js · React
- Dify.aiAI-agentLLM App Builder · 20+ peopleShares Next.js · TypeScript · Redis
- FormbricksAI-agentSurvey & Feedback SaaS · 2-5 peopleShares Next.js · TypeScript · Prisma