# andrewflbarnes/krm-ui architecture

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

- Interactive diagram: https://gitdiagram.com/andrewflbarnes/krm-ui
- Repository: https://github.com/andrewflbarnes/krm-ui
- Video tour (about a minute): https://gitdiagram.com/andrewflbarnes/krm-ui/video

## Overview

Kings Results Manager is a browser-based tool for configuring and running Kings ski races, then recording and viewing their results. The main workflow is to load league/team data, configure teams and rounds, run races through their stages, enter results, and review standings. Round configuration and race progression are distinct domain steps, supported by Kings-specific scheduling and result utilities. The README describes optional Clerk login and Firestore persistence, plus scraping Kingsski.club for configuration data. Some page-to-API wiring is unsampled, so only documented or excerpt-supported links are shown.

Main entry points: [`src/App.tsx`](https://github.com/andrewflbarnes/krm-ui/blob/main/src/App.tsx) (Routes and providers), [`src/api/krm.ts`](https://github.com/andrewflbarnes/krm-ui/blob/main/src/api/krm.ts) (Round lifecycle API), [`src/hooks/auth.tsx`](https://github.com/andrewflbarnes/krm-ui/blob/main/src/hooks/auth.tsx) (Optional sign-in), [`src/pages/RaceNew.tsx`](https://github.com/andrewflbarnes/krm-ui/blob/main/src/pages/RaceNew.tsx) (Round setup flow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_router["Routes and providers<br/>[App.tsx]"]
  node_home["Home and portal<br/>[Home.tsx]"]
end

subgraph group_setup["League setup"]
  node_config["League configuration<br/>[Config.tsx]"]
  node_teamconfig["Team setup<br/>[TeamConfig.tsx]"]
  node_scraper["League config loader<br/>[ksc-results.mts]"]
  node_kings["Kings domain model<br/>[config.ts]"]
  node_roundconfig["Round config editor<br/>[ConfigRound.tsx]"]
end

subgraph group_racing["Race operations"]
  node_roundsetup["Round setup flow<br/>[RaceNew.tsx]"]
  node_roundapi["Round lifecycle API<br/>[krm.ts]"]
  node_racepages["Race stage pages<br/>[RaceInProgress.tsx]"]
  node_minileague["Race result entry<br/>[MiniLeague.tsx]"]
  node_raceutils["Scheduling and scoring<br/>[index.ts]"]
end

subgraph group_results["Results and tracking"]
  node_roundlist["Round listing<br/>[RoundInfoList.tsx]"]
  node_raceview["Race results view<br/>[Race.tsx]"]
  node_tracker["League tracker<br/>[Tracker.tsx]"]
  node_trackerapi["Tracker data API<br/>[tracker.ts]"]
end

subgraph group_identity["Identity and persistence"]
  node_auth["Optional sign-in<br/>[auth.tsx]"]
  node_firebase["Firebase integration<br/>[firebase.ts]"]
end

node_user(("Race organizer"))
node_firestore[("Firestore")]
node_clerk["Clerk identity"]
node_kingsclub["Kingsski.club"]

node_user -->|"uses"| node_router
node_router -->|"routes to"| node_home
node_router -->|"routes to"| node_config
node_router -->|"routes to"| node_teamconfig
node_router -->|"routes to"| node_roundsetup
node_router -->|"routes to"| node_racepages
node_router -->|"routes to"| node_tracker
node_teamconfig -->|"requests config"| node_scraper
node_scraper -->|"scrapes"| node_kingsclub
node_roundsetup -->|"reads config"| node_kings
node_roundsetup -->|"seeds teams"| node_raceutils
node_roundconfig -->|"edits templates"| node_kings
node_roundapi -->|"calculates progression"| node_raceutils
node_roundapi -.->|"syncs rounds"| node_firestore
node_roundapi -.->|"loads rounds"| node_firestore
node_racepages -->|"loads and advances"| node_roundapi
node_minileague -->|"calculates results"| node_raceutils
node_racepages -->|"presents stage"| node_minileague
node_roundlist -->|"displays rounds"| node_roundapi
node_raceview -->|"loads race"| node_roundapi
node_tracker -->|"requests standings"| node_trackerapi
node_trackerapi -.->|"fetches results"| node_kingsclub
node_auth -.->|"authenticates"| node_clerk
node_auth -.->|"signs in"| node_firebase
node_auth -.->|"writes user profile"| node_firestore
node_firebase -.->|"connects"| node_firestore

click node_router "https://github.com/andrewflbarnes/krm-ui/blob/main/src/App.tsx"
click node_home "https://github.com/andrewflbarnes/krm-ui/blob/main/src/pages/Home.tsx"
click node_config "https://github.com/andrewflbarnes/krm-ui/blob/main/src/pages/Config.tsx"
click node_teamconfig "https://github.com/andrewflbarnes/krm-ui/blob/main/src/pages/TeamConfig.tsx"
click node_scraper "https://github.com/andrewflbarnes/krm-ui/blob/main/netlify/functions/ksc-results/ksc-results.mts"
click node_kings "https://github.com/andrewflbarnes/krm-ui/blob/main/src/kings/config.ts"
click node_roundsetup "https://github.com/andrewflbarnes/krm-ui/blob/main/src/pages/RaceNew.tsx"
click node_roundconfig "https://github.com/andrewflbarnes/krm-ui/blob/main/src/pages/ConfigRound.tsx"
click node_roundapi "https://github.com/andrewflbarnes/krm-ui/blob/main/src/api/krm.ts"
click node_racepages "https://github.com/andrewflbarnes/krm-ui/blob/main/src/pages/RaceInProgress.tsx"
click node_minileague "https://github.com/andrewflbarnes/krm-ui/blob/main/src/components/MiniLeague.tsx"
click node_raceutils "https://github.com/andrewflbarnes/krm-ui/blob/main/src/kings/utils/index.ts"
click node_roundlist "https://github.com/andrewflbarnes/krm-ui/blob/main/src/ui/RoundInfoList.tsx"
click node_raceview "https://github.com/andrewflbarnes/krm-ui/blob/main/src/pages/Race.tsx"
click node_tracker "https://github.com/andrewflbarnes/krm-ui/blob/main/src/pages/Tracker.tsx"
click node_trackerapi "https://github.com/andrewflbarnes/krm-ui/blob/main/src/api/tracker.ts"
click node_auth "https://github.com/andrewflbarnes/krm-ui/blob/main/src/hooks/auth.tsx"
click node_firebase "https://github.com/andrewflbarnes/krm-ui/blob/main/src/firebase.ts"

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_router,node_home toneBlue
class node_config,node_teamconfig,node_scraper,node_kings,node_roundconfig,node_firestore toneAmber
class node_roundsetup,node_roundapi,node_racepages,node_minileague,node_raceutils toneMint
class node_roundlist,node_raceview,node_tracker,node_trackerapi toneRose
class node_auth,node_firebase,node_user,node_clerk,node_kingsclub toneIndigo
```

## Components

### Application

- [Routes and providers](https://github.com/andrewflbarnes/krm-ui/blob/main/src/App.tsx): `src/App.tsx`
- [Home and portal](https://github.com/andrewflbarnes/krm-ui/blob/main/src/pages/Home.tsx): `src/pages/Home.tsx`

### League setup

- [League configuration](https://github.com/andrewflbarnes/krm-ui/blob/main/src/pages/Config.tsx): `src/pages/Config.tsx`
- [Team setup](https://github.com/andrewflbarnes/krm-ui/blob/main/src/pages/TeamConfig.tsx): `src/pages/TeamConfig.tsx`
- [League config loader](https://github.com/andrewflbarnes/krm-ui/blob/main/netlify/functions/ksc-results/ksc-results.mts): `netlify/functions/ksc-results/ksc-results.mts`
- [Kings domain model](https://github.com/andrewflbarnes/krm-ui/blob/main/src/kings/config.ts): `src/kings/config.ts`
- [Round config editor](https://github.com/andrewflbarnes/krm-ui/blob/main/src/pages/ConfigRound.tsx): `src/pages/ConfigRound.tsx`

### Race operations

- [Round setup flow](https://github.com/andrewflbarnes/krm-ui/blob/main/src/pages/RaceNew.tsx): `src/pages/RaceNew.tsx`
- [Round lifecycle API](https://github.com/andrewflbarnes/krm-ui/blob/main/src/api/krm.ts): `src/api/krm.ts`
- [Race stage pages](https://github.com/andrewflbarnes/krm-ui/blob/main/src/pages/RaceInProgress.tsx): `src/pages/RaceInProgress.tsx`
- [Race result entry](https://github.com/andrewflbarnes/krm-ui/blob/main/src/components/MiniLeague.tsx): `src/components/MiniLeague.tsx`
- [Scheduling and scoring](https://github.com/andrewflbarnes/krm-ui/blob/main/src/kings/utils/index.ts): `src/kings/utils/index.ts`

### Results and tracking

- [Round listing](https://github.com/andrewflbarnes/krm-ui/blob/main/src/ui/RoundInfoList.tsx): `src/ui/RoundInfoList.tsx`
- [Race results view](https://github.com/andrewflbarnes/krm-ui/blob/main/src/pages/Race.tsx): `src/pages/Race.tsx`
- [League tracker](https://github.com/andrewflbarnes/krm-ui/blob/main/src/pages/Tracker.tsx): `src/pages/Tracker.tsx`
- [Tracker data API](https://github.com/andrewflbarnes/krm-ui/blob/main/src/api/tracker.ts): `src/api/tracker.ts`

### Identity and persistence

- [Optional sign-in](https://github.com/andrewflbarnes/krm-ui/blob/main/src/hooks/auth.tsx): `src/hooks/auth.tsx`
- [Firebase integration](https://github.com/andrewflbarnes/krm-ui/blob/main/src/firebase.ts): `src/firebase.ts`

### Other components

- **Race organizer**
- **Firestore**
- **Clerk identity**
- **Kingsski.club**

## Connections

- Race organizer → Routes and providers: uses
- Routes and providers → Home and portal: routes to
- Routes and providers → League configuration: routes to
- Routes and providers → Team setup: routes to
- Routes and providers → Round setup flow: routes to
- Routes and providers → Race stage pages: routes to
- Routes and providers → League tracker: routes to
- Team setup → League config loader: requests config
- League config loader → Kingsski.club: scrapes
- Round setup flow → Kings domain model: reads config
- Round setup flow → Scheduling and scoring: seeds teams
- Round config editor → Kings domain model: edits templates
- Round lifecycle API → Scheduling and scoring: calculates progression
- Round lifecycle API → Firestore: syncs rounds
- Round lifecycle API → Firestore: loads rounds
- Race stage pages → Round lifecycle API: loads and advances
- Race result entry → Scheduling and scoring: calculates results
- Race stage pages → Race result entry: presents stage
- Round listing → Round lifecycle API: displays rounds
- Race results view → Round lifecycle API: loads race
- League tracker → Tracker data API: requests standings
- Tracker data API → Kingsski.club: fetches results
- Optional sign-in → Clerk identity: authenticates
- Optional sign-in → Firebase integration: signs in
- Optional sign-in → Firestore: writes user profile
- Firebase integration → Firestore: connects
