name: turborepo-workflow description: >- Manage turborepo monorepo development workflow including dev servers, builds, linting, and package management. Use when running dev, build, lint, deploy, or managing workspace packages in this pnpm + turbo monorepo.
Turborepo Workflow
Project Overview
Monorepo managed by pnpm workspaces + Turborepo. Node >= 24, TypeScript 5.
Workspace Layout
apps/
builder/ → Next.js 16 web UI (port 3123)
worker/ → Background workers (BullMQ, Kafka)
realtime/ → Realtime server (port 1999)
cli/ → CLI tool (yargs)
mcp-server/ → MCP server
packages/
database/ → Drizzle ORM + PostgreSQL
ui/ → Shared UI (Tailwind 4, Radix, Dice UI)
utils/ → Shared utilities
redis/ → Redis/Dragonfly client
kafka/ → Kafka client
analytics/ → Analytics services
worker-config/ → BullMQ queues, job types
sdk/ → Types, integration contracts
ai/ → AI model/provider config
events/ → Domain events
flow-config/ → Flow step definitions
mail/ → Email templates
public-apis/ → Public API surface
...
integrations/
messenger/ → Facebook Messenger
whatsapp/ → WhatsApp Business
zalo/ → Zalo OA
tiktok/ → TikTok for Business
telegram/ → Telegram Bot API
webchat/ → In-app webchat
chatbotx/ → Internal chatbot
google-sheets/ → Google Sheets
openai/ → OpenAI integration
Common Commands
Development
# Start all apps in dev mode
pnpm dev
# Start specific app
pnpm --filter builder dev
pnpm --filter worker dev
# Start with HTTPS
pnpm --filter builder https
Build & Lint
# Build all packages (respects turbo dependency graph)
pnpm build
# Lint (uses Biome via Ultracite)
pnpm lint
pnpm fix # auto-fix
# Type checking
pnpm --filter builder check-types
Database
# Full setup (migrate + seed)
pnpm --filter database db:setup
# Migration only
pnpm --filter database db:migrate
# Create new migration
pnpm --filter database make:migration <name>
# Studio (GUI)
pnpm --filter database db:studio
Code Quality
# Check circular dependencies
pnpm check:circular
# Check unused exports (knip)
pnpm check:unused
Package Management
- Use
pnpm add <pkg> --filter <workspace>to add dependencies to specific workspace - Workspace packages use
@chatbotx.io/*scope - Cross-workspace imports:
@chatbotx.io/database/client,@chatbotx.io/ui/button, etc. - Package exports are defined in each
package.jsonexportsfield
Adding a New Workspace Package
When creating a new package (e.g. integrations/<channel>/):
- Create
package.jsonwith"name": "@chatbotx.io/<name>" - Add
"@chatbotx.io/<name>": "workspace:*"to consumerpackage.jsondependencies - Run
CI=true pnpm install --no-frozen-lockfileto link the package- MUST use
CI=trueto avoid TTY confirmation prompt in non-interactive shells - Without this step, imports of the new package will fail with
Cannot find module
- MUST use
Turbo Pipeline
Defined in turbo.json:
builddepends on^build(builds dependencies first), outputs.next/**,dist/**dev,https,packages:devare persistent (long-running)db:migrate,db:setup,db:reset,db:studioare non-cached
Environment
- Root
.envfile is loaded by apps viadotenv -e ../../.env - Env validation uses
@t3-oss/env-core+ Zod inkeys.tsfiles SKIP_ENV_CHECK=trueto bypass validation during build
Git Hooks
- lefthook manages pre-commit hooks (see
lefthook.yml)