Skip to content

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

  1. The browser sends the conversation to LibreChat over HTTPS.
  2. LibreChat resolves the selected Agent and its permissions.
  3. LibreChat calls LiteLLM with a scoped backend credential.
  4. LiteLLM routes the request to the selected local llama.cpp service.
  5. LibreChat stores the conversation in MongoDB and indexes searchable metadata in Meilisearch.
  1. The selected Agent invokes file_search.
  2. LibreChat uses MongoDB permissions to build the authorized file-ID allow-list.
  3. LibreChat sends one batch request to the RAG API on the Railway private network.
  4. The RAG API embeds the query through local/embed-engineering on the Local AI Server.
  5. PostgreSQL/pgvector returns relevant chunks within the allowed file IDs and Agent namespace.
  6. 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.

  1. The Bauer Agent calls the protected search_bauer_twin MCP tool.
  2. The MCP action and numerical fields remain strictly typed, while medium, topology, compressor family, and part category accept open text.
  3. The Bauer Twin terminology resolver normalizes recognized German, English, abbreviation, and chemical-symbol aliases from the PostgreSQL-backed terminology catalogue.
  4. Unknown vocabulary returns unknown_constraint; a recognized but unavailable combination returns no_compatible_match. Neither outcome is retried with weaker constraints.
  5. Compatible candidates pass medium, pressure, topology, family, and category exclusions before text/vector ranking.
  6. Structured synthetic results return to the Agent. The Agent can call file_search separately 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.md
  • D:\02_Code\LibreChat_Setup\librechat.yaml
  • Railway service topology and Bauer MCP contract captured on 2026-07-22
  • Local AI Server overview