3.9 KiB
Moon Base — Project Notes
Property management for the Moon homestead (Eau Claire, WI). Next.js 14 + Prisma +
Postgres. Same conventions as FMB (/Users/bonnamoon/Projects/fullmoonbakehouse).
Repo on Gitea: bonna61/Moonbase. Live at NAS:8053. See README.md for the
user-facing overview.
Modules (all live)
- Garden — Plant registry + care/harvest logs, plant groups, reusable PlantType records, Wikipedia photos. Plants sit on the shared location tree.
- Inventory — durable Items that nest (
parentItemId), with Labels (M:N viaLabelOnItem),ItemAttachment, andItemLog. Shares the Location spine. - Animals —
Animal+AnimalLog(pets/livestock); placed on the Location tree, andTasks can link to an animal (Task.animalId). - Locations —
Locationtree (self-refparentId) shared by plants, items, animals. - Reminders —
Task+TaskCompletion; recurrence insrc/lib/tasks/schedule.ts. - REST API —
/api/v1/*authed byApiToken(per-scope; logic insrc/lib/api/). - Suggestions —
@otm/account-panel(Gitea npm registry) → files issues to the repo. - Backup & Restore —
/api/admin/backup+/api/admin/restore(admin only). - Self-update — admin "Pull & rebuild" (see Deploy).
Local dev
- DB:
postgresql://tonym@localhost:5432/moonbase_dev; copy.env.example→.env. npm install,npm run dev(3000). After schema edits:npx prisma generate.npx prisma migrate deployprovisions Bonna + Tony.npm run db:seedfor demo data (SEED_MODE=minimal= accounts only).- Backfills for the location/plant-type refactors:
npm run db:backfill-locations,npm run db:backfill-plant-types.
Deploy — git checkout on the NAS (NOT rsync)
The NAS appdata (/mnt/user/appdata/moonbase) is a real git checkout tracking
origin/master (remote URL carries the token). Deploy by:
git push origin master
ssh root@192.168.0.5 'cd /mnt/user/appdata/moonbase && git pull && docker compose up -d --build'
Or admins click Settings → Updates → Pull & rebuild, which signals the
privileged updater sidecar (docker socket + adnanh/webhook) to run the same
git pull && compose up -d --build app detached; the UI polls /api/version and
reloads. Never rsync over the appdata dir — it fights the checkout.
- Secrets (
NEXTAUTH_SECRET,GITEA_TOKEN,UPDATER_SECRET) live in a gitignored host.envnext to the compose file, interpolated in — never committed. - Docker runtime mirrors FMB:
node:20-bookworm-slim+ openssl, runs as root, fullnode_modules,next start. Migrations run on container start via the entrypoint (waits for Postgres first). Image gotcha: don't letnpx prismaresolve at runtime — with no local prisma on PATH it pulls Prisma 7, which rejectsurlin the datasource.
Conventions (same as FMB)
- Every commit bumps APP_VERSION in
src/lib/version.ts+ a plain-English entry atopsrc/lib/changelog.ts(the footer shows it + an "update available" badge fromsrc/lib/update-check.ts). Minor for features/migrations, patch for fixes. - AuditEvent on every mutation — append-only.
- Soft-delete via
active=false. - Pure core + colocated test — logic in
src/lib/...with a.test.ts; routes thin.
Auth
- Username OR email login. Accounts
bonna/tony, roleADMIN. getSession()/requireAuth()/isAdmin()insrc/lib/auth.ts.- Forced password change is wired (provisioned accounts ship
moonbase!+mustChangePassword=true): the dashboard layout redirects to/change-password(outside the layout group; backed by/api/account/change-password). Don't remove that redirect. NEXTAUTH_SECRETis asserted at runtime in production (skipped during build).
Color palette
Forest / earth theme: --canopy (sidebar), --leaf (accent), --soil (text),
--dew (bg), --ember (destructive).