Poindexter Database Schema
This document defines the database schema Poindexter runs on. The entire system uses PostgreSQL 16 with the pgvector extension through asyncpg. There is no ORM — queries are hand-written SQL, and schema changes are tracked as migration files insrc/cofounder_agent/services/migrations/ (the history is squashed
into 0000_baseline.py, re-rolled most recently by the Phase F squash
on 2026-06-22 (which folded the Phase E baseline + 73 post-E migrations
and retired the pipeline_tasks.category column); new migrations use a
UTC timestamp prefix per poindexter#378).
Last Updated: 2026-06-22
Version: 0.1.x (alpha)
Architecture: PostgreSQL 16 + pgvector + FastAPI + asyncpg background workers
PostgreSQL Database Module Overview
The system uses a modular database architecture with 6 specialized database modules, each handling domain-specific operations:- UsersDatabase - User accounts, OAuth, authentication
- TasksDatabase - Task CRUD, filtering, status management
- ContentDatabase - Posts, articles, publishing metadata
- AdminDatabase - Logging, financial tracking, system health
- WritingStyleDatabase - Writing samples for RAG-based style matching
- EmbeddingsDatabase - pgvector storage and cosine-similarity search (writer-segregated across
brain,audit,posts,memory,claude_sessions,issues,samples)
services/database_service.py::DatabaseService — callers don’t import them directly. See ../reference/services.md for service-level details and GH-106 for the stale-embedding retention policy.
Core Database Tables
1. users Table
Stores user accounts and authentication data.
2. pipeline_tasks Table
Stores the content-generation task queue. The Prefect-orchestrated flow
(services/flows/content_generation.py) claims rows via SELECT ... FOR UPDATE SKIP LOCKED; each task carries a template_slug that picks the
LangGraph template (canonical_blog / dev_diary) to run.
3. posts Table
Stores published blog posts and the awaiting-approval queue. The
canonical content table — the older content example was never the
production shape.
4. audit_log Table
Canonical historical record — every significant pipeline transition,
QA decision, writer-fallback event, etc. lands here. Queried by
routes/pipeline_events_routes.py despite the legacy URL prefix.
5. writing_samples Table
Stores user writing samples for RAG-based style matching.
API Endpoints Reference
All content endpoints are served by the FastAPI backend athttp://localhost:8002.
See the live OpenAPI spec at /api/openapi.json for the full endpoint catalog.
Key content routes:
- Tasks:
/api/tasks(GET, POST, PUT, DELETE) - Content:
/api/content(GET, POST, PUT) - Posts:
/api/posts(GET, POST, PUT, DELETE) - Categories:
/api/categories(GET, POST, PUT, DELETE)
Maintainer: Poindexter is built and maintained by Glad Labs LLC. For questions, open an issue on the public repo.