This guide covers setting up and running Ampel for local development.
- Rust 1.95+ - Install via rustup
- Node.js 26+ - Install via nvm or official installer
- pnpm 11.1.3+ - Install via
npm install -g pnpm@latest(corepack was removed from Node.js 23+) - PostgreSQL 16+ - Via Docker or local installation
- Docker - For containerized development
- Redis - For background job queues (optional for basic development)
- Make - For unified command interface
git clone https://github.com/pacphi/ampel.git
cd ampel
# Copy environment template
cp .env.example .envEdit .env with your settings:
# Required
DATABASE_URL=postgres://ampel:ampel@localhost:5432/ampel
JWT_SECRET=your-secret-key-minimum-32-characters-long
# Generate encryption key for PAT storage
ENCRYPTION_KEY=$(openssl rand -base64 32)
# Personal Access Tokens (add via UI after login)
# See docs/PAT_SETUP.md for instructions on creating PATs# Using Make (recommended)
make install
# Or manually:
cd frontend && pnpm installOption A: Docker (Recommended)
docker run -d --name ampel-postgres \
-e POSTGRES_USER=ampel \
-e POSTGRES_PASSWORD=ampel \
-e POSTGRES_DB=ampel \
-p 5432:5432 \
postgres:16-alpineOption B: Local PostgreSQL
createuser -s ampel
createdb -O ampel ampelAmpel provides a unified Makefile for all common operations:
make help # Show all available commands
# Build
make build # Build everything (debug)
make build-release # Build everything (release)
make clean # Clean all artifacts
# Development
make dev-api # Start API server
make dev-worker # Start background worker
make dev-frontend # Start frontend dev server
# Testing
make test # Run all tests
make test-backend # Run backend tests only
make test-frontend # Run frontend tests only
# Code Quality
make lint # Run all linters
make format # Format all code
make format-check # Check formatting
# Docker
make docker-build # Build Docker images
make docker-up # Start Docker services
make docker-down # Stop Docker services# Using Make
make build-backend
# Or directly
cargo build
# Release build
cargo build --release# Using Make
make dev-api
# With hot reload (requires cargo-watch)
cargo install cargo-watch
cargo watch -x 'run --bin ampel-api'
# Or run directly
cargo run --bin ampel-apiThe API server starts at http://localhost:8080.
# Using Make
make dev-worker
# Or directly
cargo run --bin ampel-worker# Using Make
make test-backend
# Or directly
cargo test --all-features
# Specific crate
cargo test -p ampel-core
# With output
cargo test -- --nocapture# Using Make
make lint-backend # Run clippy
make format-backend # Format with rustfmt
# Or directly
cargo fmt
cargo clippy --all-targets --all-features -- -D warnings
# Security audit
make audit-backend
# or: cargo auditMigrations run automatically on API startup. For manual control:
# Using sea-orm-cli
cargo install sea-orm-cli
# Generate migration
sea-orm-cli migrate generate create_table_name
# Run migrations
sea-orm-cli migrate up
# Rollback
sea-orm-cli migrate downcd frontend
pnpm install# Using Make (from root)
make dev-frontend
# Or directly
cd frontend && pnpm run devThe frontend starts at http://localhost:5173 with hot reload.
# Development server
pnpm run dev
# Type checking
pnpm run type-check
# Linting
pnpm run lint
# Run tests
pnpm test
# Run tests in watch mode
pnpm test -- --watch
# Production build
pnpm run build
# Preview production build
pnpm run previewWe use shadcn/ui. To add components:
pnpm dlx shadcn-ui@latest add button
pnpm dlx shadcn-ui@latest add cardmake docker-build # Build all images# API Image
docker build -t ampel-api:dev -f docker/Dockerfile.api .
# Worker Image
docker build -t ampel-worker:dev -f docker/Dockerfile.worker .
# Frontend Image
docker build -t ampel-frontend:dev \
--build-arg VITE_API_URL=http://localhost:8080/api \
-f docker/Dockerfile.frontend .cd docker
docker compose build| Crate | Purpose |
|---|---|
ampel-api |
REST API server (Axum), HTTP handlers, middleware |
ampel-core |
Business logic, domain models, services |
ampel-db |
Database layer (SeaORM), entities, migrations, queries |
ampel-providers |
Git provider integrations (GitHub, GitLab, Bitbucket) |
ampel-worker |
Background job processing (Apalis) |
frontend/src/
├── api/ # API client functions
├── components/ # React components
│ ├── ui/ # shadcn/ui components
│ ├── layout/ # Layout components
│ └── dashboard/ # Dashboard-specific components
├── hooks/ # Custom React hooks
├── lib/ # Utilities
├── pages/ # Page components
└── types/ # TypeScript types
ampel/
├── Makefile # Root Makefile (delegates to others)
├── crates/Makefile # Backend-specific targets
└── frontend/Makefile # Frontend-specific targets
Recommended extensions:
- rust-analyzer
- ESLint
- Tailwind CSS IntelliSense
- Prettier
Settings (.vscode/settings.json):
{
"editor.formatOnSave": true,
"rust-analyzer.checkOnSave.command": "clippy",
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}- Install Rust plugin
- Enable ESLint integration
- Configure Prettier for TypeScript
# Check PostgreSQL is running
pg_isready -h localhost -p 5432
# Check connection string
psql $DATABASE_URL -c "SELECT 1"# Find and kill process on port 8080
lsof -i :8080
kill -9 <PID># Clean and rebuild
make clean
make build
# Or directly
cargo clean
cargo buildcd frontend
rm -rf node_modules pnpm-lock.yaml
pnpm install| Variable | Required | Default | Description |
|---|---|---|---|
DATABASE_URL |
Yes | - | PostgreSQL connection string |
JWT_SECRET |
Yes | - | JWT signing secret (min 32 chars) |
ENCRYPTION_KEY |
Yes | - | Base64 32-byte key for PAT encryption |
HOST |
No | 0.0.0.0 |
API server bind address |
PORT |
No | 8080 |
API server port |
RUST_LOG |
No | info |
Log level |
CORS_ORIGINS |
No | - | Comma-separated allowed origins |
Note: Personal Access Tokens are configured per-user via the UI. See PAT_SETUP.md for details.