webrune-tim / webrune-tim/The-Autonomy-Protocol
Centralize Database Layer into Monorepo Package (`@autonomy/db`)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
Consolidate schema, migrations, and Drizzle config into @autonomy/db
1. Problem Statement
Currently, sites/student-site/src/lib/server/db/ and sites/teacher-site/src/lib/server/db/ contain duplicate schemas and separate drizzle.config.ts files. Both sites maintain independent drizzle/ migration directories (0001_perfect_charles_xavier.sql exists only on student-site). Running migrations from both repositories against a shared Turso database leads to race conditions, schema drift, and duplicate migrations.
2. Scope of Work
- Create a new monorepo package:
packages/core/db(orpackages/db) named@autonomy/db. - Consolidate all Drizzle schema files (
auth.schema.ts,schema.ts, relations) into the new package. - Relocate migration generation (
drizzle-kit generate), migrations execution (drizzle-kit migrate), and Drizzle Studio into@autonomy/db. - Export a typed client and repository helpers consumable by both
student-siteandteacher-site. - Update
package.jsonworkspaces and Turborepo pipeline tasks (turbo.json) so database build/check tasks run deterministically.
3. Acceptance Criteria
-
sites/student-siteandsites/teacher-siteimport schemas anddbclient from@autonomy/db. - Only one canonical
drizzle/directory exists in the entire monorepo. - Running
pnpm --filter @autonomy/db db:migratesuccessfully applies all migrations cleanly to a blank SQLite/Turso database. - Both applications pass
pnpm checkandpnpm buildusing the shared package.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Compare the duplicate database code under sites/student-site/src/lib/server/db/ and sites/teacher-site/src/lib/server/db/, including their drizzle.config.ts and drizzle/ directories. Then review packages/core/db or packages/db, the workspace package.json files, and turbo.json before choosing the package location. Done means both sites import the shared schema and client, one canonical drizzle/ directory remains, the db:migrate command works on a blank database, and both sites pass pnpm check and pnpm build.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sqlite, typescript
- Domain
- build-system, database
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100