a love letter to tangled (android, iOS, and a search API)
title: ADR - Choose PostgreSQL And Coolify For Search Storage updated: 2026-03-26 status: accepted#
Decision#
Twisted will use PostgreSQL as the primary database backend for search,
indexing, queue state, and activity cache. The production deploy target is one
Compose stack for postgres, migrate, api, indexer, tap, and
llama-embeddings. Coolify can host that stack, but the Compose file remains
the source of truth.
Why#
- PostgreSQL is the better fit for long-running multi-service deployment.
- Coolify still gives the project a straightforward Git-to-deploy path with built-in Traefik when we want it.
- The current service shape already wants two long-lived processes writing to one shared database.
- A local PostgreSQL workflow keeps development closer to production than the old Turso split.
Consequences#
Positive#
- one mainstream database for local and remote environments
- simpler production backups and restore story
- easier operational model for
apiandindexer - explicit migration ownership through a one-shot
migratecommand - no dependency on Turso-specific SQLite extension behavior
Negative#
- the search layer must move off SQLite FTS5
- ranking and snippet behavior will change
- SQLite remains only as a temporary rollback path during migration
Search Shape#
Keyword search will use PostgreSQL full-text search:
- weighted
tsvector websearch_to_tsquery('simple', ...)ts_rank_cdts_headline
The HTTP response shape stays stable, but exact scores and snippets are not expected to match the previous FTS5 implementation.
Migration Plan#
- add PostgreSQL connection/config support and local defaults
- add a primary PostgreSQL migration set
- move search and store implementations to PostgreSQL
- deploy the Compose stack from
docker-compose.prod.yaml - rebuild data through
backfill,enrich, andreindex - cut traffic over only after smoke checks pass
Explicit Non-Goal#
The default migration does not include a Turso-to-PostgreSQL data import. The serving dataset should be rebuilt from authoritative upstream sources.
Related Records#
docs/adr/pg.mdremains the background research for this decisiondocs/adr/turso.mdis retained as superseded historical context