brackt/docs/agents/domain-models.md
Chris Parsons 5268e07365
Migrate auth from Clerk to BetterAuth (#354)
* Fix BetterAuth field mapping and add owner-prefixed team names

- Fix auth.server.ts: use camelCase Drizzle field names for BetterAuth
  adapter (was snake_case, causing user inserts to fail); add
  generateId: "uuid" so PostgreSQL UUID columns accept generated IDs
- Add prependOwnerToTeamName / stripOwnerFromTeamName utilities
- Invite join, league creation, and settings assign/remove all now
  manage the owner-prefix on team names atomically

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Complete BetterAuth migration: auth flows, rename, and cleanup

- Add /forgot-password and /reset-password pages (full password reset flow)
- Add 'Forgot password?' link on login page
- Fix register.tsx: add explicit window.location fallback after signUp
- Rename commissionerAuditLog.actorClerkId → actorUserId (migration 0084)
  and update all references in model, routes, components, and tests
- Rewrite docs/agents/auth.md to document BetterAuth (removes all Clerk refs)
- Update test fixtures and schema comments to remove Clerk ID references;
  use UUID-format IDs throughout test data
- Update docs/agents/domain-models.md ownerId description

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Fix BetterAuth ID generation, clean up review issues

- Set generateId: false so BetterAuth omits id from inserts; add
  $defaultFn(crypto.randomUUID) to accounts/sessions/verifications
  so Drizzle fills it in (fixes null id constraint violation on signup)
- Move renameTeam to static import; rename before removeTeamOwner so
  a failed rename leaves owner intact rather than leaving a stale prefix
- Clarify stripOwnerFromTeamName toTitleCase assumption in comment
- Annotate reset-password token fallback to explain loader guarantee

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-29 10:03:50 -07:00

34 lines
1.5 KiB
Markdown

# Domain Models
## Fantasy Draft System
| Model | Description |
|---|---|
| **League** | Top-level container; has one or more commissioners |
| **Season** | One iteration of a league. Status: `pre_draft``draft``active``completed` |
| **Team** | Belongs to a season; owned by a user (`ownerId` = UUID → `users.id`) |
| **Draft Slot** | Defines draft order for teams in a season |
| **Draft Pick** | Record of each pick made |
| **Draft Queue** | A team's pre-ordered wish list of participants |
| **Draft Timer** | Active countdown for the team currently on the clock |
| **Autodraft Settings** | Per-team config for automatic picking |
Season status drives UI visibility: draft order shown in `pre_draft`, draft controls active in `draft`, etc.
### Snake Draft Logic
- Draft slots define base order (1, 2, 3…)
- Odd rounds go 1→N; even rounds go N→1
- `currentPickNumber` on the season tracks position
- `server/timer.ts` handles autopicks when timer expires
## Sports Data System
| Model | Description |
|---|---|
| **Sport** | Base sport definition (e.g. NFL, NBA); type is `team` or `individual` |
| **Sports Season** | A specific season of a sport (e.g. "2024 NFL Season") |
| **Participant** | An athlete or team that can be drafted |
| **Season Template** | Reusable configuration for creating league seasons |
| **Season Sport** | Junction: links a fantasy season to the sports it covers |
| **Participant Result** | Final standings/scores for participants at season end |