chain-rdeveloper portal
build

Development Setup

Prerequisites

Quick Start

1. Clone & open in Dev Container

Open the repository in VS Code and reopen in container when prompted. The devcontainer installs all tooling automatically.

2. Configure environment files

Environment configuration lives under modules/dotenv/. Example templates are in modules/dotenv/example/.

Copy and fill in each 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 values for Redis password and session secret:

make generate-secrets

3. Configure local DNS

The stack uses virtual-host routing. Add these entries to /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

Use the local.datachainr.com family, not dev.datachainr.com — the latter is the real deployed dev environment's domain. Hosts-mapping it to 127.0.0.1 hijacks every request your machine makes to the live dev server, including outside this stack, and svc-auth's TrustedHostMiddleware will reject the Host header once you do hit the real server, since local.datachainr.com is the family modules/dotenv/dev/environment.env and the nginx vhosts (modules/nginx/conf.d/default.conf) are actually configured for locally.

4. Start the stack

make fullstack          # Build (first run) and start all services
make fullstack build=on # Force rebuild images

Services will be available at:

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

5. Run database migrations

make db-migrate

Auth0 Setup

  1. Create an Auth0 application (Regular Web Application)

  2. Set the allowed callback URL: http://auth.local.datachainr.com:8000/callback

  3. Set the allowed logout URL: http://local.datachainr.com:8000

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

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

Common Commands

Stack

make fullstack           # Start full stack
make fullstack build=on  # Build and start
make fullstack-split     # Start with split tmux logs
make down                # Stop all services
make clean               # Stop and remove volumes
make fresh               # Clean rebuild everything

Dependencies

make install             # Install all dependencies (fe + be)
make update              # Update all dependencies
make rebuild-shared      # Rebuild fe-shared package
make audit               # Frontend security audit

Testing

make test                # Run all tests (svc-ai + svc-core)
make test-ai             # svc-ai tests only
make test-core           # svc-core tests only
make test-cov            # All tests with coverage

Database

make db-shell            # Open psql shell
make db-migrate          # Run Alembic migrations
make db-reset            # Drop, recreate, migrate

Debugging

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

IDE Setup

The workspace uses VS Code Workspaces for module-level settings. Open chainr.code-workspace to get per-module Python interpreters and TypeScript configs applied automatically. See docs/guides/development/IDE.md for full details.