How danny-avila/librechat works
LibreChat is a self-hosted multi-model conversational platform with chat, Agents, Assistants, tools, files, MCP, artifacts, and automation. The principal workflow is: a user submits chat content, authenticated API routes create a run, the run invokes a configured model and optional tools, state is persisted, and streamed events update the client conversation. The graph combines documented capabilities with sampled implementation evidence; several broad subsystems are represented by their exact enclosing paths because their internals were not sampled.
Main entry points: RunManager.js Run Manager · ChatView.tsx Chat UI · messages.js Chat Routes · handleTools.js Tool Runtime
Components 23
Client Experience
- Chat UI
client/src/components/Chat/ChatView.tsx - Query Intake
client/src/hooks/Input/useQueryParams.ts - SSE Events
client/src/hooks/SSE/useEventHandlers.ts - MCP Manager
client/src/hooks/MCP/useMCPServerManager.ts
API Gateway
- Auth Middleware
api/server/middleware/requireJwtAuth.js - Chat Routes
api/server/routes/messages.js - Agent Management
api/server/routes/agents/management.js
AI Runtime
- Run Manager
api/server/services/Runs/RunManager.js - Stream Runs
api/server/services/Runs/StreamRunManager.js - Model Clients
api/app/clients/index.js - Tool Runtime
api/app/clients/tools/util/handleTools.js - MCP Service
api/server/services/MCP.js - Structured Tools
api/app/clients/tools/structured/GoogleSearch.js
Data Services
- File Pipeline
api/server/services/Files/index.js - Conversation Store
api/db/models.js - File Storage
- Data Provider
packages/data-provider/src/react-query/react-query-service.ts
Automation
- Schedule Engine
packages/api/src/schedules/engine.ts - Agent Triggers
packages/api/src/agents/triggers/engine.ts
Other components
- User
- Model Providers
- Search Services
- MCP Servers
Connections 24
- User → Chat UI: submits prompt
- Chat UI → Chat Routes: sends message
- Chat UI → File Pipeline: uploads files
- Query Intake → Chat UI: applies settings
- Chat Routes → Auth Middleware: requires identity
- Auth Middleware → Conversation Store: reads account
- Chat Routes → Run Manager: creates run
- Run Manager → Model Clients: invokes model
- Model Clients → Model Providers: calls provider
- Run Manager → Tool Runtime: dispatches tools
- Tool Runtime → Structured Tools: runs tool
- Structured Tools → Search Services: performs search
- Tool Runtime → MCP Service: dispatches MCP
- MCP Service → MCP Servers: calls server
- Run Manager → Conversation Store: persists state
- Run Manager → Stream Runs: streams run
- Stream Runs → SSE Events: emits events
- SSE Events → Chat UI: updates view
- File Pipeline → File Storage: stores files
- Agent Management → Conversation Store: manages agents
- MCP Manager → Data Provider: queries status
- Data Provider → MCP Service: requests MCP
- Schedule Engine → Run Manager: fires runs
- Agent Triggers → Run Manager: dispatches agents