Development Guide
Development Guide
Section titled “Development Guide”This guide covers the detailed development setup and workflow for Cosella.
Prerequisites
Section titled “Prerequisites”- Node.js: v22.0.0 or higher
- pnpm: v9.0.0 or higher
- Git: v2.30.0 or higher
- VS Code: Recommended editor
1. Clone and Install
Section titled “1. Clone and Install”git clone https://github.com/cosella/cosella.gitcd cosellapnpm install2. Environment Variables
Section titled “2. Environment Variables”Create .env.local in the root:
# API ConfigurationVITE_API_URL=http://localhost:3000VITE_WS_URL=ws://localhost:3000
# Sentry (optional)VITE_SENTRY_DSN=
# Feature FlagsVITE_FEATURE_NEW_DASHBOARD=true3. Start Development
Section titled “3. Start Development”# Start all appspnpm dev
# Or start specific appspnpm --filter @cosella/dashboard devpnpm --filter @cosella/admin devpnpm --filter @cosella/docs devProject Structure
Section titled “Project Structure”| App | Port | Description |
|---|---|---|
| Dashboard | 5173 | Sales rep daily driver |
| Admin | 5174 | Internal admin panel |
| Docs | 4322 | Documentation site |
| Marketing | 4321 | Public landing page |
| Storybook | 6006 | Component stories |
Packages
Section titled “Packages”| Package | Purpose |
|---|---|
@cosella/ui | UI components |
@cosella/tokens | Design tokens |
@cosella/domain | Domain models |
@cosella/api-client | API client |
Development Commands
Section titled “Development Commands”# Build allpnpm build
# Build specific apppnpm --filter @cosella/dashboard build# Run all testspnpm test
# Run specific package testspnpm --filter @cosella/ui test
# Run with coveragepnpm test -- --coverageType Check
Section titled “Type Check”# Check allpnpm typecheck
# Check specific packagepnpm --filter @cosella/ui typecheck# Lint allpnpm lint
# Lint and fixpnpm lint --fixCode Generation
Section titled “Code Generation”New Package
Section titled “New Package”pnpm gen packageNew Component
Section titled “New Component”pnpm gen componentNew ADR
Section titled “New ADR”Create manually in apps/docs/src/content/docs/engineering/adr-NNNN.mdx.
Git Workflow
Section titled “Git Workflow”Branch Naming
Section titled “Branch Naming”feature/my-feature- New featuresfix/my-bug- Bug fixesdocs/my-docs- Documentation updatesrefactor/my-refactor- Code refactoring
Commits
Section titled “Commits”Follow Conventional Commits:
feat(ui): add new Button variantfix(api-client): handle network errorsdocs(readme): update installation guidePre-commit Hooks
Section titled “Pre-commit Hooks”Automatically runs:
- lint-staged: ESLint + Prettier on staged files
- commitlint: Validates commit messages
IDE Setup
Section titled “IDE Setup”VS Code Extensions
Section titled “VS Code Extensions”- ESLint (
dbaeumer.vscode-eslint) - Prettier (
esbenp.prettier-vscode) - Tailwind CSS IntelliSense (
bradlc.vscode-tailwindcss) - TypeScript Importer (
ms-vscode.vscode-typescript-next)
VS Code Settings
Section titled “VS Code Settings”{ "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" }, "typescript.tsdk": "node_modules/typescript/lib"}Debugging
Section titled “Debugging”VS Code Launch Configurations
Section titled “VS Code Launch Configurations”{ "version": "0.2.0", "configurations": [ { "name": "Launch Dashboard", "type": "node", "request": "launch", "program": "${workspaceFolder}/node_modules/.bin/vite", "args": ["--config", "apps/dashboard/vite.config.ts"], "console": "integratedTerminal" } ]}Browser DevTools
Section titled “Browser DevTools”- React DevTools: Inspect component tree
- TanStack Query DevTools: Inspect cache state
- Network Tab: Monitor API calls
Performance
Section titled “Performance”Bundle Analysis
Section titled “Bundle Analysis”# Analyze bundle sizepnpm build -- --analyzeLighthouse
Section titled “Lighthouse”Run Lighthouse audits in Chrome DevTools.
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”Port Conflicts
Section titled “Port Conflicts”# Find process using portlsof -ti:5173
# Kill processkill -9 <PID>Type Errors
Section titled “Type Errors”# Clear TypeScript cacherm -rf node_modules/.cachepnpm installBuild Failures
Section titled “Build Failures”# Clean buildrm -rf distrm -rf node_modules/.cachepnpm buildNext Steps
Section titled “Next Steps”- Testing Strategy - Testing best practices
- Releases - Release process