Skip to content

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.

Before starting, ensure you have the following installed:

ToolVersionPurpose
Python>= 3.12Runtime language
Docker + Docker ComposeRecent stableDatabase services (PostgreSQL, Qdrant, Redis)
makeAnyCanonical command interface
GitAnyVersion control
uv (recommended)RecentFast Python package manager. Falls back to pip if unavailable.

Resource requirements: approximately 4 GB RAM and 3 GB disk space (including the embedding model).

Clone the repository and create a Python virtual environment:

Terminal window
git clone <repo-url>
cd Valter
python -m venv .venv
source .venv/bin/activate

Install all dependencies including dev tools:

Terminal window
# Preferred: using uv (faster)
uv pip install -e ".[dev]"
# Alternative: using pip
pip install -e ".[dev]"

This installs FastAPI, SQLAlchemy, Qdrant client, Neo4j driver, sentence-transformers, and all development tools (pytest, ruff, mypy).

The docker-compose.yml file defines three database services for local development:

Terminal window
make docker-up

This starts the following containers:

ServiceImagePortPurpose
PostgreSQLpostgres:16-alpine5432Document metadata, migrations
Qdrantqdrant/qdrant:latest6333Vector similarity search
Redisredis:7-alpine6379Caching, rate limiting, ARQ job queue

Verify the services are running:

Terminal window
docker compose ps

All three containers should show running status.

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:

Terminal window
# .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.app

See the Environment Variables reference for all available options.

Apply Alembic migrations to set up the PostgreSQL schema:

Terminal window
make migrate

This 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).

The semantic search feature requires a pre-trained embedding model:

Terminal window
make download-model

This 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:

Terminal window
VALTER_EMBEDDING_MODEL=my-org/my-model make download-model
Terminal window
make dev

The API starts at http://localhost:8000. Verify with:

Terminal window
curl http://localhost:8000/v1/health

A successful response confirms that the API is running and database connections are healthy.

Terminal window
make test

This runs 660+ tests across unit, regression, and MCP test suites. All tests should pass without external service dependencies (stores are mocked in unit tests).

Terminal window
make lint

This runs ruff check and ruff format --check across src/ and tests/.

The Makefile is the canonical command interface. Use make <target> for all routine operations.

TargetDescription
make devStart development server with hot reload (port 8000)
make testRun the full pytest suite
make test-covRun tests with coverage report
make test-neo4j-liveRun Neo4j integration tests (requires Aura credentials)
make lintCheck code style with ruff (check + format verification)
make fmtAuto-fix code style issues and format code
make qualityRun lint, mypy (scoped), and tests together
make migrateApply Alembic database migrations
make worker-ingestStart the ARQ background worker for ingest jobs
make mcp-remoteStart the MCP HTTP server (port 8001)
make docker-upStart database containers (PostgreSQL, Qdrant, Redis)
make docker-downStop and remove database containers
make download-modelDownload the embedding model from HuggingFace
make validate-auraValidate graph queries against a live Neo4j Aura instance

If make migrate or make dev fails to connect to PostgreSQL:

Terminal window
# Check that containers are running
docker compose ps
# Check PostgreSQL logs
docker compose logs postgres
# Restart the stack
make docker-down && make docker-up

If port 5432, 6333, or 6379 is already in use, either stop the conflicting service or modify the port mappings in docker-compose.yml.

If make download-model fails due to network issues, retry or set VALTER_EMBEDDING_SERVICE_URL to use a remote encoding service instead.