<h1 align="center">
<a href="https://prompts.chat">
Langfuse is an open-source LLM engineering platform that helps teams collaboratively develop, monitor, evaluate, and debug AI applications.
Sign in to like and favorite skills
Langfuse is an open-source LLM engineering platform that helps teams collaboratively develop, monitor, evaluate, and debug AI applications. The main feature areas are tracing, evals and prompt management. Langfuse consists of the web application (this repo), documentation, python SDK and javascript/typescript SDK. This repo contains the web application, worker, and supporting packages but notably not the JS nor Python client SDKs.
High level structure. There are more folders (eg for hooks etc).
langfuse/ ├── web/ # Next.js 14 frontend/backend application │ ├── src/ │ │ ├── components/ # Reusable UI components (shadcn/ui) │ │ ├── features/ # Feature-specific code organized by domain │ │ ├── pages/ # Next.js pages (Pages Router) │ │ └── server/ # tRPC API routes and server logic │ └── public/ # Static assets ├── worker/ # Express.js background job processor │ └── src/ │ ├── queues/ # BullMQ job queues │ └── services/ # Background processing services ├── packages/ │ ├── shared/ # Shared types, schemas, and utilities │ │ ├── prisma/ # Database schema and migrations │ │ └── src/ # Shared TypeScript code │ ├── config-eslint/ # ESLint configuration │ └── config-typescript/ # TypeScript configuration ├── ee/ # Enterprise Edition features ├── fern/ # API documentation and OpenAPI specs ├── generated/ # Auto-generated client code └── scripts/ # Development and deployment scripts
This is a pnpm + Turbo monorepo with the following key packages:
/web/ - Next.js 14 application (Pages Router) providing both frontend UI and backend APIs/worker/ - Express.js background job processing server/packages/shared/ - Shared database schema, types, and utilities/ee/ - Enterprise Edition features (separate licensing)/packages/config-eslint/ - Shared ESLint configuration/packages/config-typescript/ - Shared TypeScript configurationpnpm i # Install dependencies pnpm run dev # Start all services (web + worker) pnpm run dev:web # Web app only (localhost:3000) - **used in most cases!** pnpm run dev:worker # Worker only pnpm run dx # Full initial setup: install deps, reset DBs, resets node modules, seed data, start dev. USE SPARINGLY AS IT WIPES THE DATABASE & node_modules
database commands are to be run in the
packages/shared/ folder.
pnpm run db:generate # Build prisma models pnpm run db:migrate # Run Prisma migrations pnpm run db:reset # Reset and reseed databases pnpm run db:seed # Seed with example data
pnpm run infra:dev:up # Start Docker services (PostgreSQL, ClickHouse, Redis, MinIO) pnpm run infra:dev:down # Stop Docker services
pnpm --filter=PACKAGE_NAME run build # Runs the build command, will show real typescript errors etc. pnpm tc # Fast typecheck across all packages (alias for pnpm typecheck) pnpm build:check # Full Next.js build to alternate dir (can run parallel with dev server)
The web package uses JEST for unit tests. Depending on the file location (sync, async)
web related tests must go into the web/src/__tests__/ folder.
pnpm test-sync --testPathPatterns="$FILE_LOCATION_PATTERN" --testNamePattern="$TEST_NAME_PATTERN" # For tests in the async folder: pnpm test -- --testPathPatterns="$FILE_LOCATION_PATTERN" --testNamePattern="$TEST_NAME_PATTERN" # For client tests: pnpm test-client --testPathPatterns="buildStepData" --testNamePattern="buildStepData"
The worker uses
vitest for unit tests.
pnpm run test --filter=worker -- $TEST_FILE_NAME -t "$TEST_NAME"
pnpm run format # Format code across entire project pnpm run nuke # Remove all node_modules, build files, wipe database, docker containers. **USE WITH CAUTION**
/web/)zod/v4)/worker/)/web/src/features/[feature-name]/web/src/server/api/root.ts)@/src/components/ui@/src/components/web/src/pages/api/publicwithMiddlewares.ts wrapper/web/src/features/public-api/types with strict Zod v4 objectsdatasets-api.servertest.ts)/fern/, then regenerate OpenAPI spec via Fern CLI/web/src/features/rbac/README.md for authorization patterns/web/src/features/entitlements/README.md)golang-migrate CLI for database migrationsit or test block to ensure that they can run independently and concurrently. Tests must never depend on the action or outcome of previous or subsequent tests.pruneDatabase calls..nvmrc).env.dev.example to .envWhen running locally with seed data:
[email protected]passwordhttp://localhost:3000/project/7a88fb47-b4e2-43b8-a06c-a5ce950dc53aTo get a project, use the
get_project capability with the full project name as it is in the title.
any type// ❌ Bad - positional arguments are unclear and can be swapped without type errors function sendMessage(userId: string, sessionId: string, projectId: string) { // ... } sendMessage(someString, someOtherString, anotherString); // Which is which? // ✅ Good - params object makes intent clear and prevents argument swapping function sendMessage(params: { userId: string; sessionId: string; projectId: string }) { // ... } sendMessage({ userId: someString, sessionId: someOtherString, projectId: anotherString });