Loading...
Loading...

A group stock watchlist where friends post picks with up to three support-level entry prices and position sizes. A Supabase Edge Function runs hourly via pg_cron, fetches quotes from Twelve Data, and fires styled HTML email alerts through Resend when a stock drops to a support level. The trigger logic uses an atomic claim pattern in PostgreSQL — one transaction marks the level as triggered and inserts a pending alert log, so duplicate alerts can't happen even if the function runs twice. Historical OHLCV data gets backfilled from Yahoo Finance with a resumable bootstrap job system. The frontend subscribes to three Supabase Realtime channels simultaneously for live price updates, pick changes, and support level triggers.
The alert pipeline runs entirely inside Supabase: pg_cron triggers pg_net which calls the Edge Function, pulling API keys from Vault at runtime. The claim_support_level_trigger RPC atomically marks a level and inserts a pending alert log; if Resend delivery fails, mark_alert_delivery_failed_and_reopen rolls the level back so the next run retries. On the frontend, the picks list merges Realtime events into local state maps keyed by exchange:symbol, with ID-based deduplication for comments. A shared normalization layer handles the Twelve Data / Yahoo Finance symbol format differences and validates OHLCV bar integrity before insert.
A working private watchlist that a group of friends actually use to track stock entries across US, Swedish, and German exchanges. The alert system catches support-level breaches hourly and emails the group with suggested position sizes. Live prices update in the browser without refreshing, and the social features (reactions, comments, interest tracking) let everyone see who's watching what and discuss entries in context.


