Development Setup
Development Setup
Section titled “Development Setup”This guide walks through setting up a complete local development environment for Valter, from installing prerequisites to verifying that all services are running.
Prerequisites
Section titled “Prerequisites”Before starting, ensure you have the following installed:
| Tool | Version | Purpose |
|---|---|---|
| Python | >= 3.12 | Runtime language |
| Docker + Docker Compose | Recent stable | Database services (PostgreSQL, Qdrant, Redis) |
| make | Any | Canonical command interface |
| Git | Any | Version control |
| uv (recommended) | Recent | Fast Python package manager. Falls back to pip if unavailable. |
Resource requirements: approximately 4 GB RAM and 3 GB disk space (including the embedding model).
Step 1: Clone and Install Dependencies
Section titled “Step 1: Clone and Install Dependencies”Clone the repository and create a Python virtual environment:
git clone <repo-url>cd Valterpython -m venv .venvsource .venv/bin/activateInstall all dependencies including dev tools:
# Preferred: using uv (faster)uv pip install -e ".[dev]"
# Alternative: using pippip install -e ".[dev]"This installs FastAPI, SQLAlchemy, Qdrant client, Neo4j driver, sentence-transformers, and all development tools (pytest, ruff, mypy).
Step 2: Start Database Services
Section titled “Step 2: Start Database Services”The docker-compose.yml file defines three database services for local development:
make docker-upThis starts the following containers:
| Service | Image | Port | Purpose |
|---|---|---|---|
| PostgreSQL | postgres:16-alpine | 5432 | Document metadata, migrations |
| Qdrant | qdrant/qdrant:latest | 6333 | Vector similarity search |
| Redis | redis:7-alpine | 6379 | Caching, rate limiting, ARQ job queue |
Verify the services are running:
docker compose psAll three containers should show running status.
Step 3: Configure Environment
Section titled “Step 3: Configure Environment”Most environment variables have defaults that work with the docker-compose.yml stack. For basic development, no .env file is required.
To enable optional features, create a .env file at the project root:
# .env (optional — only for features you need)
# Groq LLM (enables factual extraction, query expansion)# VALTER_GROQ_API_KEY=gsk_your_key_here# VALTER_GROQ_ENABLED=true
# Neo4j (enables graph features)# VALTER_NEO4J_URI=bolt://localhost:7687
# Remote embedding (skips local model download)# VALTER_EMBEDDING_SERVICE_URL=https://your-service.up.railway.appSee the Environment Variables reference for all available options.
Step 4: Run Database Migrations
Section titled “Step 4: Run Database Migrations”Apply Alembic migrations to set up the PostgreSQL schema:
make migrateThis runs alembic upgrade head using the configuration in migrations/alembic.ini. The migration connects to the database defined by VALTER_DATABASE_URL (defaults to the local PostgreSQL from docker-compose).
Step 5: Download the Embedding Model
Section titled “Step 5: Download the Embedding Model”The semantic search feature requires a pre-trained embedding model:
make download-modelThis downloads rufimelo/Legal-BERTimbau-sts-base (~500 MB) from HuggingFace Hub and caches it at ~/.cache/huggingface/. The download only needs to happen once.
To use a different model:
VALTER_EMBEDDING_MODEL=my-org/my-model make download-modelStep 6: Verify the Setup
Section titled “Step 6: Verify the Setup”Start the development server
Section titled “Start the development server”make devThe API starts at http://localhost:8000. Verify with:
curl http://localhost:8000/v1/healthA successful response confirms that the API is running and database connections are healthy.
Run the test suite
Section titled “Run the test suite”make testThis runs 660+ tests across unit, regression, and MCP test suites. All tests should pass without external service dependencies (stores are mocked in unit tests).
Run linting
Section titled “Run linting”make lintThis runs ruff check and ruff format --check across src/ and tests/.
Make Targets
Section titled “Make Targets”The Makefile is the canonical command interface. Use make <target> for all routine operations.
| Target | Description |
|---|---|
make dev | Start development server with hot reload (port 8000) |
make test | Run the full pytest suite |
make test-cov | Run tests with coverage report |
make test-neo4j-live | Run Neo4j integration tests (requires Aura credentials) |
make lint | Check code style with ruff (check + format verification) |
make fmt | Auto-fix code style issues and format code |
make quality | Run lint, mypy (scoped), and tests together |
make migrate | Apply Alembic database migrations |
make worker-ingest | Start the ARQ background worker for ingest jobs |
make mcp-remote | Start the MCP HTTP server (port 8001) |
make docker-up | Start database containers (PostgreSQL, Qdrant, Redis) |
make docker-down | Stop and remove database containers |
make download-model | Download the embedding model from HuggingFace |
make validate-aura | Validate graph queries against a live Neo4j Aura instance |
Troubleshooting
Section titled “Troubleshooting”Database connection errors
Section titled “Database connection errors”If make migrate or make dev fails to connect to PostgreSQL:
# Check that containers are runningdocker compose ps
# Check PostgreSQL logsdocker compose logs postgres
# Restart the stackmake docker-down && make docker-upPort conflicts
Section titled “Port conflicts”If port 5432, 6333, or 6379 is already in use, either stop the conflicting service or modify the port mappings in docker-compose.yml.
Model download failures
Section titled “Model download failures”If make download-model fails due to network issues, retry or set VALTER_EMBEDDING_SERVICE_URL to use a remote encoding service instead.