# starlightent/sflgbtbowl architecture

> Architecture diagram of the GitHub repository starlightent/sflgbtbowl, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/starlightent/sflgbtbowl
- Repository: https://github.com/starlightent/sflgbtbowl

## Overview

This is a Next.js league-management site for bowlers, officers, and administrators. The principal workflow is league members viewing team, roster, schedule, and finance information, then submitting prebowl/scheduling requests; officers administer league data and publish weekly updates. Four supporting domains cover authentication, finance reconciliation, league setup, and public tournaments/venues/announcements. Edges are limited to relationships visible in excerpts or the source index; unsampled routes and features are represented without asserting internal calls.

Main entry points: [`lib/db.js`](https://github.com/starlightent/sflgbtbowl/blob/main/lib/db.js) (League database), [`app/leagues/[slug]/page.js`](https://github.com/starlightent/sflgbtbowl/blob/main/app/leagues/%5Bslug%5D/page.js) (League dashboard), [`app/api/admin/weekly/parse/route.js`](https://github.com/starlightent/sflgbtbowl/blob/main/app/api/admin/weekly/parse/route.js) (Weekly results admin), [`app/api/finance/sync/route.js`](https://github.com/starlightent/sflgbtbowl/blob/main/app/api/finance/sync/route.js) (Finance sync API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_member["Member experience"]
  node_league_views["League dashboard<br/>[page.js]"]
  node_roster_ui["Member roster<br/>[MemberRoster.js]"]
  node_member_api["Bowler profile API<br/>[route.js]"]
  node_prebowl["Prebowl form<br/>[PrebowlForm.js]"]
  node_schedule_request_api["Scheduling request API<br/>[route.js]"]
  node_public_content["Public league content"]
  node_tournaments["Tournaments"]
  node_venues["Venues"]
end

subgraph group_admin["League administration"]
  node_weekly_admin["Weekly results admin<br/>[route.js]"]
  node_admin_routes["Admin API"]
  node_admin_ui["Admin forms"]
  node_finance_ui["Finance manager<br/>[FinanceManager.js]"]
  node_announcements["Announcements"]
end

subgraph group_domain["League operations"]
  node_request_service["Request validation"]
  node_schedule_context["Schedule context<br/>[context.js]"]
  node_schedule_rules["Scheduling rules<br/>[rules.js]"]
  node_standings_parser["Standings PDF parser"]
  node_weekly_matcher["Bowler matching"]
  node_finance_sync["Finance sync API<br/>[route.js]"]
  node_finance_ingest["Finance reconciliation<br/>[ingest.js]"]
  node_team_flags["Team flags<br/>[teamFlags.js]"]
end

subgraph group_platform["Shared platform"]
  node_auth["Authentication<br/>[auth.js]"]
  node_admin_guard["Admin authorization<br/>[requireAdminApi.js]"]
  node_database[("League database<br/>[db.js]")]
end

node_bowler(("Bowler"))
node_admin_actor(("League admin"))

node_bowler -->|"views leagues"| node_league_views
node_league_views -->|"renders"| node_prebowl
node_bowler -.->|"views roster"| node_roster_ui
node_roster_ui -.->|"loads profile"| node_member_api
node_bowler -->|"submits request"| node_schedule_request_api
node_prebowl -->|"uses rules"| node_schedule_rules
node_league_views -->|"uses rules"| node_schedule_rules
node_schedule_request_api -->|"validates request"| node_request_service
node_league_views -->|"loads context"| node_schedule_context
node_admin_actor -.->|"manages league"| node_admin_ui
node_admin_ui -.->|"updates data"| node_admin_routes
node_admin_actor -.->|"uploads results"| node_weekly_admin
node_weekly_admin -->|"parses PDF"| node_standings_parser
node_weekly_admin -->|"matches bowlers"| node_weekly_matcher
node_admin_actor -.->|"reviews finance"| node_finance_ui
node_finance_ui -->|"updates flags"| node_team_flags
node_admin_actor -.->|"starts sync"| node_finance_sync
node_finance_sync -->|"ingests snapshot"| node_finance_ingest
node_finance_ingest -->|"sets flags"| node_team_flags
node_admin_actor -.->|"publishes news"| node_announcements
node_announcements -.->|"publishes updates"| node_public_content
node_bowler -.->|"browses events"| node_tournaments
node_bowler -.->|"finds venues"| node_venues
node_schedule_context -->|"reads schedule"| node_database
node_request_service -.->|"checks eligibility"| node_database
node_member_api -->|"reads profile"| node_database
node_finance_ingest -->|"writes finance"| node_database
node_admin_routes -.->|"checks access"| node_admin_guard
node_admin_guard -->|"checks session"| node_auth
node_admin_guard -.->|"checks roles"| node_database
node_league_views -->|"loads league data"| node_database
node_finance_sync -->|"uses season context"| node_auth

click node_league_views "https://github.com/starlightent/sflgbtbowl/blob/main/app/leagues/%5Bslug%5D/page.js"
click node_roster_ui "https://github.com/starlightent/sflgbtbowl/blob/main/components/Member/MemberRoster.js"
click node_member_api "https://github.com/starlightent/sflgbtbowl/blob/main/app/api/member/bowler/%5Bid%5D/route.js"
click node_prebowl "https://github.com/starlightent/sflgbtbowl/blob/main/components/Dashboard/PrebowlForm.js"
click node_schedule_request_api "https://github.com/starlightent/sflgbtbowl/blob/main/app/api/scheduling-requests/route.js"
click node_request_service "https://github.com/starlightent/sflgbtbowl/blob/main/lib/schedulingRequests.js"
click node_schedule_context "https://github.com/starlightent/sflgbtbowl/blob/main/lib/scheduling/context.js"
click node_schedule_rules "https://github.com/starlightent/sflgbtbowl/blob/main/lib/scheduling/rules.js"
click node_weekly_admin "https://github.com/starlightent/sflgbtbowl/blob/main/app/api/admin/weekly/parse/route.js"
click node_standings_parser "https://github.com/starlightent/sflgbtbowl/blob/main/lib/pdf/parseLeagueStandings.js"
click node_weekly_matcher "https://github.com/starlightent/sflgbtbowl/blob/main/lib/pdf/matchWeeklyBowlers.js"
click node_admin_routes "https://github.com/starlightent/sflgbtbowl/tree/main/app/api/admin"
click node_admin_ui "https://github.com/starlightent/sflgbtbowl/tree/main/components/Admin"
click node_finance_ui "https://github.com/starlightent/sflgbtbowl/blob/main/components/Admin/FinanceManager.js"
click node_finance_sync "https://github.com/starlightent/sflgbtbowl/blob/main/app/api/finance/sync/route.js"
click node_finance_ingest "https://github.com/starlightent/sflgbtbowl/blob/main/lib/finance/ingest.js"
click node_team_flags "https://github.com/starlightent/sflgbtbowl/blob/main/lib/teamFlags.js"
click node_announcements "https://github.com/starlightent/sflgbtbowl/blob/main/components/Admin/AnnouncementsManager.js"
click node_tournaments "https://github.com/starlightent/sflgbtbowl/tree/main/app/tournaments"
click node_venues "https://github.com/starlightent/sflgbtbowl/tree/main/app/venues"
click node_auth "https://github.com/starlightent/sflgbtbowl/blob/main/lib/auth.js"
click node_admin_guard "https://github.com/starlightent/sflgbtbowl/blob/main/lib/requireAdminApi.js"
click node_database "https://github.com/starlightent/sflgbtbowl/blob/main/lib/db.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_league_views,node_roster_ui,node_member_api,node_prebowl,node_schedule_request_api,node_public_content,node_tournaments,node_venues toneBlue
class node_weekly_admin,node_admin_routes,node_admin_ui,node_finance_ui,node_announcements toneAmber
class node_request_service,node_schedule_context,node_schedule_rules,node_standings_parser,node_weekly_matcher,node_finance_sync,node_finance_ingest,node_team_flags toneMint
class node_auth,node_admin_guard,node_database toneRose
class node_bowler,node_admin_actor toneIndigo
```

## Components

### Member experience

- [League dashboard](https://github.com/starlightent/sflgbtbowl/blob/main/app/leagues/%5Bslug%5D/page.js): `app/leagues/[slug]/page.js`
- [Member roster](https://github.com/starlightent/sflgbtbowl/blob/main/components/Member/MemberRoster.js): `components/Member/MemberRoster.js`
- [Bowler profile API](https://github.com/starlightent/sflgbtbowl/blob/main/app/api/member/bowler/%5Bid%5D/route.js): `app/api/member/bowler/[id]/route.js`
- [Prebowl form](https://github.com/starlightent/sflgbtbowl/blob/main/components/Dashboard/PrebowlForm.js): `components/Dashboard/PrebowlForm.js`
- [Scheduling request API](https://github.com/starlightent/sflgbtbowl/blob/main/app/api/scheduling-requests/route.js): `app/api/scheduling-requests/route.js`
- **Public league content**
- [Tournaments](https://github.com/starlightent/sflgbtbowl/tree/main/app/tournaments): `app/tournaments`
- [Venues](https://github.com/starlightent/sflgbtbowl/tree/main/app/venues): `app/venues`

### League administration

- [Weekly results admin](https://github.com/starlightent/sflgbtbowl/blob/main/app/api/admin/weekly/parse/route.js): `app/api/admin/weekly/parse/route.js`
- [Admin API](https://github.com/starlightent/sflgbtbowl/tree/main/app/api/admin): `app/api/admin`
- [Admin forms](https://github.com/starlightent/sflgbtbowl/tree/main/components/Admin): `components/Admin`
- [Finance manager](https://github.com/starlightent/sflgbtbowl/blob/main/components/Admin/FinanceManager.js): `components/Admin/FinanceManager.js`
- [Announcements](https://github.com/starlightent/sflgbtbowl/blob/main/components/Admin/AnnouncementsManager.js): `components/Admin/AnnouncementsManager.js`

### League operations

- [Request validation](https://github.com/starlightent/sflgbtbowl/blob/main/lib/schedulingRequests.js): `lib/schedulingRequests.js`
- [Schedule context](https://github.com/starlightent/sflgbtbowl/blob/main/lib/scheduling/context.js): `lib/scheduling/context.js`
- [Scheduling rules](https://github.com/starlightent/sflgbtbowl/blob/main/lib/scheduling/rules.js): `lib/scheduling/rules.js`
- [Standings PDF parser](https://github.com/starlightent/sflgbtbowl/blob/main/lib/pdf/parseLeagueStandings.js): `lib/pdf/parseLeagueStandings.js`
- [Bowler matching](https://github.com/starlightent/sflgbtbowl/blob/main/lib/pdf/matchWeeklyBowlers.js): `lib/pdf/matchWeeklyBowlers.js`
- [Finance sync API](https://github.com/starlightent/sflgbtbowl/blob/main/app/api/finance/sync/route.js): `app/api/finance/sync/route.js`
- [Finance reconciliation](https://github.com/starlightent/sflgbtbowl/blob/main/lib/finance/ingest.js): `lib/finance/ingest.js`
- [Team flags](https://github.com/starlightent/sflgbtbowl/blob/main/lib/teamFlags.js): `lib/teamFlags.js`

### Shared platform

- [Authentication](https://github.com/starlightent/sflgbtbowl/blob/main/lib/auth.js): `lib/auth.js`
- [Admin authorization](https://github.com/starlightent/sflgbtbowl/blob/main/lib/requireAdminApi.js): `lib/requireAdminApi.js`
- [League database](https://github.com/starlightent/sflgbtbowl/blob/main/lib/db.js): `lib/db.js`

### Other components

- **Bowler**
- **League admin**

## Connections

- Bowler → League dashboard: views leagues (evidence: `app/leagues/[slug]/page.js`)
- League dashboard → Prebowl form: renders (evidence: `app/leagues/[slug]/page.js`)
- Bowler → Member roster: views roster
- Member roster → Bowler profile API: loads profile
- Bowler → Scheduling request API: submits request (evidence: `app/api/scheduling-requests/route.js`)
- Prebowl form → Scheduling rules: uses rules (evidence: `components/Dashboard/PrebowlForm.js`)
- League dashboard → Scheduling rules: uses rules (evidence: `app/leagues/[slug]/page.js`)
- Scheduling request API → Request validation: validates request (evidence: `app/api/scheduling-requests/route.js`)
- League dashboard → Schedule context: loads context (evidence: `app/leagues/[slug]/page.js`)
- League admin → Admin forms: manages league
- Admin forms → Admin API: updates data
- League admin → Weekly results admin: uploads results
- Weekly results admin → Standings PDF parser: parses PDF (evidence: `app/api/admin/weekly/parse/route.js`)
- Weekly results admin → Bowler matching: matches bowlers (evidence: `app/api/admin/weekly/parse/route.js`)
- League admin → Finance manager: reviews finance
- Finance manager → Team flags: updates flags (evidence: `components/Admin/FinanceManager.js`)
- League admin → Finance sync API: starts sync
- Finance sync API → Finance reconciliation: ingests snapshot (evidence: `app/api/finance/sync/route.js`)
- Finance reconciliation → Team flags: sets flags (evidence: `lib/finance/ingest.js`)
- League admin → Announcements: publishes news
- Announcements → Public league content: publishes updates
- Bowler → Tournaments: browses events
- Bowler → Venues: finds venues
- Schedule context → League database: reads schedule (evidence: `lib/scheduling/context.js`)
- Request validation → League database: checks eligibility
- Bowler profile API → League database: reads profile (evidence: `app/api/member/bowler/[id]/route.js`)
- Finance reconciliation → League database: writes finance (evidence: `lib/finance/ingest.js`)
- Admin API → Admin authorization: checks access (evidence: `app/api/admin/weekly/parse/route.js`)
- Admin authorization → Authentication: checks session (evidence: `lib/requireAdminApi.js`)
- Admin authorization → League database: checks roles
- League dashboard → League database: loads league data (evidence: `app/leagues/[slug]/page.js`)
- Finance sync API → Authentication: uses season context (evidence: `app/api/finance/sync/route.js`)
