Development Environment Setup
Comprehensive instructions for establishing a local development environment for CoW Protocol’s Backend For Frontend (BFF) services, which uses an NX monorepo architecture.
Prerequisites
The setup requires three foundational tools:
-
Node.js 20.x - Install via nvm:
-
Yarn - Install globally as the package manager:
-
Docker - Required for running databases, message queues, and other containerized services
Initial Setup
Clone and Install
The installation automatically generates TypeScript types through a postinstall hook.
Environment Configuration
Configure the following in your .env file:
- RPC URLs for blockchain networks (Ethereum mainnet, Gnosis Chain, Arbitrum)
- Database credentials for PostgreSQL
- Optional: Redis and RabbitMQ settings
Use .env for running services locally via NX commands, and .env.docker when running services through Docker Compose.
Infrastructure Services
Docker Compose manages the project’s infrastructure:
Database Migrations
After the database service starts, run migrations:
Development Workflow
Starting Services
NX enables running specific services:
Project Architecture
The monorepo organizes code into:
Applications (/apps/)
- API - Main HTTP API server
- Telegram - Telegram bot consumer
- TWAP - Time-weighted average price service
- Notification Producer - Blockchain event monitor
Shared Libraries (/libs/)
- Repositories - Data access layer
- Services - Business logic
- Shared - Common utilities and types
- Notifications - Notification templates
- Smart Contract ABIs - Contract interfaces
TypeScript Path Aliases
The project uses TypeScript path aliases for module imports:
Common Issues
TypeORM Driver Error
If you encounter pg package resolution errors:
Port Conflicts
Check for existing processes on the required ports:
Docker Container Failures
For persistent Docker issues, perform a full reset:
Useful Commands
Last modified on March 4, 2026