Installation
Prerequisites
ChainGraph requires:
- Node.js: Version 22.14.0
- Package Manager: pnpm 10.16.1 or higher
Quick Installation
Clone the repository and install dependencies:
git clone https://github.com/badaitech/chaingraph.git
cd chaingraph
pnpm installRunning in Development Mode
Start the complete development environment (frontend and backend):
pnpm run devThis command launches:
- Frontend development server with hot reloading
- Backend development process in watch mode
Running Components Individually
You can also run each component separately:
Backend only:
pnpm run dev:backFrontend only:
pnpm run dev:frontExecution worker:
pnpm run dev:execution-workerPostgreSQL Database Storage (Optional)
ChainGraph can use PostgreSQL for persistent storage instead of in-memory storage.
1. Start PostgreSQL Database
Use the included Docker Compose configuration:
docker compose up -d postgresThis starts a PostgreSQL instance on port 5432.
2. Configure Database Connection
Create a .env file in the project root:
DATABASE_URL=postgres://postgres:postgres@127.0.0.1:5432/postgres?sslmode=disable3. Run Database Migrations
Before starting ChainGraph with PostgreSQL storage, run migrations:
pnpm run migrateThis creates all required tables and indexes in your PostgreSQL database.
4. Start ChainGraph
Once migrations are complete, start ChainGraph normally:
pnpm run devYour flows, nodes, and execution data will now be stored persistently in PostgreSQL.
Building for Production
Build the entire project:
pnpm run buildBuild specific packages:
# Build frontend only
pnpm run build:front
# Build backend only
pnpm run build:backPreview the production build:
pnpm run previewDocker Deployment
Building Docker Images
Build Docker images using the Makefile:
# Build backend image
make docker-build-backend
# Build frontend image
make docker-build-frontend
# Build both images
make docker-build-allOr manually:
# Backend
docker build -t chaingraph-backend -f apps/chaingraph-backend/Dockerfile .
# Frontend
docker build -t chaingraph-frontend -f apps/chaingraph-frontend/Dockerfile .Running with Docker Compose
Launch both containers:
make docker-compose-upOr manually:
docker-compose up -d # Start containers
docker-compose down # Stop and remove containersThis starts:
- Backend on port 3001
- Frontend on port 5173
Debugging Setup
WebStorm
- Open Run/Debug Configurations
- Create a new Bun configuration:
- File:
apps/chaingraph-backend/src/index.ts - Bun parameters:
--conditions=development
- File:
- Set breakpoints in TypeScript files and start debugging
VS Code
Add to .vscode/launch.json:
{
"type": "node",
"request": "launch",
"name": "Debug Backend",
"runtimeExecutable": "bun",
"runtimeArgs": ["--conditions=development", "--watch", "run", "src/index.ts"],
"cwd": "${workspaceFolder}/apps/chaingraph-backend"
}Frontend Debugging (Browser)
- Start dev server:
pnpm run dev:front - Open Chrome/Firefox and navigate to
http://localhost:3004 - Open DevTools (F12) → Sources tab
- Press
Cmd+P(orCtrl+P) to quick-open files - Set breakpoints in
.tsx/.tsfiles
Authentication for GitHub Packages
To use published ChainGraph packages, configure npm authentication:
- Create a personal access token (PAT) with the
read:packagesscope on GitHub - Add to your
.npmrcfile:
@badaitech:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_PATReplace YOUR_GITHUB_PAT with your actual GitHub personal access token.
Verification
After installation, verify everything works:
# Run tests
pnpm test
# Check types
pnpm typecheck
# Lint code
pnpm lintNext Steps
- Quick Start Guide - Build your first flow
- Architecture Overview - Understand the system design
- API Reference - Explore the API documentation
Troubleshooting
Issue: pnpm install fails with peer dependency errors
Solution: These warnings are expected and don't prevent the application from running. They're related to React type versions in the monorepo.
Issue: Database migrations fail
Solution: Ensure PostgreSQL is running and the DATABASE_URL in .env is correct. Check the connection with:
psql "postgres://postgres:postgres@127.0.0.1:5432/postgres?sslmode=disable"Issue: Port already in use
Solution: Check if another process is using the port:
lsof -i :3001 # Backend
lsof -i :3004 # FrontendKill the process or configure a different port in the respective app's configuration.