Architecture and Boundaries¶
LibreChat is split across two compute locations. Railway hosts the web application and persistent data services. The Fedora Local AI Server hosts model inference. GitHub stores the non-secret deployment configuration and Bauer Twin source code.
For the version-by-version retrieval layout, see the unified Bauer RAG V1 / V2 / V3 architecture.
flowchart LR
User["User browser"] --> Domain["chat.rapiddraft.ai"]
Domain --> LC["LibreChat<br/>Railway"]
LC --> Mongo["MongoDB<br/>Railway volume"]
LC --> Meili["Meilisearch<br/>Railway volume"]
LC --> S3["librechat-files<br/>Railway bucket"]
LC --> RAG["RAG API<br/>Railway"]
RAG --> PG["PostgreSQL + pgvector<br/>Railway volume"]
LC --> MCP["Bauer Twin MCP/API<br/>Railway"]
MCP --> BauerDB["bauer_twin database<br/>Railway PostgreSQL"]
LC --> LiteLLM["LiteLLM<br/>Local AI Server"]
RAG --> LiteLLM
MCP --> LiteLLM
LiteLLM --> Chat["Qwen3-Coder-Next"]
LiteLLM --> Vision["Qwen3-VL 8B"]
LiteLLM --> Embed["Qwen3 Embedding 0.6B"]
GitHub["GitHub configuration repo"] --> LC
GitHub --> MCP
Component locations¶
| Component | Location | Responsibility | Persistent data |
|---|---|---|---|
| Browser | User device | LibreChat UI and Agent selection | Browser session state only |
| DNS/TLS entry | Cloudflare-managed domain | Routes chat.rapiddraft.ai to Railway |
None |
| LibreChat | Railway, US East, one replica | Authentication, conversations, Agents, tool orchestration | Uses MongoDB, Meilisearch, and S3 |
| MongoDB | Railway private network | Users, conversations, Agents, permissions, file metadata | mongodb-volume |
| Meilisearch | Railway private network | Search over LibreChat records | meilisearch-volume |
| RAG API | Railway, one replica | File parsing, embedding, and retrieval integration | Uses VectorDB |
| VectorDB | Railway PostgreSQL 16 + pgvector | RAG chunks, vectors, and the dedicated Bauer database | vectordb-volume |
| File bucket | Railway S3-compatible storage, Amsterdam region | Uploaded source objects | librechat-files |
| Bauer Twin API | Railway, US East, one replica | Structured project, part, document, and comparison search | Uses dedicated PostgreSQL database and login |
| LiteLLM | Local AI Server | Authenticated OpenAI-compatible model gateway | Configuration and operational logs only |
| llama.cpp model services | Local AI Server | Chat, vision, and embedding inference | Model files on the Fedora host |
| Configuration repository | GitHub | Versioned non-secret configuration, provisioning scripts, and Bauer Twin source | Git history |
Request paths¶
Normal chat¶
- The browser sends the conversation to LibreChat over HTTPS.
- LibreChat resolves the selected Agent and its permissions.
- LibreChat calls LiteLLM with a scoped backend credential.
- LiteLLM routes the request to the selected local llama.cpp service.
- LibreChat stores the conversation in MongoDB and indexes searchable metadata in Meilisearch.
File search¶
- The selected Agent invokes
file_search. - LibreChat uses MongoDB permissions to build the authorized file-ID allow-list.
- LibreChat sends one batch request to the RAG API on the Railway private network.
- The RAG API embeds the query through
local/embed-engineeringon the Local AI Server. - PostgreSQL/pgvector returns relevant chunks within the allowed file IDs and Agent namespace.
- LibreChat validates the returned file IDs and supplies the ranked evidence and citations to the chat model.
The full document corpus and its filename inventory are not loaded into every prompt. The model sees a compact document count; relevant chunks and their source names are returned only when the Agent calls file_search. See File Search and RAG Request Flow.
Bauer structured search¶
- The Bauer Agent calls the protected
search_bauer_twinMCP tool. - The MCP action and numerical fields remain strictly typed, while medium, topology, compressor family, and part category accept open text.
- The Bauer Twin terminology resolver normalizes recognized German, English, abbreviation, and chemical-symbol aliases from the PostgreSQL-backed terminology catalogue.
- Unknown vocabulary returns
unknown_constraint; a recognized but unavailable combination returnsno_compatible_match. Neither outcome is retried with weaker constraints. - Compatible candidates pass medium, pressure, topology, family, and category exclusions before text/vector ranking.
- Structured synthetic results return to the Agent. The Agent can call
file_searchseparately for page-level public-document evidence.
MCP is used here because the Technical Twin exposes actions over structured engineering objects, not passages from uploaded files. file_search remains on the RAG integration because it performs authorized chunk retrieval and citation over the document corpus.
Ownership boundaries¶
| Boundary | Owner |
|---|---|
| LibreChat configuration, runtime overlays, and provisioning | adeelyj/librechat-railway-config |
| LibreChat upstream application | Digest-pinned danny-avila/LibreChat image beneath the reviewed overlay |
| Railway services and persistence | Railway project bk-RAG-test |
| Model serving | Local AI Server |
| Product-owned CAD, approval, artifact, and viewer contracts | RapidDraft |
| Synthetic Bauer search schema and logic | Bauer Twin service in the configuration repository |
LibreChat is a candidate runtime behind a future RapidDraft Agent gateway. It is not currently embedded in RapidDraft and does not own RapidDraft's stable Agent or CAD contracts.
Network boundary¶
Only the LibreChat application, RAG health endpoint, and Bauer health endpoint require public HTTP routes for current operations. Database services remain on Railway's private network. Model endpoints are protected backend services; browser code must never receive the shared LibreChat-to-LiteLLM credential.
Sources¶
D:\02_Code\LibreChat_Setup\README.mdD:\02_Code\LibreChat_Setup\librechat.yaml- Railway service topology and Bauer MCP contract captured on 2026-07-22
- Local AI Server overview