Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.
docs: describe the schema tree and migration rules in CLAUDE.md
spacesdrivea4c0ddae79fd
diff --git a/claude.md b/claude.mdindex 6f0c5f5..c8ed6a4 100644--- a/claude.md+++ b/claude.md@@ -49,12 +49,13 @@ scripts/ publish-scheduled.ts, run by GitHub Actions with no dependrun after npm ci in every workflowsupabase/ the database schema: migrations/ (versioned SQL, one table, access, trigger, index or function per file, appliedwith the Supabase CLI), rollbacks/ (the reverse of each migration, same file name),- config.toml (CLI config, Postgres 17)+ schemas/ (generated by npm run db:schema: the schema as it stands, one file per table and+ function under public/), config.toml (CLI config, Postgres 17)```- `npm install` at the root installs every workspace. Never run `npm install` inside `backend/`, `frontend/` or `site/`, and never commit a lockfile there.- `npm run dev` starts the Worker (port 8787) and Vite (port 5173) together; `npm run dev:site` starts the public site on its own. `npm run typecheck`, `npm test`, `npm run lint` and `npm run build` cover the whole repo, the site included (`build` builds the app, then the site).-- `npm run db:new <name>` creates a migration, `npm run db:status` lists which are applied, `npm run db:check` shows what a push would apply and `npm run db:push` applies it (the Supabase CLI is a root dev dependency; link it once with `npx supabase link --project-ref <ref>`). CI never runs migrations.+- `npm run db:new <verb>_<object>` creates a migration named with the current UTC time, `npm run db:status` lists which are applied, `npm run db:check` shows what a push would apply, `npm run db:push` applies it and `npm run db:schema` then rewrites `supabase/schemas/` from the database (the Supabase CLI is a root dev dependency; link it once with `npx supabase link --project-ref <ref>`). CI never runs migrations.- Add a dependency to the workspace that uses it: `npm install <pkg> --workspace backend`, `--workspace frontend` or `--workspace site`. Only shared dev tooling belongs in the root `package.json`.- Tests never live next to source files. A test for `backend/services/accountService.ts` is `backend/tests/services/accountService.test.ts`; a test for `frontend/src/lib/accounts.ts` is `frontend/tests/lib/accounts.test.ts`; site tests live in `site/tests/`.@@ -211,7 +212,7 @@ Read `docs/guidelines/CODE_STYLE.md` before writing code and run its checklist b- Pure logic goes in a plain `.ts` helper (`lib/`) so Node can test it; markup used twice becomes a component; copy that changes by mode lives in a typed table- `scripts/` stays free of npm packages but may import a `backend/lib/` helper that imports nothing at runtime, so both schedulers share one set of rules (`scheduledPublishing.ts`)- The schema changes only through a migration in `supabase/migrations/` plus its rollback in `supabase/rollbacks/`; repositories update `data` through the merge functions, never by reading it and writing it back-- Every migration and its rollback is as small as possible, one database entity per file: a table (with its columns, keys and checks), its browser access, one trigger, one index or one function. A new table is at least four migrations (the table, its access, its `updated_at` trigger, each index). Split any large query into one file per entity before it is applied; never edit a migration production already recorded. `backend/tests/database/migrations.test.ts` enforces it+- Every migration and its rollback is as small as possible, one database entity per file: a table (with its columns, keys and checks), its browser access, one trigger, one index or one function. A new table is at least four migrations (the table, its access, its `updated_at` trigger, each index). Split any large query into one file per entity before it is applied; never rename, renumber or change the SQL of a migration production already recorded. Each file comes from `npm run db:new`, its name starts with the verb (`create`, `alter`, `add`, `index`, `revoke`, `check`, `replace`, `drop`, `rename`), and each migration and rollback opens with one plain sentence that says what it does. After `db:push`, commit the regenerated `supabase/schemas/` with it. `backend/tests/database/migrations.test.ts` enforces it- New row ids come from `newRowId()` in `backend/lib/ids.ts` (`crypto.randomUUID()`)- Tests use `node:test` with sentence names that describe behaviour, live in `tests/` mirroring the source path, and use the smallest typed fake- When the code and `CODE_STYLE.md` disagree, update the guide in the same change