Development Guide
Development Guide
Section titled “Development Guide”Generated: 2026-01-04
Prerequisites
Section titled “Prerequisites”- Node.js: ≥18 (check with
node -v) - pnpm: 10.16.1+ (install with
npm install -g pnpm) - Bun: 1.2+ (for whatsapp-web-server)
- Docker: For local PostgreSQL
- Git: Latest version
Initial Setup
Section titled “Initial Setup”1. Clone Repository
Section titled “1. Clone Repository”git clone https://github.com/your-org/NexisChat.gitcd NexisChat2. Install Dependencies
Section titled “2. Install Dependencies”pnpm installThis installs all workspace dependencies and links local packages.
3. Environment Configuration
Section titled “3. Environment Configuration”Each app has its own .env file. Copy the examples:
# Servercp apps/server/.env.example apps/server/.env
# Clientcp apps/client/.env.example apps/client/.env
# WhatsApp Web Servercp apps/whatsapp-web-server/.env.example apps/whatsapp-web-server/.env4. Database Setup
Section titled “4. Database Setup”Start PostgreSQL with Docker:
cd apps/serverdocker compose -f development.docker-compose.yml up -dRun migrations:
pnpm --filter server db:push# orpnpm --filter server db:migrate5. Start Development Servers
Section titled “5. Start Development Servers”# All services (recommended)pnpm dev
# Individual servicespnpm --filter client dev # :3000pnpm --filter server dev # :8787pnpm --filter whatsapp-web-server dev # :8788pnpm --filter landing dev # :4321pnpm --filter docs dev # :3002Project Scripts
Section titled “Project Scripts”Root Level
Section titled “Root Level”| Command | Description |
|---|---|
pnpm dev | Start all dev servers |
pnpm build | Build all packages |
pnpm lint | Lint all packages |
pnpm format | Format all files |
pnpm typecheck | Type-check all packages |
pnpm test | Run all tests |
pnpm clean | Remove build artifacts |
Per-App Scripts
Section titled “Per-App Scripts”Client (apps/client)
Section titled “Client (apps/client)”pnpm --filter client dev # Start dev serverpnpm --filter client build # Production buildpnpm --filter client preview # Preview production buildpnpm --filter client lint # Run ESLintpnpm --filter client typecheck # Type-checkServer (apps/server)
Section titled “Server (apps/server)”pnpm --filter server dev # Start dev serverpnpm --filter server build # Production buildpnpm --filter server test # Run testspnpm --filter server db:push # Push schema to DBpnpm --filter server db:generate # Generate migrationpnpm --filter server db:migrate # Run migrationspnpm --filter server db:studio # Open Drizzle StudioWhatsApp Web Server (apps/whatsapp-web-server)
Section titled “WhatsApp Web Server (apps/whatsapp-web-server)”pnpm --filter whatsapp-web-server dev # Start with Bunpnpm --filter whatsapp-web-server build # Buildpnpm --filter whatsapp-web-server start # Production startUI Package (packages/ui)
Section titled “UI Package (packages/ui)”pnpm --filter ui storybook # Start Storybookpnpm --filter ui build # Build component librarypnpm --filter ui test # Run component testspnpm --filter ui chromatic # Run visual regressionDatabase Management
Section titled “Database Management”Drizzle Commands
Section titled “Drizzle Commands”# Generate migration from schema changespnpm --filter server db:generate
# Apply migrationspnpm --filter server db:migrate
# Push schema directly (dev only)pnpm --filter server db:push
# Open Drizzle Studio (GUI)pnpm --filter server db:studioDatabase Connection
Section titled “Database Connection”DATABASE_URL=postgresql://user:password@localhost:5432/nexischatTesting
Section titled “Testing”Unit Tests
Section titled “Unit Tests”# All testspnpm test
# Specific packagepnpm --filter server testpnpm --filter ui test
# Watch modepnpm --filter server test:watch
# Coveragepnpm --filter server test:coverageComponent Tests (Storybook)
Section titled “Component Tests (Storybook)”# Start Storybookpnpm --filter ui storybook
# Run Storybook testspnpm --filter ui test:storybook
# Visual regression (requires Chromatic token)pnpm --filter ui chromaticCode Quality
Section titled “Code Quality”Linting
Section titled “Linting”# Lint allpnpm lint
# Lint specific packagepnpm --filter client lint
# Auto-fixpnpm lint --fixFormatting
Section titled “Formatting”# Format allpnpm format
# Check formattingpnpm format:checkType Checking
Section titled “Type Checking”# All packagespnpm typecheck
# Specific packagepnpm --filter server typecheckAdding Dependencies
Section titled “Adding Dependencies”To a Specific Package
Section titled “To a Specific Package”# Add to clientpnpm --filter client add react-icons
# Add dev dependencypnpm --filter server add -D vitest
# Add workspace dependencypnpm --filter client add @nexischat/ui@workspace:*To Root (Dev Tools)
Section titled “To Root (Dev Tools)”pnpm add -D -w turboCreating New Components
Section titled “Creating New Components”UI Component
Section titled “UI Component”- Create component directory:
mkdir -p packages/ui/src/atoms/my-component- Create component file:
import { cn } from '../../lib/utils'
interface MyComponentProps { className?: string children: React.ReactNode}
export function MyComponent({ className, children }: MyComponentProps) { return <div className={cn('base-styles', className)}>{children}</div>}- Create story:
import type { Meta, StoryObj } from '@storybook/react'import { MyComponent } from './my-component'
const meta: Meta<typeof MyComponent> = { title: 'Atoms/MyComponent', component: MyComponent}
export default metatype Story = StoryObj<typeof MyComponent>
export const Default: Story = { args: { children: 'Hello World' }}- Export from index:
export * from './atoms/my-component/my-component'Environment Variables
Section titled “Environment Variables”Required Variables
Section titled “Required Variables”Server
Section titled “Server”DATABASE_URL=postgresql://...WORKOS_CLIENT_ID=...WORKOS_API_KEY=...WORKOS_REDIRECT_URI=...BETTER_AUTH_SECRET=...CREEM_API_KEY=...Client
Section titled “Client”VITE_SERVER_URL=http://localhost:8787VITE_WORKOS_CLIENT_ID=...VITE_SENTRY_DSN=...WhatsApp Web Server
Section titled “WhatsApp Web Server”DATABASE_URL=postgresql://...WORKOS_CLIENT_ID=...WORKOS_API_KEY=...WAHA_API_KEY=...Troubleshooting
Section titled “Troubleshooting””Module not found” errors
Section titled “”Module not found” errors”# Clear caches and reinstallpnpm cleanrm -rf node_modulespnpm installTypeScript errors after package changes
Section titled “TypeScript errors after package changes”# Restart TS server in VS CodeCmd+Shift+P → "TypeScript: Restart TS Server"
# Or rebuildpnpm buildDatabase connection issues
Section titled “Database connection issues”# Check Docker is runningdocker ps
# Restart databasecd apps/serverdocker compose -f development.docker-compose.yml downdocker compose -f development.docker-compose.yml up -dPort already in use
Section titled “Port already in use”# Find processlsof -i :3000
# Kill processkill -9 <PID>IDE Setup
Section titled “IDE Setup”VS Code Extensions
Section titled “VS Code Extensions”Recommended extensions (see .vscode/extensions.json):
- ESLint
- Prettier
- Tailwind CSS IntelliSense
- TypeScript Importer
- Prisma (for Drizzle syntax highlighting)
Settings
Section titled “Settings”{ "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, "typescript.preferences.importModuleSpecifier": "relative"}Git Workflow
Section titled “Git Workflow”Branch Naming
Section titled “Branch Naming”feature/description- New featuresfix/description- Bug fixeschore/description- Maintenancedocs/description- Documentation
Commit Messages
Section titled “Commit Messages”Follow Conventional Commits:
feat: add user profile pagefix: resolve login redirect issuechore: update dependenciesdocs: add API documentationPull Requests
Section titled “Pull Requests”- Create feature branch from
main - Make changes with atomic commits
- Run
pnpm lint && pnpm typecheck && pnpm test - Push and create PR
- Wait for CI checks
- Request review
- Squash merge when approved