How librechat-ai/librechat works
LibreChat is a self-hosted conversational AI application spanning a browser client and an API server. Users configure models or Agents, submit chat turns, and receive streamed responses with tools, attachments, and generated artifacts. The README also describes distinct workflows for authentication, web search, code execution, scheduling, and observability. The graph reflects documented capabilities and relationships visible in the supplied excerpts and source index; some subsystems are represented at directory level because their implementation files were not sampled.
Main entry points: agents Agents · App.jsx Chat UI · StreamRunManager.js Run streaming · Files File workflows
Components 18
Client experience
- Chat UI
client/src/App.jsx - Stream handling
client/src/hooks/SSE/useEventHandlers.ts - Data service
packages/data-provider/src/data-service.ts - Code artifacts
client/src/components/Artifacts/Artifacts.tsx
Conversation runtime
- API routes
api/server/routes/index.js - Chat controllers
api/server/controllers/assistants - Run streaming
api/server/services/Runs/StreamRunManager.js - Model clients
api/app/clients/BaseClient.js
Tools and capabilities
- Agents
api/server/controllers/agents - Tools and search
api/server/services/Tools - MCP integration
packages/api/src/mcp - File workflows
api/server/services/Files - Code execution
api/server/services/Files/Code - Schedules
packages/api/src/schedules/engine.ts
Identity and platform
- Authentication
api/server/services/AuthService.js - Application data
api/db/models.js - Tracing and insights
api/server/routes/traces.js
Other components
- User
Connections 17
- User → Chat UI: uses
README.md - Chat UI → Data service: requests data
- Data service → API routes: calls API
- API routes → Chat controllers: routes chat
- Chat controllers → Run streaming: starts runs
- Run streaming → Model clients: generates responses
- Run streaming → Stream handling: streams events
- Agents → Tools and search: uses tools
README.md - Agents → MCP integration: supports MCP
README.md - Tools and search → File workflows: searches files
- Agents → Code execution: runs code
README.md - User → File workflows: uploads attachments
README.md - User → Schedules: configures runs
README.md - Authentication → Application data: stores sessions
- File workflows → Application data: stores metadata
- Chat UI → Code artifacts: previews output
README.md - User → Tracing and insights: views traces
README.md