Skip to content

feat(local-deploy): replace supabase-js with direct postgres + autosync#2

Merged
safixdev merged 1 commit into
safixdev:local-deployfrom
KainanYuval:feat/direct-postgres-autosync
Jun 8, 2026
Merged

feat(local-deploy): replace supabase-js with direct postgres + autosync#2
safixdev merged 1 commit into
safixdev:local-deployfrom
KainanYuval:feat/direct-postgres-autosync

Conversation

@KainanYuval

Copy link
Copy Markdown
Contributor

Summary

  • Drop supabase-js from server/index.ts — replaced with npm:postgres@3 (direct TCP connection to Postgres), the same driver sync.ts already uses. No PostgREST / Supabase REST stack required.
  • Remove cloud env vars (SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, MCP_ACCESS_KEY). Connection is now driven by POSTGRES_URL (or individual POSTGRES_HOST / POSTGRES_PASSWORD / POSTGRES_DB vars), compatible with the ob1-postgres docker container out of the box.
  • Add autosync loop — on startup and every 5 minutes (configurable via AUTOSYNC_INTERVAL_MS), the MCP server calls diffSince(cursor) to fetch only new Artifactory artifacts, upserts them via upsert_thought(), and generates embeddings only for rows where embedding IS NULL. Already-embedded thoughts cost zero Ollama calls.
  • Stage artifactory.ts and sync.ts as tracked files (were previously untracked on this branch).
  • Update deno.json — drop @supabase/supabase-js, add postgres@3.

Test plan

  • POSTGRES_URL=postgres://postgres:ob1local@localhost:5432/ob1 deno task start — server listens on :8000
  • Startup log shows [autosync] started — interval 300s and immediately runs a sync
  • New artifact added to Artifactory appears in Postgres within 5 minutes with embedding
  • Second sync run for the same artifact logs skipped embedding (already present) — no Ollama call
  • All MCP tools (search, fetch, search_thoughts, list_thoughts, thought_stats, capture_thought) return correct results

Made with Cursor

@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

Hey @KainanYuval — welcome to Open Brain Source! 👋

Thanks for submitting your first PR. The automated review will run shortly and check things like metadata, folder structure, and README completeness. If anything needs fixing, the review comment will tell you exactly what.

Once the automated checks pass, a human admin will review for quality and clarity. Expect a response within a few days.

If you have questions, check out CONTRIBUTING.md or open an issue.

…action

Rebased cleanly on top of the db.ts driver refactor (PR #1).

- server/artifactory.ts: restore Artifactory client (diffSince, fetchArtifact,
  pushArtifact) — needed by autosync and capture_thought Artifactory write path
- server/db.ts: add hasEmbedding(id) method to Db interface and both drivers
  (supabase: checks embedding column via select; postgres: checks via IS NOT NULL
  query). Used by autosync to skip Ollama calls for already-embedded thoughts.
- server/index.ts: add autosync loop — fires on startup then every 5 min
  (AUTOSYNC_INTERVAL_MS env var). Uses in-memory cursor advanced after each
  successful run; calls diffSince(cursor) for incremental diff; skips embedding
  generation when hasEmbedding returns true.

Co-authored-by: Cursor <cursoragent@cursor.com>
@KainanYuval KainanYuval force-pushed the feat/direct-postgres-autosync branch from dcbe65e to 3a76c13 Compare June 7, 2026 12:05
@safixdev safixdev merged commit 3a7fb6c into safixdev:local-deploy Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants