Exploring Postgres 17 via demo of Postgres-only Slack Shared Todo App Backend
+----------------------+ enqueue (INSERT) +----------------------------------+
| Producers | --------------------------------> | PostgreSQL |
| (FE API/Batch/etc.) | | scheduled_reminders table |
+----------------------+ | - status FSM |
| / | - (status, scheduled_for) index |
| LISTEN/NOTIFY wakeups / | - visibility_timeout |
v / | - retry_count |
+-------------------+ poll (FOR UPDATE SKIP LOCKED) | - NOTIFY/LISTEN |
| Workers (N) | <------------------------------------ | |
| (Docker/VM) | -----> update status=processing +----------------------------------+
| | -----> set visibility_timeout=now()+lease duration
| | -----> do work (idempotent side effects)
| | -----> ACK (sent) or NACK (failed + retry++)
+-------------------+
|
| cleanup (TTL by posted_at)
v
+-------------------+
| Cleanup Job |
+-------------------+
|
| metrics/logs (When needed)
v
+-------------------+
| Monitoring/Alert |
| (Grafana/ELK) |
+-------------------+
FTS(Full text search) with
CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE INDEX idx_todos_payload_fts ON todos USING GIN (to_tsvector('simple', payload::text));
CREATE INDEX idx_todos_description_trgm ON todos USING GIN (description gin_trgm_ops);
Environment Variables: Create a .env file in the project root:
# Database Configuration
POSTGRES_PASSWORD=your-strong-postgres-password
POSTGRES_USER=postgres
POSTGRES_DB=postgres
DB_USER=slack_todo_user
DB_PASSWORD=your-db-user-password
DB_NAME=slack_todo_db
# Slack Configuration
SLACK_BOT_TOKEN=your-slack-bot-tokenFor detailed database setup instructions, see db/README.md.
# Start database, worker, and adminer
docker compose up -d
# Check service status
docker compose ps
# View logs
docker compose logs -f# Create virtual environment
uv venv
# Activate virtual environment
source .venv/bin/activate # Linux/Mac
# or
.venv\Scripts\activate # Windows
# Install dependencies
uv pip install -r requirements.txt
# Run FastAPI with hot reload
uvicorn main:app --reload- Database: PostgreSQL with pg_cron extension
- Worker: Background reminder processing
- Adminer: Database administration UI
- FastAPI: REST API Backend
For detailed setup instructions, see k8s/README.md.