Development Setup Guide
Development Setup Guide
Section titled “Development Setup Guide”This guide walks you through setting up a local development environment for Evolution API Lite. You’ll learn how to run the project locally for development, testing, and contribution.
Prerequisites
Section titled “Prerequisites”Before starting, ensure you have:
- Node.js v20.10.0 or higher (Download here)
- npm (comes with Node.js)
- Git for version control
- Docker & Docker Compose (optional, for database services)
- A code editor (VS Code, WebStorm, etc.)
Setup Methods
Section titled “Setup Methods”Choose your preferred setup method:
The project includes a local_install.sh script that automates the entire setup process.
Quick Start
Section titled “Quick Start”-
Clone the Repository
Terminal window git clone https://github.com/EvolutionAPI/evolution-api.gitcd evolution-api -
Run the Installation Script
Terminal window chmod +x local_install.sh./local_install.sh -devThe script will:
- Install NVM (Node Version Manager) if not present
- Install Node.js v20.10.0
- Install project dependencies
- Set up the database
- Start the development server
-
Configure Environment
The script uses
.env.exampleas a template. After the first run, customize your.envfile:Terminal window cp .env.example .env# Edit .env with your preferred settings
Script Options
Section titled “Script Options”- Development mode:
./local_install.sh -dev(starts with hot reloading) - Production mode:
./local_install.sh(builds and starts production server)
For more control over the setup process, follow these manual steps.
Step-by-Step Manual Setup
Section titled “Step-by-Step Manual Setup”-
Clone and Navigate
Terminal window git clone https://github.com/EvolutionAPI/evolution-api.gitcd evolution-api -
Install Node.js Dependencies
Terminal window npm install -
Environment Configuration
Terminal window cp .env.example .envEdit the
.envfile with your development settings:Terminal window # Development server configurationSERVER_URL=http://localhost:8080SERVER_PORT=8080# Database (you can use Docker or local PostgreSQL)DATABASE_PROVIDER=postgresqlDATABASE_CONNECTION_URI='postgresql://user:pass@localhost:5432/evolution?schema=public'# Development API keyAUTHENTICATION_API_KEY=dev-api-key-12345# Enable detailed logging for developmentLOG_LEVEL=ERROR,WARN,DEBUG,INFO,LOG,VERBOSE,DARK,WEBHOOKS,WEBSOCKETLOG_COLOR=trueLOG_BAILEYS=debug -
Database Setup
Generate Prisma client and deploy migrations:
Terminal window npm run db:generatenpm run db:deploy -
Start Development Server
Terminal window npm run dev:serverThis starts the server with:
- Hot reloading on file changes
- TypeScript compilation
- Detailed logging
Development with Docker
Section titled “Development with Docker”For a containerized development environment that closely matches production:
Using Docker Compose for Development
Section titled “Using Docker Compose for Development”-
Build Development Image
Terminal window docker-compose -f docker-compose.dev.yaml buildThis builds a local Docker image with your current code.
-
Start Development Environment
bash docker-compose -f docker-compose.dev.yaml up -d -
View Logs
Terminal window docker-compose -f docker-compose.dev.yaml logs -f api
Hybrid Development Setup
Section titled “Hybrid Development Setup”Many developers prefer running the API locally while using Docker for supporting services:
# Start only database servicesdocker-compose up -d postgres redis
# Run the API locallynpm run dev:serverThis approach provides:
- Fast local development with hot reloading
- Consistent database and cache services
- Easy debugging and IDE integration
Available Scripts
Section titled “Available Scripts”Understanding the available npm scripts helps with development workflow:
Development Scripts
npm run dev:server- Start development server with hot reloadingnpm run start- Start server without building (development mode)npm run build- Build the project for productionnpm run start:prod- Start production server
Database Scripts
npm run db:generate- Generate Prisma clientnpm run db:deploy- Deploy database migrationsnpm run db:studio- Open Prisma Studio (database GUI)npm run db:migrate:dev- Create and apply new migration
Code Quality Scripts
npm run lint- Run ESLint and fix issuesnpm run lint:check- Check for linting issues without fixingnpm run test- Run test suite
Development Workflow
Section titled “Development Workflow”Typical Development Session
Section titled “Typical Development Session”-
Start Services
Terminal window # Option 1: Full Docker setupdocker-compose up -d# Option 2: Hybrid (recommended for development)docker-compose up -d postgres redisnpm run dev:server -
Make Changes
Edit files in the
src/directory. The development server will automatically restart when you save changes. -
Test Changes
Terminal window # Create a test instancecurl -X POST http://localhost:8080/instance/create \-H "Content-Type: application/json" \-H "apikey: dev-api-key-12345" \-d '{"instanceName": "test", "integration": "WHATSAPP_BAILEYS", "qrcode": true}' -
Debug Issues
- Check console output for errors
- Use
npm run db:studioto inspect database - Enable verbose logging in
.env
Database Development
Section titled “Database Development”When working with database changes:
# Make changes to prisma/postgresql-schema.prisma or prisma/mysql-schema.prisma
# Generate new migrationnpm run db:migrate:dev
# The migration will be automatically applied and copied to the appropriate migrations folderIDE Configuration
Section titled “IDE Configuration”VS Code Setup
Section titled “VS Code Setup”Create .vscode/settings.json for optimal development experience:
{ "typescript.preferences.importModuleSpecifier": "relative", "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" }, "files.exclude": { "**/node_modules": true, "**/dist": true }}Recommended Extensions
Section titled “Recommended Extensions”- TypeScript Importer - Auto import management
- ESLint - Code linting
- Prettier - Code formatting
- Prisma - Database schema support
- Docker - Container management
Troubleshooting
Section titled “Troubleshooting”Common Development Issues
Section titled “Common Development Issues”-
Port Already in Use
-
Find and fix port conflicts:
Terminal window # Find process using port 8080lsof -i :8080# Kill the processkill -9 <PID># Or change the port in .envSERVER_PORT=8081
-
-
Database Connection Errors
-
Troubleshoot database issues:
Terminal window # Check if PostgreSQL is runningdocker-compose ps postgres# View database logsdocker-compose logs postgres# Reset databasedocker-compose down -vdocker-compose up -d postgresnpm run db:deploy
-
-
TypeScript Compilation Errors
-
Reset TypeScript environment:
Terminal window # Clear TypeScript cacherm -rf dist/# Reinstall dependenciesrm -rf node_modules package-lock.jsonnpm install# Regenerate Prisma clientnpm run db:generate
-
-
Hot Reloading Not Working
- Ensure you’re using
npm run dev:server - Check file permissions in the project directory
- Try restarting the development server
- Verify your editor isn’t interfering with file watching
- Ensure you’re using
Getting Help
Section titled “Getting Help”If you encounter issues during development:
- Check the logs: Look for error messages in the console output
- Review the documentation: Ensure you’re following the correct procedures
- Search existing issues: Check the GitHub issues
- Join the community: Get help in our Discord or WhatsApp group
Ready to develop! You now have a complete development environment for Evolution API Lite. Start building amazing WhatsApp integrations!