All projects

Petal

AI-powered notes that organize themselves

Role
Founder & Full-Stack Developer
Tags
ML · Web

1536-dim

embeddings, semantic categorization

100%

of the job queue lives in Postgres

Problem

Notes apps make you do the filing. Folders and tags rot because organizing by hand is exactly the chore people skip — notes should land in the right place by meaning, automatically.

Approach

Embed every note (OpenAI text-embedding-3-small, 1536 dimensions) and match it to categories by cosine similarity in pgvector. When similarity alone can't decide, an LLM tie-breaker with confidence thresholds settles it — and when the user corrects a category, a background worker reinforces that category's semantic anchors so the system gets better with use.

What I built

  • Hybrid AI pipeline — vector similarity (pgvector, cosine search) plus an LLM tie-breaker with confidence thresholds; falls back to user prompts or AI-suggested new categories when confidence is low.
  • Self-improving ML loop — user corrections trigger a background worker that extracts and reinforces semantic anchors, continuously refining each category's embedding.
  • All-in-Postgres asynchronous job system — pgmq + pg_cron + pg_net drive Deno Edge Function workers with batch claiming, visibility timeouts, retries, idempotency, and optimistic concurrency. No separate queue service.
  • Next.js 16 + React 19 + TypeScript 5 frontend with a custom contentEditable rich-text editor, voice dictation, and dark mode.
  • Security throughout — Row-Level Security, SECURITY DEFINER functions with locked search_path, Supabase Vault secrets, DOMPurify sanitization.

Result

A production-grade app on Next.js + Supabase: automatic categorization that improves itself, and a fault-tolerant background job system built entirely inside Postgres (pgmq, pg_cron, pg_net) — auth, RLS isolation, onboarding, search, and soft delete included.

Media

Petal — plant your thoughts (petal-notes.com)

Links