Complete guide for local development of VideoGen Messenger.
# Clone repository
git clone https://github.com/yourusername/videogen-messenger.git
cd videogen-messenger
# Install backend dependencies
cd backend
npm install
# Copy environment template
cp .env.example .env
# Start development server
npm run dev- Node.js: v18.0.0 or higher
- npm: v9.0.0 or higher
- Docker Desktop: Latest version
- Git: Latest version
- PostgreSQL: v15+ (or use Docker)
- Redis: v7+ (or use Docker)
- Elasticsearch: v8+ (or use Docker)
- Postman/Insomnia: API testing
- pgAdmin: Database management
- RedisInsight: Redis visualization
- Kibana: Elasticsearch management
# PostgreSQL
docker run --name videogen-postgres \
-e POSTGRES_DB=videogen_dev \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-p 5432:5432 \
-d postgres:15-alpine
# Redis
docker run --name videogen-redis \
-p 6379:6379 \
-d redis:7-alpine
# Elasticsearch
docker run --name videogen-elasticsearch \
-e "discovery.type=single-node" \
-e "xpack.security.enabled=false" \
-p 9200:9200 \
-p 9300:9300 \
-d elasticsearch:8.11.0Create docker-compose.dev.yml:
version: '3.8'
services:
postgres:
image: postgres:15-alpine
environment:
POSTGRES_DB: videogen_dev
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
redis:
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
- redis_data:/data
elasticsearch:
image: elasticsearch:8.11.0
environment:
- discovery.type=single-node
- xpack.security.enabled=false
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ports:
- "9200:9200"
- "9300:9300"
volumes:
- es_data:/usr/share/elasticsearch/data
volumes:
postgres_data:
redis_data:
es_data:Start services:
docker-compose -f docker-compose.dev.yml up -dCreate .env file in backend/:
# Application
NODE_ENV=development
PORT=3000
API_VERSION=v1
# Database
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/videogen_dev
DATABASE_POOL_MIN=2
DATABASE_POOL_MAX=10
# Redis
REDIS_URL=redis://localhost:6379
REDIS_DB=0
# Elasticsearch
ELASTICSEARCH_NODE=http://localhost:9200
ELASTICSEARCH_INDEX=videos_dev
# AWS (use LocalStack for local development)
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test
AWS_S3_BUCKET_VIDEOS=videogen-videos-dev
AWS_S3_BUCKET_THUMBNAILS=videogen-thumbnails-dev
AWS_S3_ENDPOINT=http://localhost:4566 # LocalStack
# AI Providers (use test keys for development)
GOOGLE_VEO_API_KEY=your_test_key_here
RUNWAY_API_KEY=your_test_key_here
MINIMAX_API_KEY=your_test_key_here
# Security
JWT_SECRET=dev-secret-change-in-production-min-32-chars
JWT_EXPIRY=24h
API_KEY_SALT=dev-salt-change-in-production
# Rate Limiting
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=1000
# Logging
LOG_LEVEL=debug# Run migrations
npm run migrate
# Check migration status
npm run migrate:status
# Rollback last migration
npm run migrate:rollback
# Seed database with test data
npm run db:seed# Start with auto-reload
npm run dev
# Server will start on http://localhost:3000backend/
├── api/
│ ├── server.js # Express app entry point
│ ├── routes/ # Route definitions
│ │ ├── index.js
│ │ ├── generation.js
│ │ ├── search.js
│ │ ├── trending.js
│ │ ├── videos.js
│ │ └── auth.js
│ ├── controllers/ # Request handlers
│ │ ├── generationController.js
│ │ ├── searchController.js
│ │ ├── trendingController.js
│ │ ├── videoController.js
│ │ └── authController.js
│ ├── middleware/ # Express middleware
│ │ ├── auth.js
│ │ ├── validation.js
│ │ ├── rateLimit.js
│ │ └── errorHandler.js
│ └── utils/ # Utility functions
│ └── logger.js
├── services/ # Business logic
│ ├── generation/
│ │ └── GenerationService.js
│ ├── search/
│ │ └── SearchService.js
│ ├── queue/
│ │ └── QueueService.js
│ ├── trending/
│ │ └── TrendingService.js
│ └── video/
│ └── VideoService.js
├── __tests__/ # Test files
│ ├── unit/
│ ├── integration/
│ └── e2e/
├── migrations/ # Database migrations
├── scripts/ # Utility scripts
├── package.json
└── .env
# Run all tests
npm test
# Run tests in watch mode
npm test -- --watch
# Run tests with coverage
npm test -- --coverage
# Run specific test file
npm test -- generation.test.js
# Run unit tests only
npm test -- __tests__/unit
# Run integration tests only
npm test -- __tests__/integration
# Run E2E tests only
npm test -- __tests__/e2e// .eslintrc.js
module.exports = {
env: {
node: true,
es2021: true,
jest: true
},
extends: 'eslint:recommended',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
rules: {
'no-console': 'warn',
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'prefer-const': 'error',
'no-var': 'error'
}
};{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"printWidth": 100
}# Check for lint errors
npm run lint
# Fix auto-fixable issues
npm run lint -- --fix
# Format code with Prettier
npm run formatfeature/description # New features
bugfix/description # Bug fixes
hotfix/description # Production hotfixes
refactor/description # Code refactoring
test/description # Test additions
docs/description # Documentation updates
Follow conventional commits:
feat: add video sharing functionality
fix: resolve database connection timeout
docs: update API documentation
test: add unit tests for SearchService
refactor: optimize search query builder
perf: improve thumbnail generation speed
chore: update dependencies
# Create feature branch
git checkout -b feature/video-sharing
# Make changes and commit
git add .
git commit -m "feat: add video sharing endpoint"
# Push to remote
git push origin feature/video-sharing
# Create pull request on GitHub
# After review, merge to mainImport the Postman collection:
# Collection located at
docs/postman/VideoGen-Messenger.postman_collection.json# Health check
curl http://localhost:3000/health
# Generate video
curl -X POST http://localhost:3000/api/v1/generate \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{
"prompt": "A beautiful sunset over mountains",
"quality": "hd",
"duration": 5
}'
# Check generation status
curl http://localhost:3000/api/v1/generate/{jobId}/status \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
# Search videos
curl "http://localhost:3000/api/v1/search?q=sunset&limit=10"Create .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Server",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/backend/api/server.js",
"envFile": "${workspaceFolder}/backend/.env"
},
{
"type": "node",
"request": "launch",
"name": "Debug Tests",
"program": "${workspaceFolder}/backend/node_modules/.bin/jest",
"args": ["--runInBand", "--no-cache"],
"console": "integratedTerminal"
}
]
}-
Enable Debug Logging:
LOG_LEVEL=debug npm run dev
-
Use Debugger Statements:
debugger; // Breakpoint in code
-
Inspect Redis:
redis-cli KEYS * GET generation:job:123 -
Check Elasticsearch:
# Check cluster health curl http://localhost:9200/_cluster/health # Search index curl http://localhost:9200/videos_dev/_search?pretty
-
View Logs:
tail -f logs/app.log
-
Create route in
api/routes/:router.post('/new-endpoint', validateRequest, controller.handler);
-
Create controller in
api/controllers/:export async function handler(req, res, next) { try { // Implementation res.json({ success: true }); } catch (error) { next(error); } }
-
Add tests in
__tests__/integration/api/ -
Update API documentation in
docs/API.md
-
Create service file in
services/:class NewService { constructor() {} async method() {} } export default NewService;
-
Add unit tests in
__tests__/unit/services/ -
Import and use in controllers
# Create migration file
touch migrations/002_add_new_table.sql-- Up migration
CREATE TABLE new_table (
id UUID PRIMARY KEY,
name VARCHAR(255)
);
-- Down migration
DROP TABLE new_table;node --prof api/server.js
node --prof-process isolate-*.log > profile.txtnode --inspect api/server.js
# Open chrome://inspect in Chrome# Install autocannon
npm install -g autocannon
# Run load test
autocannon -c 100 -d 30 http://localhost:3000/api/v1/search?q=testSee TROUBLESHOOTING.md for common issues.