Skip to main content
LibreChat is joining ClickHouse to power the open-source Agentic Data Stack 🎉 Learn more
LibreChat

Project Architecture

Overview of LibreChat's monorepo workspace structure and package boundaries.

Monorepo Structure

LibreChat is organized as a monorepo with clearly defined workspace boundaries:

WorkspaceLanguageSideDependencyPurpose
/apiJS (legacy)Backendpackages/api, packages/data-schemas, packages/data-provider, @librechat/agentsExpress server — minimize changes here
/packages/apiTypeScriptBackendpackages/data-schemas, packages/data-providerNew backend code lives here (TS only, consumed by /api)
/packages/data-schemasTypeScriptBackendpackages/data-providerDatabase models/schemas, shareable across backend projects
/packages/data-providerTypeScriptShared—Shared API types, endpoints, data-service — used by both frontend and backend
/clientTypeScript/ReactFrontendpackages/data-provider, packages/clientFrontend SPA
/packages/clientTypeScriptFrontendpackages/data-providerShared frontend utilities
/packages/chatTypeScriptFrontendpackages/data-provider, packages/client@librechat/chat: chat state, transport, and message components moving out of /client; never imports the app

Key Principles

  • All new backend code must be TypeScript in /packages/api.
  • Keep /api changes to the absolute minimum — thin JS wrappers calling into /packages/api.
  • Database-specific shared logic belongs in /packages/data-schemas.
  • Frontend/backend shared API logic (endpoints, types, data-service) belongs in /packages/data-provider.

Build and Install

CommandPurpose
npm run smart-reinstallInstall deps (if lockfile changed) + build via Turborepo
npm run reinstallClean install after changing Node/npm versions or when dependency state is suspect
npm run buildBuild all compiled code via Turborepo (parallel, cached)
npm run frontendBuild all compiled code sequentially (legacy fallback)
npm run build:data-providerRebuild packages/data-provider after changes
npm run backendStart the backend server
npm run backend:devStart backend with file watching (development)
npm run frontend:devStart frontend dev server with HMR (port 3090, requires backend running)
  • Node.js: v24.22.1
  • npm: v11.13.0
  • Database: MongoDB
  • Backend runs on http://localhost:3080/; frontend dev server on http://localhost:3090/

Note

For the full set of coding standards and conventions, see Code Standards and Conventions.

Shared Schema and Component Compatibility

The v0.8.9-rc1 shared packages use Zod 4. Consumers composing librechat-data-provider schemas should use compatible Zod 4 APIs and infer input/output types from the exported schema rather than relying on Zod 3 internals. Rebuild custom package consumers together; forcing Zod 3 through an override is not a compatibility path.

The client package no longer exports the legacy Select, SelectDropDown, Dialog, DialogTemplate, or Radix DropdownMenu controls. Use the maintained Dropdown-based selectors and dialog primitives used by current LibreChat callers. See the upgrade guide.

How is this guide?