Development Commands
Essential commands for daily development workflow with Mifty framework.
Quick Start Commands
Start Development Environment
npm run dev
Start API server with hot reload
npm run dev:full
Start complete development environment (API + DB Designer + Monitor + Prisma Studio)
Individual Services
npm run dev:server
Start only the API server
npm run dev:db-designer
Start database designer UI on port 3001
npm run dev:monitor
Start error monitor with auto-fix
Database Development
Visual Database Design
npm run db-designer
Launch visual database designer at http://localhost:3001/ui
Schema Management
npm run prisma:generate
Generate Prisma Client after schema changes
npm run prisma:migrate
Create and apply database migration
npm run prisma:studio
Open Prisma Studio for database browsing
npm run prisma:push
Push schema changes without migration (development only)
Code Generation
Module Generation
npm run generate
Generate all modules from database design
npm run generate:module
Generate specific module
Testing During Development
Continuous Testing
npm run test:watch
Run tests in watch mode - reruns on file changes
npm test
Run full test suite with coverage
Code Quality
Linting and Formatting
npm run lint
Check code quality with ESLint
npm run lint:fix
Auto-fix linting issues
npm run format
Format code with Prettier
Error Monitoring and Debugging
Error Monitoring
npm run monitor
Start error monitoring system
npm run monitor:autofix
Monitor with automatic error fixing
npm run watch:imports
Watch for import issues and report them
Build Commands
Development Build
npm run build
Build TypeScript to JavaScript
npm run build:watch
Build in watch mode - rebuilds on changes
Development Workflows
Standard Daily Workflow
-
Start Development Environment
npm run dev:fullThis starts:
- API server on http://localhost:3000
- DB Designer on http://localhost:3001/ui
- Error monitor
- Prisma Studio on http://localhost:5555
-
Design Database (if needed)
- Open http://localhost:3001/ui
- Design your schema visually
- Save changes
-
Generate Code
npm run generate -
Develop with Testing
npm run test:watch -
Quality Check
npm run lint:fix
npm run format
Database-First Development
-
Start Database Designer
npm run db-designer -
Design Schema
- Use visual designer at http://localhost:3001/ui
- Or edit
src/db.design.tsmanually
-
Generate Modules
npm run generate -
Apply Database Changes
npm run prisma:migrate
npm run prisma:generate -
Verify in Prisma Studio
npm run prisma:studio
Test-Driven Development
-
Start Test Watcher
npm run test:watch -
Write Tests First
- Create test files in
src/tests/ - Write failing tests
- Create test files in
-
Implement Code
- Write code to make tests pass
- Tests automatically rerun
-
Check Coverage
npm test
Service URLs Reference
When running development commands, these services become available:
| Service | URL | Command | Description |
|---|---|---|---|
| API Server | http://localhost:3000 | npm run dev | Main REST API |
| DB Designer | http://localhost:3001/ui | npm run db-designer | Visual database designer |
| Prisma Studio | http://localhost:5555 | npm run prisma:studio | Database browser |
| API Documentation | http://localhost:3000/api-docs | npm run dev | Swagger UI |
Environment Configuration
Development Environment Variables
Create a .env file in your project root:
# Database
DATABASE_URL="postgresql://postgres:password@localhost:5432/mifty_dev"
# Server
PORT=3000
NODE_ENV=development
# Database Designer
DB_DESIGNER_PORT=3001
# JWT
JWT_SECRET=your-jwt-secret-here
# Optional: External Services
# EMAIL_PROVIDER=gmail
# GMAIL_USER=your-email@gmail.com
# GMAIL_APP_PASSWORD=your-app-password
Check Current Configuration
npm run services:config
View current services configuration
Troubleshooting Development Issues
Common Problems and Solutions
Port Already in Use
Problem: Error: listen EADDRINUSE: address already in use :::3000
Solutions:
-
Kill process using the port:
# Windows
netstat -ano | findstr :3000
taskkill /PID <PID> /F
# macOS/Linux
lsof -ti:3000 | xargs kill -9 -
Change port in
.env:PORT=3001
Database Connection Issues
Problem: Cannot connect to database
Solutions:
- Check database URL:
npm run services:config
Verify database configuration
2. Reset database:
```bash
npm run prisma:reset
⚠️ Reset database (deletes all data)
- Generate Prisma Client:
npm run prisma:generate
Regenerate Prisma Client
#### Hot Reload Not Working
**Problem**: Changes not reflected in browser
**Solutions**:
1. Restart development server:
```bash
npm run dev:server
Restart API server only
- Clear cache and restart:
# Clear npm cache
npm cache clean --force
npm run dev
Import Errors
Problem: Module import errors
Solutions:
- Watch for import issues:
npm run watch:imports
Monitor and report import problems
2. Auto-fix imports:
```bash
npm run watch:imports:autofix
Automatically fix import issues
Test Failures After Database Changes
Problem: Tests fail after schema changes
Solutions:
- Regenerate Prisma Client:
npm run prisma:generate
Update Prisma Client with new schema
2. Update test database:
```bash
npm run prisma:migrate
Apply migrations to test database
Performance Tips
Faster Development Startup
-
Use Specific Services: Instead of
npm run dev:full, use only what you need:npm run dev:server- API onlynpm run dev:db-designer- Database designer only
-
Skip Unnecessary Services: Comment out unused services in development
Efficient Testing
- Use Watch Mode:
npm run test:watchfor continuous testing - Test Specific Files:
npm test -- --testPathPattern=userfor specific tests - Skip Coverage:
npm test -- --coverage=falsefor faster runs
Database Performance
- Use Push for Quick Changes:
npm run prisma:pushinstead of migrations during development - Reset When Needed:
npm run prisma:resetto start fresh - Use Studio for Data:
npm run prisma:studioinstead of writing queries
Development Best Practices
Code Quality Workflow
-
Before Committing:
npm run lint:fix
npm run format
npm test -
During Development:
npm run test:watch # Keep running
npm run monitor # Keep running for error detection -
After Database Changes:
npm run generate
npm run prisma:migrate
npm run prisma:generate
Efficient Development Cycle
-
Start with Full Environment:
npm run dev:full -
Make Changes:
- Edit code
- Design database (if needed)
- Write tests
-
Generate and Test:
npm run generate
npm test -
Quality Check:
npm run lint:fix -
Commit:
git add .
git commit -m "Your changes"