Local Development Setup
This guide provides detailed instructions for setting up your local Opik development environment. We offer multiple development modes optimized for different workflows.
Quick Start
Choose the approach that best fits your development needs:
Working with multiple branches? Opik supports multi-worktree development - run multiple environments simultaneously with automatic port isolation.
Prerequisites
Required Tools
- Docker and Docker Compose - For running infrastructure services
- Java 21 and Maven - For backend development
- Node.js 18+ and npm - For frontend development
- Python 3.8+ and pip - For SDK development
Verify Installation
Development Modes
1. Docker Mode (Full Stack)
Best for: Testing complete system, integration testing, or when you need an environment closest to production.
How It Works
The opik.sh script manages Docker Compose profiles to start different combinations of services:
- Infrastructure: MySQL, ClickHouse, Redis, MinIO, ZooKeeper
- Backend: Java backend application
- Frontend: React application
- Optional: Guardrails service
Starting Opik in Docker
Available Profiles
Managing Docker Services
Accessing Services
- UI: http://localhost:5173
- Backend API: http://localhost:8080
- MySQL: localhost:3306
- ClickHouse: localhost:8123
- Redis: localhost:6379
2. Local Process Mode (Fast Development)
Best for: Rapid backend and frontend development with instant code reloading.
How It Works
The dev-runner.sh script:
- Starts infrastructure services in Docker (MySQL, Redis, ClickHouse, etc.)
- Builds backend and runs it as a local process
- Runs frontend with Vite dev server as a local process
- Runs database migrations automatically
Starting Development Environment
Debug Mode
Service Details
Backend Process:
- Port: 8080 (default, may vary with multi-worktree support)
- Logs:
/tmp/opik-<worktree-id>-backend.log - PID file:
/tmp/opik-<worktree-id>-backend.pid - CORS enabled for local frontend
- Auto-built from
apps/opik-backend
Frontend Process:
- Port: 5174 (default, may vary with multi-worktree support)
- Logs:
/tmp/opik-<worktree-id>-frontend.log - PID file:
/tmp/opik-<worktree-id>-frontend.pid - Hot-reload enabled
- Proxies API calls to backend
Infrastructure (Docker):
- Same services as Docker mode
- Ports mapped for local access (may be offset with multi-worktree support)
Port assignments are shown when the environment starts. With multi-worktree support, ports may be offset from the defaults.
Accessing Services
- UI: http://localhost:5174 (local Vite dev server, port may vary)
- Backend API: http://localhost:8080 (port may vary)
- Infrastructure: Same ports as Docker mode (may be offset)
SDK Configuration
After starting, configure the SDK to use your local instance:
IMPORTANT: You must manually edit ~/.opik.config to remove /api from the URL:
Or use environment variables:
If using multi-worktree support, replace 8080 with your actual backend port (shown when the environment starts).
3. BE-Only Mode (Backend Development)
Best for: Backend-focused development when you don’t need to modify frontend code.
How It Works
This mode:
- Starts infrastructure services in Docker
- Starts frontend in Docker (pre-built)
- Runs backend as a local process with hot-reload
The frontend in Docker proxies API calls to your local backend process.
Starting BE-Only Mode
Service Details
Backend Process (Local):
- Port: 8080
- Logs:
/tmp/opik-backend.log - Auto-built and hot-reloadable
Frontend (Docker):
- Port: 5173 (Docker container)
- Pre-built image
- Proxies to localhost:8080
Infrastructure (Docker):
- All infrastructure services
Accessing Services
- UI: http://localhost:5173 (Docker frontend)
- Backend API: http://localhost:8080 (local process)
SDK Configuration
Configure SDK without the manual edit requirement:
Or with environment variables:
4. Infrastructure Only Mode
Best for: SDK development, integration testing, or when you need just the databases.
This gives you access to:
- MySQL on port 3306
- ClickHouse on port 8123
- Redis on port 6379
- MinIO on port 9000
Multi-Worktree Support
Opik supports running multiple development environments simultaneously from different git worktrees. This is useful when you need to work on multiple features or compare branches side-by-side.
How It Works
Each worktree automatically gets:
- Unique port assignments - All services use offset ports to avoid conflicts
- Isolated Docker containers - Separate container namespaces per worktree
- Separate log and PID files - No interference between worktrees
The port offset (0-99) is deterministically calculated from an MD5 hash of your project path, ensuring consistent port assignments across restarts.
Port Assignments
Running Multiple Worktrees
Manual Port Override
If you need specific ports (e.g., to use standard ports or avoid conflicts):
Port Collision Detection
The script automatically checks for port conflicts before starting:
Docker Container Naming
Containers are prefixed with the worktree project name:
- Main repo:
opik-opik-mysql-1,opik-opik-backend-1 - Worktree:
opik-feature-xyz-mysql-1,opik-feature-xyz-backend-1
SDK Configuration for Worktrees
Configure the SDK to use your worktree’s backend port (shown when the environment starts):
Or edit ~/.opik.config:
Windows Development
All scripts have PowerShell equivalents for Windows developers.
Docker Mode (Windows)
Local Process Mode (Windows)
Windows-Specific Notes
- Logs location:
$env:TEMPdirectory - PID files:
$env:TEMPdirectory - Use
Get-Content -Waitinstead oftail -ffor log following - Configuration file:
$env:USERPROFILE\.opik.config
Common Development Tasks
Building Components
Database Migrations
If migrations fail, you may need to clean up:
Viewing Logs
Working with Docker Services
Troubleshooting
Services Won’t Start
If you have port conflicts from another worktree, you can override the port offset:
Build Failures
Database Connection Issues
Process Management Issues
Clean Slate Restart
Development Workflow Examples
Backend Feature Development
Frontend Feature Development
Full Stack Feature Development
SDK Development
Integration Testing
Performance Tips
- Use local process mode for fastest development cycle
- Use BE-only mode if you’re not changing frontend
- Use
--startinstead of--restartwhen dependencies haven’t changed - Enable debug mode only when needed - it increases log verbosity
- Keep Docker images up to date - rebuild periodically with
--build
Best Practices
-
Always run linters before committing:
-
Test migrations locally before committing:
-
Clean up regularly to free disk space:
-
Use debug mode for troubleshooting:
-
Check service status before reporting issues:
IDE Configuration
Opik provides AI coding rules and configurations for editors like Cursor and Claude Code. These are stored in .agents/ and can be synced to your editor of choice using Makefile.
Setup
Directory Structure
Git Hooks
Install pre-commit hooks to automatically run linting before commits:
Next Steps
- Backend Development Guide - Deep dive into backend development
- Frontend Development Guide - Deep dive into frontend development
- Python SDK Development Guide - SDK contribution guidelines
- Testing Guide - Running and writing tests