Twin Documentation
  • Overview
  • Consumer
  • Developer
  • Operations
Arquitectura
Flujos Técnicos
Base de Datos
Local SetupConventions
powered by Zudoku
Developer

Local Setup

Guide to running the Twin platform locally for development.

Prerequisites

ToolVersionNotes
Node.js20+LTS recommended
PostgreSQL15Local instance
GitLatest

Database Setup

Create the development database:

TerminalCode
createdb twin-dashboard

Default connection string:

Code
postgres://postgres:postgres@localhost:5432/twin-dashboard

Backend

TerminalCode
cd twin-backend # Install dependencies npm install # Run migrations cd packages/database npm run migrate cd ../.. # Run seeds (optional -- populates test data) cd packages/database npm run seed cd ../.. # Build packages in dependency order npm run build -w packages/utils npm run build:types -w packages/utils npm run build -w packages/database npm run build:types -w packages/database npm run build -w packages/shared npm run build:types -w packages/shared npm run build -w packages/dashboard # Start the dashboard API npm run dev -w packages/dashboard # Start the platform API (separate terminal) npm run dev -w packages/platform # Start the cron service (separate terminal) npm run dev -w apps/cron-service

{% hint style="warning" %} Always run both build and build:types for each package. Skipping build:types leaves stale type declarations -- you will see Property X does not exist on type Y errors in consumers. {% endhint %}

Dashboard Frontend

TerminalCode
cd twin-dashboard-frontend # Install dependencies npm install # Create .env in project root cat > .env << EOF VITE_API_URL=http://localhost:3000 VITE_WALLET_CONNECT_PROJECT_ID=development EOF # Start dev server npm run dev

{% hint style="info" %} VITE_WALLET_CONNECT_PROJECT_ID can be set to development locally. WalletConnect features will show a console warning but function for testing. For production-like behavior, get a project ID from cloud.reown.com. {% endhint %}

Platform Frontend

TerminalCode
cd twin-platform-frontend # Install dependencies npm install # Create .env in project root cat > .env << EOF VITE_API_URL=http://localhost:3001 VITE_WALLET_CONNECT_PROJECT_ID=development EOF # Start dev server npm run dev

Test User

After running seeds, a test user is available:

FieldValue
Emailtest@example.com
PasswordSecurePassword123!
AccountAcme Corp
RoleAdmin

Troubleshooting

ProblemCauseSolution
Property X does not exist on type YStale .d.ts in distRun npm run build:types for the affected package
Cannot find module '@twin/database'Packages not builtRun the full build pipeline in order
ECONNREFUSED :5432PostgreSQL not runningStart PostgreSQL service
relation "X" does not existMigrations not runRun npm run migrate in packages/database
ProjectNotFound code 3000Invalid WalletConnect project IDSet VITE_WALLET_CONNECT_PROJECT_ID in .env
403 Forbidden on new endpointRoute not in permissionsAdd to routes-permissions.ts in shared
import { Knex } error in migrationCJS/ESM mismatchUse import type { Knex } instead
Cron job not runningNot registered in all 3 placesCheck cron-keys.ts, manager.ts, cron-handlers.ts
Last modified on May 12, 2026
Database PatternsConventions
On this page
  • Prerequisites
  • Database Setup
  • Backend
  • Dashboard Frontend
  • Platform Frontend
  • Test User
  • Troubleshooting