Domain Model: westside-admin

arch-domain-westside-admin Architecture

architecture active

Domain Model: westside-admin

Diagram

Components

Component Purpose Notes
tenants Multi-tenant root 6 cols. v1 hardcoded to id=1 (Westside).
parents Parent/guardian contact 11 cols, ~99 rows. Holds waiver fields + magic-link registration_token (sensitive).
coaches Coaching staff 16 cols. Stripe Connect onboarding state.
players Player profile (widest table) 37 cols, ~58 rows. 6 enum fields, jsonb contract_overrides.
teams Team roster + config 10 cols, 7 rows. contract_config jsonb + GroupMe links.
player_teams Junction table 2 cols. Many-to-many player↔team.
events Calendar entries 13 cols. Self-ref via parent_event_id for recurring events.
tournaments Tournament definitions 6 cols.
tournament_products Tournament↔product↔team junction 5 cols.
practice_schedules Recurring practice slots 12 cols.
products Stripe products catalog 10 cols. custom_fields jsonb.
orders Stripe checkout records 12 cols, 85 rows.
registrations Tryout/signup payments 12 cols, 50 rows.
email_log Outbound email audit 8 cols, 609 rows (largest table).
interest_leads Marketing capture 8 cols.
sponsors Sponsor CRM 13 cols, 44 rows.
oauth_tokens Third-party API tokens 7 cols. token_data jsonb is SENSITIVE — hide from UI.
password_reset_tokens Reset flow tokens 6 cols. token field SENSITIVE.
contract_audit_log Contract state diffs 8 cols. old_state/new_state jsonb.
jersey_public_orders Public jersey intake 19 cols. UUID PK (only one).
outbox Outbox event pattern 7 cols.
alembic_version Migration tracking 1 col. EXCLUDE from admin UI.

Key Decisions

  • Live-Postgres-as-source-of-truth. Domain comes from drizzle-kit pull, not a hand-maintained TS file. Ensures admin tool never lies about reality.
  • tenant_id is universal but not enforced at DB level. Most tables have it; the application layer enforces scoping via the query helper. This is a known limitation worth a future RLS upgrade.
  • jersey_public_orders uses UUID PK while all others use serial integer. Inherited from public-submission flow needing unguessable IDs. Admin UI must handle both PK shapes.
  • Sensitive columns identified upfront for visible-columns-config. Tokens (oauth_tokens.token_data, password_reset_tokens.token, parents.registration_token, players.contract_token) hidden by default.
  • alembic_version excluded from admin UI. Migration tracking is not user data; editing it manually breaks alembic.
  • arch-dataflow-westside-admin — sibling: how data moves
  • arch-deployment-westside-admin — sibling: where it runs
  • project-westside-admin — parent project page
  • arch-domain-westside-basketball — same DB, modeled from basketball-api side