Port to Neon + Better Auth, with SQL-aggregated hot paths#6
Merged
Conversation
…, add indexes Hot read paths were doing O(N) work in JS and running queries sequentially. All four changes are driven by Vitest integration tests against a Neon branch that assert both correctness and the performance invariant (query count, SQL shape, parallel dispatch). - balance: single SELECT SUM(delta) instead of fetching every ledger row - market detail: 7 sequential queries -> gated reads + Promise.all + aggregate counts; balance via SUM - leaderboard: windowed GROUP BY (SUM OVER + ROW_NUMBER) instead of pulling all ledger rows and summing in JS - migration 009: indexes on ledger_entries(user_id) and markets(group_id) API handlers now delegate to tested server/queries/* modules (-153 lines). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This branch is what's currently deployed to production (
betchaon Vercel, commit48c22fb). It contains two pieces of work:1. Port from Supabase → Neon + Better Auth (commit
3fa0130)Migrates identity/auth off Supabase onto Neon Postgres + Better Auth; removes the Supabase client/admin/RLS layer and
supabase/migrations.2. Performance: SQL-aggregated hot read paths (commit
48c22fb, this session)The hot read paths were doing O(N) work in JS and running queries sequentially. All four changes are test-first, with Vitest integration tests against an ephemeral Neon branch asserting both correctness and the performance invariant (query count, SQL shape, parallel dispatch).
SELECT SUM(delta)Promise.all+ aggregate countsGROUP BY(SUM OVER+ROW_NUMBER)ix_ledger_entries_user_id,ix_markets_group_id(migration009)API route handlers now delegate to tested
server/queries/*modules (-153 lines in the handlers).Test harness
New Vitest suite (
npm run test:perf) runstest/**/*.vitest.jsagainst a Neon branch (.env.test.local, gitignored). Data-access functions take an injectablequeryso tests can spy on call counts / concurrency.Verification
npm run test:perf→ 13 passednpm test(resolve integration) → 12 passed, no regressionsnpm run build→ clean009already applied to production Neon (ix_ledger_entries_user_id,ix_markets_group_idverified present)/api/health200, homepage 200, unauthenticated market detail 401, no runtime errors🤖 Generated with Claude Code