Available Scripts
Master all the development commands organized by category for efficient development workflow.# Development server
pnpm dev # Start development server with Turbopack
pnpm build # Build for production with Turbopack
pnpm start # Start production server
# Code quality
pnpm lint # Run ESLint for code linting
pnpm lint:fix # Fix ESLint errors automatically
pnpm format # Check code formatting with Prettier
pnpm format:fix # Fix code formatting with Prettier
# Environment setup
pnpm init:env # Interactive environment configurationDevelopment Tools
Essential tools and interfaces for efficient development workflow.Database Management
Drizzle Studio - Visual database interfacepnpm db:studio
# Opens at: http://localhost:4983- Visual table editor with inline editing
- Query builder and SQL console
- Relationship visualization
- Data import/export capabilities
- Migration history tracking
Email Development
Email Preview System- All emails logged in development console
- Real email templates with React Email
- Multi-language template testing
- Resend integration for production
# Trigger test emails in development
# Check terminal output for email content
# All emails are intercepted and loggedPayment Testing
Stripe Integration Tools# Webhook testing (in separate terminal)
pnpm stripe:listen # Listen for local webhooks
pnpm stripe:forward # Forward webhooks to local server- Real-time webhook testing
- Event simulation
- Payment flow debugging
- Subscription lifecycle testing
Code Quality Tools
TypeScript Strict Mode- Complete type safety across the codebase
- Strict null checks enabled
- No implicit any types
- Path mapping configured
- Next.js recommended rules
- TypeScript-specific linting
- Import order enforcement
- Unused variable detection
- Consistent code formatting
- Auto-format on save (if configured)
- Integration with ESLint
- Custom formatting rules
Development Workflow
Daily Development Flow
1
Start Development
# Start the development server
pnpm dev
# Open database GUI (optional)
pnpm db:studio2
Make Changes
- Edit code with full TypeScript support
- Hot reload automatically applies changes
- Database changes auto-sync with schema
3
Test Changes
# Run relevant tests
pnpm test [pattern]
# Run E2E tests for user flows
pnpm test:e2e4
Quality Check
# Check code quality before commit
pnpm lint
pnpm type-check
pnpm formatFeature Development Process
1
Database Changes
# 1. Update schema in src/db/models/
# 2. Generate migration
pnpm db:generate
# 3. Apply to development database
pnpm db:migrate2
Service Layer
# 1. Add service functions in packages/services/
# 2. Write unit tests
pnpm test services
# 3. Update facades if needed3
UI Implementation
# 1. Create/update components
# 2. Add to pages with proper data access layer
# 3. Test UI components
pnpm test components4
Integration Testing
# 1. Write E2E tests for complete user flows
# 2. Test with real data and services
pnpm test:e2eDebugging Strategies
Database Issues:# Check database connection
pnpm db:check
# View data visually
pnpm db:studio
# Reset data if corrupted
pnpm db:reset-seed# Clean build artifacts
pnpm clean
# Rebuild packages
pnpm build:packages
# Check TypeScript errors
pnpm type-check# Run specific test file
pnpm test path/to/file.test.ts
# Run with detailed output
pnpm test --reporter=verbose
# Generate coverage to find untested code
pnpm test:coverageEnvironment-Specific Development
Local Development
Configuration:- Hot reload enabled
- Debug logging active
- Test database connection
- Mock external services
.env.development # Development environment variables
.env.local # Local overrides (not committed)Testing Environment
Setup:# Use test environment
NODE_ENV=test pnpm test
# Test database setup
pnpm db:migrate # With test DATABASE_URL- Isolated test database
- Mocked external services
- Faster execution
- Deterministic data
Production Preparation
Build Testing:# Test production build locally
pnpm build
pnpm start
# Verify all features work in production mode# Analyze bundle size
pnpm build --analyze
# Test with production data structure
# Run full E2E test suite
pnpm test:e2eAdvanced Development Features
Monorepo Architecture
Package Structure:packages/
├── services/ # Business logic and API calls
├── ui/ # Shared UI components
├── shared/ # Common utilities
└── persistence/ # Database models and queries
- Code sharing between apps
- Consistent type definitions
- Centralized business logic
- Independent package testing
Code Generation
Automatic Features:- TypeScript types from database schema
- API route types from service definitions
- Component props from schema validation
- Test fixtures from database models
Performance Monitoring
Development Metrics:- Build time optimization
- Hot reload performance
- Bundle size analysis
- Database query performance
# Bundle analyzer
pnpm build --analyze
# Performance profiling
NODE_ENV=development pnpm dev --profileBest Practices
Code Organization
Layered Architecture: Follow the 5-layer pattern for consistent, maintainable code structure.
- Presentation Layer - React components and pages
- DAL (Data Access Layer) - Cached data access with React
- Facade Layer - Interface between presentation and business logic
- Service Layer - Business logic, validation, and authorization
- Persistence Layer - Database models and repositories
Development Habits
Before Each Commit:# Run the quality trio
pnpm lint # Code quality
pnpm type-check # Type safety
pnpm test # Functionality- Always generate migrations for schema changes
- Test migrations on copy of production data
- Use transactions for multi-step operations
- Keep database seeds up to date
- Write tests for business logic first
- Add integration tests for complex flows
- Use E2E tests for critical user journeys
- Mock external services in unit tests
Performance Tip: Use
pnpm dev with Turbopack for the fastest development experience. Hot reload is optimized for large codebases.