chain-rdeveloper portal
build

CHAIN-R

Privacy- and sovereignty-focused LLMs-as-a-service.

Democratising AI automation, security, and compliance — orchestrate your LLM fleet, enforce governance, and integrate intelligent agents into your own systems.

Setup · Architecture · Services · Development · Documentation


CI

Coverage: svc-ai svc-core svc-bff svc-auth fe-core fe-public fe-shared


Overview

CHAIN-R is a full-stack, fully-containerised platform that lets users, developers, and organisations build, manage, and customise AI agents, tools, and multi-agent graphs — with security, privacy, and regulatory compliance built in from the ground up.

  • Orchestrate your LLM fleet — manage, monitor, and connect intelligent agents.

  • Ensure compliance & security — protect encrypted data flows across your network with granular access controls, audit trails, and provider-agnostic egress.

  • Integrate into your own systems — drive your LLMs through the CHAIN-R API with custom network configurations.

The platform exposes a rich domain model covering agents, models, conversations, knowledge bases, skills, workers, tools, evaluations, simulations, MCP servers, organisations, and projects — backed by LiteLLM for provider abstraction and LangGraph for multi-agent workflow execution.

Status: the core feature set is implemented and integrated end-to-end. See the roadmap for outstanding work and planned phases.


🧱 Tech Stack

LayerTechnologies
BackendPython 3.12 · FastAPI · Uvicorn · Pydantic v2 · SQLAlchemy 2 · Alembic
AILiteLLM · LangChain · LangGraph · LlamaIndex · OpenAI / Anthropic providers
DataPostgreSQL 16 · Redis 7 · Neo4j 5 (graph) · Qdrant (vectors) · MinIO (object store) · Docling (document parsing)
AuthAuth0 OAuth2 · server-side token storage · signed HTTP-only session cookies
InfraDocker Compose · nginx (reverse proxy + virtual hosts) · isolated bridge networks
ObservabilityGrafana · Prometheus · Loki · Promtail · Tempo (OTLP traces) · cAdvisor · node-exporter
Toolinguv (Python) · npm workspaces (JS/TS) · Make · VS Code Dev Containers · pre-commit · Ruff · Bandit · Pytest · Vitest

🏛 Architecture

Serving architecture

nginx is the only host-exposed port (:8000). Every other service lives on one or more internal Docker networks, segmented by trust boundary. Traffic is routed by virtual host, and the authenticated app surface is session-gated at the proxy via nginx auth_request.

                                  Internet
                                     │
                          ┌──────────▼──────────┐
                          │     nginx :8000     │   ← ONLY EXPOSED PORT
                          └──────────┬──────────┘
                 ┌───────────────────┼────────────────────┐
        dev.datachainr.com   app.dev.datachainr.com   auth.dev.datachainr.com
                 │                   │ (auth_request)        │
          ┌──────▼─────┐      ┌──────▼─────┐                 │
          │ fe-public  │      │  fe-core   │                 │
          └────────────┘      └──────┬─────┘                 │
                                     │ /api/*                 │
                         ┌───────────▼───────────┐    ┌───────▼───────┐
                         │        svc-bff         │◄───┤    svc-auth   │
                         │  (BFF / proxy + JWT)   │    │  (OAuth2)     │
                         └───────────┬───────────┘    └───────┬───────┘
                                     │                        │
                            ┌────────▼────────┐         ┌─────▼─────┐
                            │    svc-core     │         │   redis   │
                            │ (domain / CRUD) │         │ (sessions)│
                            └───┬────────┬────┘         └───────────┘
                  ┌─────────────┘        └──────────────┐
            ┌─────▼─────┐                          ┌─────▼──────┐
            │ postgres- │                          │   svc-ai   │
            │   core    │                          │ (LiteLLM / │
            └───────────┘                          │ LangGraph) │
                                                   └─────┬──────┘
                          ┌──────────────┬──────────────┼───────────────┐
                    ┌─────▼────┐   ┌─────▼────┐   ┌──────▼─────┐   ┌─────▼──────┐
                    │ postgres-│   │  qdrant  │   │   neo4j    │   │   minio    │
                    │    ai    │   │ (vectors)│   │  (graph)   │   │  docling   │
                    └──────────┘   └──────────┘   └────────────┘   └────────────┘
                                                                          │
                                                              ai-egress-network
                                                                          │
                                                       Amazon Bedrock, web search, pages
                                                              (svc-ai egress only)

Virtual hosts (all served on port 8000):

HostRoutes to
app.dev.datachainr.comfe-core (authenticated UI) + /api/* → svc-bff (session-gated)
auth.dev.datachainr.comsvc-auth — OAuth2 login/callback/logout
monitoring.dev.datachainr.comGrafana dashboards

Network segmentation. Each tier sits on a dedicated bridge network; most are internal: true (no outbound access). Notably:

  • frontend-network — nginx ↔ frontends.

  • bff-network — svc-auth / svc-bff ↔ Redis.

  • backend-network (internal) — svc-bff → svc-core → svc-ai.

  • db-network, ai-network, graph-db-network, file-storage-network (internal) — isolate Postgres, Qdrant, MinIO, Neo4j, and Docling.

  • ai-egress-network — svc-ai's only path out: model calls (Amazon Bedrock), web search, page and feed fetches, tool calls. Every fetched URL must be https on 443 to a public address, checked again as the connection opens. svc-core's dashboard feeds use their own feed-egress-network.

  • monitoring-network / otel-network / socket-proxy — observability pipeline.

Authentication. OAuth2 via Auth0. svc-auth runs the full flow; access tokens are stored server-side in Redis only. The browser holds a signed HTTP-only session cookie. For service-to-service defence-in-depth, svc-bff mints a short-lived, audience-bound internal JWT (X-Internal-Token) on every downstream call, which svc-core verifies; svc-core in turn mints tokens that svc-ai verifies. Identity is taken from the verified token rather than trusted from raw headers. See docs/system/security/auth-flow.md.

AI execution. svc-ai uses LiteLLM for provider abstraction and LangGraph for multi-agent workflows, with SSE streaming, RAG over Qdrant, graph context from Neo4j, and document ingestion via Docling/MinIO. svc-core orchestrates AI operations by calling svc-ai — it never calls LLM providers directly.


🧩 Services

ServiceStackResponsibility
fe-coreReact + ViteAuthenticated single-page app for logged-in users (the product UI).
fe-sharedTS / npm packageShared components, hooks, and logic consumed by both apps.
svc-authFastAPI · python-jose · itsdangerous · RedisAuth0 OAuth2 flow and Redis-backed session management.
svc-bffFastAPI · httpx · websockets · PyJWTBackend-for-frontend: proxies frontend requests to backend services, injecting identity.
svc-coreFastAPI · SQLAlchemy · Alembic · Postgres · MinIO · Qdrant · Neo4jCore business logic and CRUD for the full domain model; orchestrates svc-ai.
svc-aiFastAPI · LiteLLM · LangChain · LangGraph · LlamaIndexModel management, multi-agent execution, streaming, RAG, and document processing.
nginxnginx (stable-alpine)Reverse proxy, virtual-host routing, rate limiting, auth_request session gating.
redisRedis 7Session/token store for svc-auth and svc-bff.
postgres-core / postgres-aiPostgreSQL 16Relational stores for svc-core and svc-ai respectively.
neo4j / qdrant / minio / docling—Graph DB, vector DB, object storage, and document parsing for AI/RAG workloads.
ObservabilityGrafana · Prometheus · Loki · Promtail · Tempo · cAdvisor · node-exporterMetrics, logs, and distributed traces.

📁 Repository Layout

.
├── Makefile                  # Primary developer entrypoint (see `make help`)
├── VERSION                   # Current release version
├── chainr.code-workspace     # VS Code multi-root workspace (per-module settings)
├── docs/                     # Documentation
│   ├── SETUP.md              # Full development setup guide
│   ├── guides/               # Developer guides (devcontainer, IDE, git, releases)
│   ├── spec/                 # Auto-generated API / frontend / model specs (`make spec`)
│   └── system/               # System & security design docs
├── infra/                    # Infrastructure configuration
├── modules/                  # The containerised modules
│   ├── docker-compose.yml         # Secure base stack definition
│   ├── docker-compose.override.yml# Dev overlay (host ports, tooling networks)
│   ├── docker-compose.prod.yml    # Prod overlay (no host ports, secure cookies)
│   ├── dotenv/                    # Environment files (+ example/ templates)
│   ├── fe/                        # Frontend — npm workspaces
│   │   ├── core/                  #   authenticated app
│   │   ├── public/                #   public app
│   │   └── shared/                #   shared component/logic package
│   ├── nginx/                     # Reverse proxy config (conf.d/ virtual hosts)
│   ├── monitoring/                # Grafana / Prometheus / Loki / Tempo / Promtail config
│   ├── svc-auth/   svc-bff/   svc-core/   svc-ai/   # Python services
│   └── test/                      # Cross-service integration tests
├── templates/                # Files symlinked across modules (e.g. .dockerignore)
└── tools/                    # Dev workflow scripts (spec, release, changelog, stats)

Each Python service follows a consistent FastAPI layout (app/router(s), app/services, app/db, app/common, app/dependency, app/middleware, with svc-ai additionally exposing agents, inference, knowledge, mcp, skills, and tools).


🚀 Getting Started

Prerequisites

The development environment is fully automated via VS Code Dev Containers — opening the repo and reopening in the container installs all tooling (uv, npm, linters, pre-commit hooks).

1. Clone & open in the Dev Container

Open the repository in VS Code and Reopen in Container when prompted.

2. Configure environment

Environment files live under modules/dotenv/, with templates in modules/dotenv/example/:

cp modules/dotenv/example/auth0.env.example         modules/dotenv/dev/auth0.env
cp modules/dotenv/example/redis.env.example         modules/dotenv/dev/redis.env
cp modules/dotenv/example/ai.env.example            modules/dotenv/dev/ai.env
cp modules/dotenv/example/postgres-core.env.example modules/dotenv/dev/postgres-core.env
cp modules/dotenv/example/postgres-ai.env.example   modules/dotenv/dev/postgres-ai.env
cp modules/dotenv/example/minio.env.example         modules/dotenv/dev/minio.env
cp modules/dotenv/example/neo4j.env.example         modules/dotenv/dev/neo4j.env
cp modules/.env.example                             modules/.env

Optional — dashboard feed widgets (weather, RSS, market):

cp modules/dotenv/example/dashboards.env.example  modules/dotenv/dev/dashboards.env

Weather and RSS work with no configuration. The market widget needs a vendor API key; without one it renders a setup prompt rather than failing.

Optional — platform allowances and plan prices, off unless set:

cp modules/dotenv/example/billing.env.example  modules/dotenv/dev/billing.env

Minimum required values:

FileKey variables
redis.envREDIS_PASSWORD, SESSION_SECRET
ai.envOPENAI_API_KEY and/or ANTHROPIC_API_KEY
postgres-core.envPOSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB
postgres-ai.envPOSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB
minio.envMINIO_ROOT_USER, MINIO_ROOT_PASSWORD
neo4j.envNEO4J_AUTH — one user/password value
.envMINIO_ROOT_USER, MINIO_ROOT_PASSWORD, REDIS_PASSWORD (compose reads these for ${...})

Generate secure random secrets:

make generate-secrets   # prints REDIS_PASSWORD, SESSION_SECRET, INTERNAL_JWT_SECRET

3. Configure local DNS

The stack uses virtual-host routing — add these to your /etc/hosts:

127.0.0.1  local.datachainr.com
127.0.0.1  app.local.datachainr.com
127.0.0.1  auth.local.datachainr.com
127.0.0.1  monitoring.local.datachainr.com

Use the local.datachainr.com family, not dev.datachainr.com — the latter is the real deployed dev environment's domain, and mapping it to 127.0.0.1 in your hosts file hijacks every request your machine makes to it, including outside this stack.

4. Start the stack

make fullstack            # Build (first run) and start everything
make fullstack build=on   # Force-rebuild images
make db-migrate           # Run database migrations

Once running:

URLService
http://app.local.datachainr.com:8000Core app (authenticated)
http://auth.local.datachainr.com:8000Auth service
http://monitoring.local.datachainr.com:8000Grafana
http://localhost:8080svc-core API (direct, dev only)
http://localhost:5000svc-ai API (direct, dev only)
localhost:5432 / localhost:5433postgres-core / postgres-ai (dev only)
http://localhost:7474Neo4j browser (dev only)

5. Auth0 setup

  1. Create an Auth0 application (Regular Web Application).

  2. Allowed callback URL: http://auth.local.datachainr.com:8000/callback.

  3. Allowed logout URL: http://local.datachainr.com:8000.

  4. Create an Auth0 API with audience https://api.<your-domain>.

  5. Copy domain, client ID, client secret, and audience into dotenv/dev/auth0.env.

Full details, including IDE configuration, live in docs/SETUP.md.


🛠 Development

All workflows are driven through make — run make help for the full list.

Stack

make fullstack            # Start full stack
make fullstack-split      # Start with split tmux logs per service
make down                 # Stop all services
make clean                # Stop and remove volumes
make fresh                # Clean rebuild everything
make rebuild              # Rebuild images with no cache

Dependencies

make install              # Install all deps (fe + be) + pre-commit hooks
make update               # Update all dependencies
make rebuild-shared       # Rebuild the fe-shared package
make audit                # Security audit: npm audit fix + Python lockfile scan
make audit-fe             # Node dependencies only (npm audit fix)
make audit-be             # Python lockfiles only (osv-scanner)
make audit-deps           # Every lockfile, Python and Node, in one pass

Dependency vulnerabilities are scanned with osv-scanner against every uv.lock and package-lock.json in the monorepo — on commit, in CI, and on demand. Report-only by default; see docs/system/security/dependency-scanning.md for the severity policy and how to make it blocking.

Code quality

make lint                 # Ruff + Bandit across Python services
make lint-fix             # Auto-fix Ruff violations and reformat

Testing

make test                 # Unit tests (svc-ai + svc-core)
make test-ai              # svc-ai unit tests
make test-core            # svc-core unit tests
make test-cov             # Unit tests with coverage
make test-integration     # Integration tests against the running stack

Frontend apps use Vitest (npm test within each app under modules/fe/).

Logs & utilities

make logs                 # All services
make logs-auth | logs-app | logs-nginx | logs-fe | logs-be
make health               # Check service health endpoints
make ps                   # Show running containers
make shell-be             # Shell into svc-core
make redis-cli            # Open Redis CLI

Database

make db-shell             # Open psql shell
make db-migrate           # alembic upgrade head
make db-reset             # Drop, recreate, and migrate

Documentation & releases

make spec                 # Regenerate docs/spec/ from source
make release-patch        # Patch release (also: release-minor / release-major)

📐 Design Principles

  • Configurable, extensible, well-structured code throughout.

  • Type safety everywhere — typed variables, classes, and functions; OOP, inheritance, and enums used where appropriate.

  • Design patterns (e.g. factories) used to keep object creation and orchestration simple.

  • Tests are mandatory for backend code — Python services are written with Pytest.

Package managers: uv for Python, npm (workspaces) for React/TypeScript.


🗺 Roadmap

The startup roadmap (MVP map, go-to-market timeline, market-evidence plan and investor readiness) lives in docs/business/.

Outstanding hardening work

  1. Dedicated databases for svc-auth and svc-bff — per-service Postgres isolation.

  2. Production hardening — environment-specific secret management. COOKIE_SECURE is already on in the prod overlay.

✅ Done: the Cloudflare → host hop runs through an outbound-only cloudflared tunnel. The host has no inbound ports, and containers can't reach the instance role (docs/system/deployment/cloudflare-tunnel.md).

✅ Done: internal service JWTs — svc-bff mints short-lived, audience-bound tokens that svc-core verifies, and svc-core mints tokens that svc-ai verifies (replacing trust in raw identity headers).

Planned phases

  • Phase 1 — Rules & Governance: policy, routing, and audit rules with a visual rule builder and an inference-time rules engine.

  • Phase 2 — Evals & Versioning: structured eval runs, regression detection, cost/latency breakdowns, and git-like version history for agents/prompts/skills.

  • Phase 3 — Access Control & Secrets Vault: workspace/agent/knowledge-level RBAC and a managed secrets vault referenced by name at runtime.

  • Phase 4 — Sandbox & Operational Tooling: an agent testing sandbox and operational cost/latency dashboards.


📚 Documentation


<sub>CHAIN-R — built with privacy, security, and compliance at its core.</sub>