chain-rdeveloper portal
build

System Architecture

Overview

CHAIN-R is a privacy-first LLM-as-a-service platform. The system is fully containerised and follows a layered microservice architecture where nginx is the only publicly exposed endpoint.

Container Topology

Internet
   ↓
[nginx:8000] ←──────────────── ONLY EXPOSED PORT
   ↓
frontend-network
   ↓
[fe-public]  [fe-core]
                  ↓
             (nginx virtual-host proxy)
                  ↓
             bff-network
                  ↓
         [svc-auth]   [svc-bff]
              ↓              ↓
           [redis]     backend-network
                             ↓
                    [svc-core]   [svc-ai]
                         ↓            ↓
                    db-network    ai-network (internal)
                         ↓            ↓
                  [postgres-core] [postgres-ai]
                                  [qdrant]
                                  [minio]
                                  [docling]
                  graph-db-network (internal)
                         ↓
                      [neo4j] ←── (svc-core)
                  file-storage-network (internal)
                         ↓
              [minio] [qdrant] [docling] ←── (svc-core)
                  ai-egress-network
                         ↓
              [Amazon Bedrock, web search, pages, tools] ←── (svc-ai only)
                  feed-egress-network
                         ↓
              [dashboard feed publishers] ←── (svc-core only)

Virtual Hosts

All traffic enters on port 8000 and is routed by nginx hostname:

HostDestinationNotes
app.dev.datachainr.comfe-core + svc-bff for /api/*Session-gated via auth_request
auth.dev.datachainr.comsvc-authOAuth2 / Auth0 flow endpoints

Services

Edge & Routing

ServicePurpose

Frontend

ServicePurpose
fe-publicPublic-facing React app — marketing and Auth0 login redirect

Backend

ServicePurpose
svc-bffBackend-for-Frontend — proxies authenticated frontend requests to svc-core with injected identity headers
svc-coreCore business logic, resource CRUD, conversation persistence, orchestration of AI operations
svc-aiLLM execution (LiteLLM), multi-agent graphs (LangGraph), RAG, streaming SSE, simulation

Data & Storage

ServicePurpose
postgres-coreRelational database for svc-core (agents, knowledge, conversations, etc.)
postgres-aiRelational database for svc-ai (model/provider registry, LLM invocations)
neo4jGraph knowledge bases
qdrantVector database for RAG (semantic search over knowledge documents)
minioS3-compatible object storage for knowledge base documents
doclingDocument parsing service (PDF, DOCX → structured text)

Request Flow

Unauthenticated Request

Browser → nginx (app.dev.datachainr.com)
  → auth_request → svc-auth /verify → 401
  → nginx redirects to svc-auth /login
  → svc-auth → Auth0 /authorize
  → Auth0 → svc-auth /callback
  → svc-auth stores tokens in Redis, sets HTTP-only session cookie
  → redirect to app

Authenticated API Request

Browser → nginx (app.dev.datachainr.com/api/*)
  → auth_request → svc-auth /verify → 200 (X-User-Id, X-Session-Id)
  → nginx → svc-bff
  → svc-bff reads access_token from Redis, injects identity headers + mints internal JWT
  → svc-bff → svc-core (Authorization: Bearer <token>, X-Internal-Token, X-User-Id, X-User-Email)
  → svc-core verifies X-Internal-Token, mints aud=svc-ai token
  → svc-core → svc-ai (for LLM execution / model registry; svc-ai verifies X-Internal-Token)

LLM Streaming

Browser (EventSource) → svc-bff /ws/* → svc-core → svc-ai
  → svc-ai streams SSE frames: status → token → token → done
  → svc-core streams through to svc-bff → nginx → browser

Network Segments

NetworkMembers
bff-networknginx, svc-auth, svc-bff, redis
backend-networksvc-bff, svc-core, svc-ai
db-networksvc-core, postgres-core
ai-networksvc-ai, postgres-ai, qdrant, minio, docling, neo4j
graph-db-networksvc-core, neo4j
file-storage-networksvc-core, minio, qdrant, docling
ai-egress-networksvc-ai (outbound: Amazon Bedrock, web search, page and feed fetches, tools)
feed-egress-networksvc-core (outbound: dashboard feed publishers)

Authentication

Auth0 is the identity provider. No local username/password system exists.

  • Tokens (access + refresh) are stored server-side in Redis only — the browser never sees them.

  • The browser holds a signed HTTP-only session cookie containing only a session ID.

  • nginx enforces authentication via auth_request on every request to app.dev.datachainr.com before the request reaches svc-bff.

  • svc-core maintains a local users table as a mirror of Auth0 identity, keyed on auth0_id, for relational resource ownership.

See security/auth-flow.md for the detailed login, verify, and logout flows.

Database Ownership

Each service owns its database exclusively — no cross-database foreign keys. Inter-service data access is via API calls only.

ServiceDatabaseStatus
svc-aipostgres-aiIn place
svc-auth(dedicated Postgres planned)Not yet added
svc-bff(dedicated Postgres planned)Not yet added

See data/schema.md for the full entity breakdown per service.