WARP.md
This file provides guidance to WARP (warp.dev) when working with code in this repository.
WARP.md
This file provides guidance to WARP (warp.dev) when working with code in this repository.
Project Overview
PlaygreSQL is a Docker-based development environment for testing PostgreSQL extensions (PostGIS, TimescaleDB, pgVector) using Django ORM with Python 3.14 and the uv package manager. This is a development environment only and is not production-ready.
Architecture
Multi-Container Setup
The project uses Docker Compose with three services:
- db (PostgreSQL 16): Custom-built container with PostGIS 3.4, TimescaleDB, and pgVector extensions pre-installed and enabled via
init.sql - web (Django 5.2+): Python 3.14 container running Django with hot-reload for development
- ollama: LLM inference service for local AI experiments
Django Configuration
- Settings:
playgresql/settings.pyconditionally loads PostGIS support based onENABLE_GISenvironment variable - Database Backend: Automatically switches between
django.contrib.gis.db.backends.postgis(whenENABLE_GIS=true) anddjango.db.backends.postgresql - Sample Apps:
series/andvectors/are empty Django apps for TimescaleDB and pgVector experimentation - Demo Models:
extensions_demo.pycontains commented example models for all three extensions with usage patterns
Extension-Specific Patterns
PostGIS Models:
- Use
from django.contrib.gis.db import models as gis_models - Fields:
PointField(),LineStringField(),PolygonField() - Requires
ENABLE_GIS=trueenvironment variable
TimescaleDB Models:
- Use regular Django models with
DateTimeFieldas primary key - Convert to hypertables via migration using
migrations.RunSQL("SELECT create_hypertable('table_name', 'time', if_not_exists => TRUE);") - Time-based queries leverage TimescaleDB's automatic optimizations
pgVector Models:
- Store embeddings using
ArrayField(models.FloatField(), size=DIMENSIONS) - Or use
pgvector.django.VectorField(dimensions=DIMENSIONS)(as seen invectors/models.py) - Query with raw SQL using distance operators:
<=>(cosine),<->(L2),<#>(inner product)
Common Commands
Container Management
Start all services:
./start.sh # Automated with health checks and migrations
Or manually:
docker compose up --build
Stop and remove volumes (full reset):
docker compose down -v
Django Operations
All Django commands must be prefixed with docker compose exec web uv run:
Migrations:
docker compose exec web uv run python manage.py makemigrations
docker compose exec web uv run python manage.py migrate
Django Shell:
docker compose exec web uv run python manage.py shell
Create Superuser:
docker compose exec web uv run python manage.py createsuperuser
Create New App:
docker compose exec web uv run python manage.py startapp <app_name>
Then add to playgresql/settings.py INSTALLED_APPS.
Database Access
From host machine:
psql postgresql://postgres:postgres@localhost:5432/playgresql
Django dbshell:
docker compose exec web uv run python manage.py dbshell
Direct psql:
docker compose exec db psql -U postgres -d playgresql
Verification Commands
Check database health:
docker compose exec db pg_isready -U postgres
Verify extensions:
docker compose exec db psql -U postgres -d playgresql -c "SELECT extname, extversion FROM pg_extension;"
View logs:
docker compose logs -f
docker compose logs -f web # Django only
docker compose logs -f db # PostgreSQL only
Local Development (Optional)
Install dependencies locally without Docker:
uv sync
Run Django commands locally (requires local PostgreSQL):
uv run python manage.py migrate
Linting (ruff is in dev dependencies):
uv run ruff check .
Ollama Usage
Pull model:
docker compose exec ollama ollama pull llama2
Interactive session:
docker compose exec ollama ollama run llama2
From Django (OLLAMA_HOST is pre-configured to http://ollama:11434):
import os
print(os.getenv('OLLAMA_HOST'))
Development Workflow
Adding New Extension Features
- Copy relevant model examples from
extensions_demo.pyto your app'smodels.py - Create migrations:
docker compose exec web uv run python manage.py makemigrations - For TimescaleDB, add a second migration with
RunSQLto create hypertables - For pgVector, add indexes via raw SQL migrations for optimal performance
- Apply migrations:
docker compose exec web uv run python manage.py migrate
Working with TimescaleDB
After creating a time-series model, convert it to a hypertable in a migration:
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [('app_name', 'XXXX_previous_migration')]
operations = [
migrations.RunSQL(
"SELECT create_hypertable('table_name', 'time', if_not_exists => TRUE);",
reverse_sql="SELECT 1;"
),
]
Working with pgVector
Create vector indexes after initial table creation:
migrations.RunSQL(
"CREATE INDEX ON table_name USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100);",
reverse_sql="DROP INDEX IF EXISTS table_name_embedding_idx;"
)
For similarity search, use raw SQL with distance operators in Django shell.
Important Notes
- The web container has hot-reload enabled; code changes reflect immediately without restart
- Database and Ollama data persist in Docker volumes between restarts
- Ollama is mapped to port 11435 (not 11434) to avoid conflicts with local instances
- Use
ENABLE_GIS=trueenvironment variable to enable PostGIS features - All credentials default to
postgres:postgresfor development convenience - Never commit
.envfile (use.env.exampleas template)
Related Documents
Building SupportX AI Assist: A Multi-Agent IT Support System
**Published:** February 9, 2026
Go-Attention API Documentation
This document provides a complete reference for all exported APIs in the go-attention library.
Agent Learnings - Papr Memory Python SDK
This document captures important learnings and best practices discovered while building and maintaining the Papr Memory Python SDK, specifically around on-device processing and Core ML integration.
ML Feedback Loop Analysis
> Design document analyzing how user actions feed back into ML predictions,