# redstellaris/leaderboard architecture

> Architecture diagram of the GitHub repository redstellaris/leaderboard, 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/redstellaris/leaderboard
- Repository: https://github.com/redstellaris/leaderboard

## Overview

This is a GT3 leaderboard web app: visitors pass a quiz and authentication gate, then view session and course rankings sourced from Google Sheets; the app also provides prediction, circuit-rating, and administrative views. A separate serverless check monitors sheet changes and GitHub commits, sends Discord notifications, and persists monitoring state. The frontend and auth flow are supported by sampled source; several listed views and the monitor’s unsampled details are represented only where the tree or excerpts support them.

Main entry points: [`src/App.jsx`](https://github.com/redstellaris/leaderboard/blob/main/src/App.jsx) (App shell), [`api/check.js`](https://github.com/redstellaris/leaderboard/blob/main/api/check.js) (Monitor endpoint), [`src/components/views/SessionView.jsx`](https://github.com/redstellaris/leaderboard/blob/main/src/components/views/SessionView.jsx) (Session view), [`src/utils/sheetsFetch.js`](https://github.com/redstellaris/leaderboard/blob/main/src/utils/sheetsFetch.js) (Sheet loading)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Leaderboard app"]
  node_app["App shell<br/>[App.jsx]"]
  node_quiz["Access quiz<br/>[QuizPage.jsx]"]
  node_sheetdata["Sheet loading<br/>[sheetsFetch.js]"]
  node_session["Session view<br/>[SessionView.jsx]"]
  node_rankings["Ranking logic<br/>[ranking.js]"]
  node_global["Global results<br/>[GlobalView.jsx]"]
  node_course["Course results<br/>[CourseView.jsx]"]
  node_landing["Landing page<br/>[LandingPage.jsx]"]
  node_prediction["Predictions"]
  node_circuit["Circuit rating<br/>[CircuitRating.jsx]"]
  node_admin["Admin dashboard<br/>[AdminDashboard.jsx]"]
end

subgraph group_identity["Identity and access"]
  node_auth["Auth provider<br/>[AuthProvider.jsx]"]
  node_supabase[("Supabase<br/>[supabaseClient.js]")]
end

subgraph group_monitor["Monitoring"]
  node_monitor["Monitor endpoint<br/>[check.js]"]
  node_state[("Monitor state")]
end

node_visitor(("Visitor"))
node_sheets[("Google Sheets")]
node_github["GitHub API"]
node_discord["Discord webhook"]

node_visitor -->|"uses"| node_app
node_app -->|"renders"| node_quiz
node_app -->|"checks session"| node_auth
node_app -->|"loads data"| node_sheetdata
node_sheetdata -->|"fetches rows"| node_sheets
node_app -->|"renders"| node_landing
node_app -->|"renders"| node_session
node_session -->|"calculates rankings"| node_rankings
node_session -->|"renders global"| node_global
node_session -->|"renders course"| node_course
node_app -->|"renders"| node_prediction
node_app -->|"renders"| node_circuit
node_app -->|"renders"| node_admin
node_auth -->|"auth and profiles"| node_supabase
node_admin -->|"manages profiles"| node_supabase
node_monitor -->|"reads and writes"| node_state
node_monitor -->|"checks changes"| node_sheets
node_monitor -->|"checks commits"| node_github
node_monitor -->|"sends alerts"| node_discord

click node_app "https://github.com/redstellaris/leaderboard/blob/main/src/App.jsx"
click node_quiz "https://github.com/redstellaris/leaderboard/blob/main/src/components/views/QuizPage.jsx"
click node_sheetdata "https://github.com/redstellaris/leaderboard/blob/main/src/utils/sheetsFetch.js"
click node_session "https://github.com/redstellaris/leaderboard/blob/main/src/components/views/SessionView.jsx"
click node_rankings "https://github.com/redstellaris/leaderboard/blob/main/src/logic/ranking.js"
click node_global "https://github.com/redstellaris/leaderboard/blob/main/src/components/views/GlobalView.jsx"
click node_course "https://github.com/redstellaris/leaderboard/blob/main/src/components/views/CourseView.jsx"
click node_landing "https://github.com/redstellaris/leaderboard/blob/main/src/components/views/LandingPage.jsx"
click node_prediction "https://github.com/redstellaris/leaderboard/blob/main/src/components/views/PredictionPanel.jsx"
click node_circuit "https://github.com/redstellaris/leaderboard/blob/main/src/components/views/CircuitRating.jsx"
click node_admin "https://github.com/redstellaris/leaderboard/blob/main/src/components/views/AdminDashboard.jsx"
click node_auth "https://github.com/redstellaris/leaderboard/blob/main/src/auth/AuthProvider.jsx"
click node_supabase "https://github.com/redstellaris/leaderboard/blob/main/src/auth/supabaseClient.js"
click node_monitor "https://github.com/redstellaris/leaderboard/blob/main/api/check.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_app,node_quiz,node_sheetdata,node_session,node_rankings,node_global,node_course,node_landing,node_prediction,node_circuit,node_admin toneBlue
class node_auth,node_supabase,node_sheets toneAmber
class node_monitor,node_state,node_github,node_discord toneMint
class node_visitor toneIndigo
```

## Components

### Leaderboard app

- [App shell](https://github.com/redstellaris/leaderboard/blob/main/src/App.jsx): `src/App.jsx`
- [Access quiz](https://github.com/redstellaris/leaderboard/blob/main/src/components/views/QuizPage.jsx): `src/components/views/QuizPage.jsx`
- [Sheet loading](https://github.com/redstellaris/leaderboard/blob/main/src/utils/sheetsFetch.js): `src/utils/sheetsFetch.js`
- [Session view](https://github.com/redstellaris/leaderboard/blob/main/src/components/views/SessionView.jsx): `src/components/views/SessionView.jsx`
- [Ranking logic](https://github.com/redstellaris/leaderboard/blob/main/src/logic/ranking.js): `src/logic/ranking.js`
- [Global results](https://github.com/redstellaris/leaderboard/blob/main/src/components/views/GlobalView.jsx): `src/components/views/GlobalView.jsx`
- [Course results](https://github.com/redstellaris/leaderboard/blob/main/src/components/views/CourseView.jsx): `src/components/views/CourseView.jsx`
- [Landing page](https://github.com/redstellaris/leaderboard/blob/main/src/components/views/LandingPage.jsx): `src/components/views/LandingPage.jsx`
- [Predictions](https://github.com/redstellaris/leaderboard/blob/main/src/components/views/PredictionPanel.jsx): `src/components/views/PredictionPanel.jsx`
- [Circuit rating](https://github.com/redstellaris/leaderboard/blob/main/src/components/views/CircuitRating.jsx): `src/components/views/CircuitRating.jsx`
- [Admin dashboard](https://github.com/redstellaris/leaderboard/blob/main/src/components/views/AdminDashboard.jsx): `src/components/views/AdminDashboard.jsx`

### Identity and access

- [Auth provider](https://github.com/redstellaris/leaderboard/blob/main/src/auth/AuthProvider.jsx): `src/auth/AuthProvider.jsx`
- [Supabase](https://github.com/redstellaris/leaderboard/blob/main/src/auth/supabaseClient.js): `src/auth/supabaseClient.js`

### Monitoring

- [Monitor endpoint](https://github.com/redstellaris/leaderboard/blob/main/api/check.js): `api/check.js`
- **Monitor state**

### Other components

- **Visitor**
- **Google Sheets**
- **GitHub API**
- **Discord webhook**

## Connections

- Visitor → App shell: uses
- App shell → Access quiz: renders
- App shell → Auth provider: checks session
- App shell → Sheet loading: loads data
- Sheet loading → Google Sheets: fetches rows
- App shell → Landing page: renders
- App shell → Session view: renders
- Session view → Ranking logic: calculates rankings
- Session view → Global results: renders global
- Session view → Course results: renders course
- App shell → Predictions: renders
- App shell → Circuit rating: renders
- App shell → Admin dashboard: renders
- Auth provider → Supabase: auth and profiles
- Admin dashboard → Supabase: manages profiles
- Monitor endpoint → Monitor state: reads and writes
- Monitor endpoint → Google Sheets: checks changes
- Monitor endpoint → GitHub API: checks commits
- Monitor endpoint → Discord webhook: sends alerts
