Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/deploy-web-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ jobs:
echo "Starting deploy with IMAGE_TAG=${IMAGE_TAG}"
docker pull "ghcr.io/asherlc/dofek:${IMAGE_TAG}"
docker pull "ghcr.io/asherlc/dofek-ml:${IMAGE_TAG}"
docker pull "timescale/timescaledb-ha:pg18.3-ts2.26.4-all"
docker pull "postgres:18-alpine"
docker pull "ghcr.io/peerdb-io/peerdb-server:stable-v0.36.18"
docker pull "ghcr.io/peerdb-io/flow-api:stable-v0.36.18"
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/review-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,9 @@ jobs:
run: |
set -euo pipefail

docker compose --env-file "$REVIEW_ENV_FILE" -p "$COMPOSE_PROJECT_NAME" -f deploy/review-apps/review-compose.yml down --remove-orphans --volumes
docker compose --env-file "$REVIEW_ENV_FILE" -p "$COMPOSE_PROJECT_NAME" -f deploy/review-apps/review-compose.yml pull web db clickhouse redis
docker compose --env-file "$REVIEW_ENV_FILE" -p "$COMPOSE_PROJECT_NAME" -f deploy/review-apps/review-compose.yml up -d db clickhouse redis
docker compose --env-file "$REVIEW_ENV_FILE" -p "$COMPOSE_PROJECT_NAME" -f deploy/review-apps/review-compose.yml up -d db

for attempt in $(seq 1 36); do
if docker compose --env-file "$REVIEW_ENV_FILE" -p "$COMPOSE_PROJECT_NAME" -f deploy/review-apps/review-compose.yml exec -T db pg_isready -U health -d health; then
Expand All @@ -374,6 +375,8 @@ jobs:
sleep 5
done

docker compose --env-file "$REVIEW_ENV_FILE" -p "$COMPOSE_PROJECT_NAME" -f deploy/review-apps/review-compose.yml up -d clickhouse redis

for attempt in $(seq 1 36); do
if docker compose --env-file "$REVIEW_ENV_FILE" -p "$COMPOSE_PROJECT_NAME" -f deploy/review-apps/review-compose.yml exec -T clickhouse sh -lc "wget -qO- http://127.0.0.1:8123/ping | grep -q Ok"; then
break
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ jobs:
runs-on: ubuntu-latest
services:
postgres:
image: timescale/timescaledb:2.26.2-pg18
image: timescale/timescaledb-ha:pg18.3-ts2.26.4-all
env:
POSTGRES_DB: test
POSTGRES_USER: test
Expand Down Expand Up @@ -768,7 +768,7 @@ jobs:
timeout-minutes: 75
services:
postgres:
image: timescale/timescaledb:2.26.2-pg18
image: timescale/timescaledb-ha:pg18.3-ts2.26.4-all
env:
POSTGRES_DB: test
POSTGRES_USER: test
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Provider-agnostic fitness/health data pipeline. Syncs data from various provider
- **Mirror agent config files with symlinks**: Every directory that contains an `AGENTS.md` file must also contain `CLAUDE.md` and `GEMINI.md` symlinked to `AGENTS.md` (same directory). Keep these in sync whenever adding or moving agent guidance files.
- **No commented-out dead code/config**: Do not leave commented-out code, workflow jobs, config blocks, or TODO-disabled paths unless the user explicitly asks for that. If something is being removed, delete it fully.
- **"I can't see a provider" means it's broken**: When the user says they can't see a provider in the UI, it means the provider is failing validation and being hidden. The fix is to debug **why** the provider's `validate()` fails (missing env vars, bad config, etc.) — not to show disabled providers. Disabled providers are intentionally hidden from users. Use the `/fix-provider` skill to diagnose and fix.
- **Always use latest versions**: When adding or updating any dependency, Docker image, service, artifact, or tool, always use the latest stable version available. Check for the current latest version rather than copying an older version from elsewhere in the codebase. Pin to specific versions in production (e.g., `timescale/timescaledb:2.26.2-pg18`, not `latest`), but those pinned versions should be the newest stable release at the time of the change.
- **Always use latest versions**: When adding or updating any dependency, Docker image, service, artifact, or tool, always use the latest stable version available. Check for the current latest version rather than copying an older version from elsewhere in the codebase. Pin to specific versions in production (e.g., `timescale/timescaledb-ha:pg18.3-ts2.26.4-all`, not `latest`), but those pinned versions should be the newest stable release at the time of the change.
- **Use TypeScript for repository scripts**: New or updated repository automation scripts must be written in TypeScript (`.ts`) and run with `pnpm tsx`. Do not add new Python scripts for repo tooling unless the work is explicitly inside the Python ML package (`packages/ml`).

## Agent Documentation
Expand Down Expand Up @@ -105,7 +105,7 @@ Provider-agnostic fitness/health data pipeline. Syncs data from various provider
docker network create dofek-test
docker run -d --name dofek-test-db --network dofek-test
-e POSTGRES_DB=health -e POSTGRES_USER=health -e POSTGRES_PASSWORD=test
timescale/timescaledb:2.26.2-pg18
timescale/timescaledb-ha:pg18.3-ts2.26.4-all
sleep 5
docker run -d --name dofek-test-web --network dofek-test -p 3000:3000
-e DATABASE_URL=postgres://health:test@dofek-test-db:5432/health -e PORT=3000
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ For production deploy-time secret injection, the required Infisical `prod` keys,

- **TypeScript** — sync scripts, provider plugins, and web + mobile apps (Node 22 native type stripping at runtime — no tsx in production)
- **Drizzle ORM** — type-safe schema and migrations
- **TimescaleDB** — Postgres with time-series extensions (hypertables, continuous aggregates, compression)
- **TimescaleDB + PostGIS** — Postgres with time-series and geospatial extensions
- **ClickHouse** — stored analytics read models for heavy activity stream and summary reads
- **Vite + React** — web dashboard frontend
- **Expo + React Native** — iOS mobile app with native HealthKit integration
Expand Down
4 changes: 4 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@
"timescale",
"timescaledb",
"peerdb",
"pgcrypto",
"PGDATA",
"ClickHouse",
"CLICKHOUSE",
"clickhouse",
"ewkt",
"SRID",
"refreshable",
"aggs",
"drizzle",
Expand Down
4 changes: 2 additions & 2 deletions deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Dofek is deployed as a **single-node Docker Swarm** stack on **Hetzner Cloud** (

- **Compute**: Hetzner Cloud `cax11` ARM64 servers running Ubuntu 24.04. Production uses `dofek`; staging uses `dofek-staging`. Each server runs `dockerd` initialized as a single-node swarm manager and has no deploy scripts or secrets on disk.
- **Storage**:
- **PostgreSQL**: Managed via TimescaleDB (running in the swarm).
- **PostgreSQL**: Managed via TimescaleDB with PostGIS enabled for geospatial metric data.
- **ClickHouse**: Runs in the swarm as the stored analytics read-model service for heavy activity stream reads. The raw scalar `metric_stream` copy is managed through tracked ClickHouse migrations and chunk-range backfill. See [docs/clickhouse-metric-stream.md](../docs/clickhouse-metric-stream.md).
- **PeerDB**: Runs internally in the swarm as the Postgres-to-ClickHouse CDC service. Its first `metric_stream` mirror writes to `peerdb.metric_stream`; production analytics keep reading the migrated native copy until that initial snapshot is verified.
- **Volume**: Terraform provisions a Hetzner Block Storage volume (`data_volume_size_gb`, default `100GB`) attached with `automount=true`.
Expand Down Expand Up @@ -49,7 +49,7 @@ Dofek is deployed as a **single-node Docker Swarm** stack on **Hetzner Cloud** (
- Zero-downtime updates for `web` and `worker` are configured via `deploy.update_config` (`order: start-first`, `failure_action: rollback`, healthcheck-gated `monitor` window).
- The `default` overlay network is declared `attachable: true` so CI can run one-shot migration containers on it from a remote Docker context.
- The `db` service has a 2 GiB container memory limit to prevent one PostgreSQL workload from exhausting the single-node host. If it hits that limit, treat it as a query/workload incident rather than increasing the cap by default.
- PostgreSQL is configured with `max_connections=40`, `work_mem=4MB`, `maintenance_work_mem=64MB`, and logical replication settings needed by ClickHouse change-data capture.
- PostgreSQL runs `timescale/timescaledb-ha:pg18.3-ts2.26.4-all` so TimescaleDB and PostGIS are both available. It is configured with `max_connections=40`, `work_mem=4MB`, `maintenance_work_mem=64MB`, and logical replication settings needed by ClickHouse change-data capture.
- PeerDB uses an internal catalog Postgres service, Temporal, worker services, and a private MinIO staging bucket. Its persistent catalog and staging data live under `/mnt/dofek-data/peerdb-catalog` and `/mnt/dofek-data/peerdb-minio`. The catalog uses the PostgreSQL 18 image layout: mount the host directory at `/var/lib/postgresql`, not `/var/lib/postgresql/data`, so the image can manage its versioned data directory.
- `metric_stream` storage controls (Timescale hypertable + compression) are managed via `docs/metric-stream-timescaledb-runbook.md` and `drizzle/0006_metric_stream_timescale_policies.sql`.
- Slack is forced to HTTP mode in production via `SLACK_MODE=http` on the `web` service. This avoids Socket Mode multi-consumer overlap during rolling deploys when `web` has multiple replicas.
Expand Down
2 changes: 2 additions & 0 deletions deploy/review-apps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ shared production front door at `pr-<number>.dofek.asherlc.com`.
- applies the PR Terraform workspace
- writes the exact PR host route on the shared front door
- exports review env vars from Infisical
- resets Docker Compose services and volumes so each deploy starts from a
clean seeded database
- runs migrations and the deterministic comprehensive seed script
- starts the review stack
- The destroy workflow tears down the PR workspace, which removes the server and
Expand Down
2 changes: 1 addition & 1 deletion deploy/review-apps/review-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ services:
start_period: 20s

db:
image: timescale/timescaledb:2.26.2-pg18
image: timescale/timescaledb-ha:pg18.3-ts2.26.4-all
command:
- postgres
- -c
Expand Down
2 changes: 1 addition & 1 deletion deploy/stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ services:
- job_files:/app/job-files

db:
image: timescale/timescaledb:2.26.2-pg18
image: timescale/timescaledb-ha:pg18.3-ts2.26.4-all
command:
- postgres
- -c
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.e2e.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
db:
image: timescale/timescaledb:2.26.2-pg18
image: timescale/timescaledb-ha:pg18.3-ts2.26.4-all
command:
- postgres
- -c
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

services:
db:
image: timescale/timescaledb:2.26.2-pg18
image: timescale/timescaledb-ha:pg18.3-ts2.26.4-all
restart: unless-stopped
command:
- postgres
Expand Down
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Human-facing architecture notes, provider research, and operational runbooks for
- [../deploy/README.md](../deploy/README.md): production architecture, deploy flow, secrets, and debugging access.
- [clickhouse-metric-stream.md](clickhouse-metric-stream.md): ClickHouse deduped sensor read model, native backfill, and PeerDB CDC target.
- [schema.md](schema.md): canonical database model and storage philosophy.
- [altitude-provenance.md](altitude-provenance.md): what current providers reveal about altitude source, correction, and confidence.
- [adding-a-provider.md](adding-a-provider.md): how to build or extend a provider.
- [testing.md](testing.md): testing patterns that come up repeatedly in this codebase.

Expand All @@ -18,6 +19,7 @@ Human-facing architecture notes, provider research, and operational runbooks for
| Doc | What it is for |
|-----|----------------|
| [schema.md](schema.md) | Database layout, raw-data-only rules, and view/dedup behavior. |
| [altitude-provenance.md](altitude-provenance.md) | Provider-by-provider altitude source confidence and modeling implications. |
| [schema.dbml](schema.dbml) / [schema.puml](schema.puml) | Generated schema diagrams for quick visual orientation. |
| [adding-a-provider.md](adding-a-provider.md) | Step-by-step provider implementation guide. |
| [nutrition-ai-input.md](nutrition-ai-input.md) | Web + iOS meal logging flow for natural-language AI input. |
Expand Down
Loading
Loading