# assassinash/scorecard architecture

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

- Interactive diagram: https://gitdiagram.com/assassinash/scorecard
- Repository: https://github.com/assassinash/scorecard

## Overview

CrickSnap is a role-based cricket tournament and live-scoring application. Users sign in, manage profiles and credits, browse tournaments, and—when authorized—create matches and score ball by ball; public viewers follow scoreboards and scorecards. The main route pages coordinate server actions, while Supabase-backed actions enforce access and persist tournament, match, and scoring data. Scoring calculations and statistics form an internal domain layer. Tournament access, credit administration, and fullscreen viewing are important supporting capabilities. Some subsystem links are documented in the README rather than verified in unsampled source.

Main entry points: [`src/app/actions/matches.ts`](https://github.com/assassinash/scorecard/blob/main/src/app/actions/matches.ts) (Match Setup), [`src/app/match/[id]/display/page.tsx`](https://github.com/assassinash/scorecard/blob/main/src/app/match/%5Bid%5D/display/page.tsx) (Public Display Route), [`src/app/actions/scoring.ts`](https://github.com/assassinash/scorecard/blob/main/src/app/actions/scoring.ts) (Scoring Actions), [`src/app/actions/tournaments.ts`](https://github.com/assassinash/scorecard/blob/main/src/app/actions/tournaments.ts) (Tournament Actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and Roles"]
  node_login["Sign In<br/>[page.tsx]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_profile["Profile and Credits<br/>[profile.ts]"]
  node_access["Tournament Access<br/>[access.ts]"]
end

subgraph group_tournaments["Tournament Operations"]
  node_home["Tournament Browse<br/>[page.tsx]"]
  node_tournament["Tournament View<br/>[page.tsx]"]
  node_tournament_actions["Tournament Actions<br/>[tournaments.ts]"]
  node_access_page["Access Management<br/>[page.tsx]"]
end

subgraph group_matches["Match Operations"]
  node_match_setup["Match Setup<br/>[matches.ts]"]
  node_team_actions["Team Management<br/>[teams.ts]"]
  node_match_page["Match Page<br/>[page.tsx]"]
end

subgraph group_scoring["Live Scoring"]
  node_score_page["Scoring Page<br/>[page.tsx]"]
  node_scoring_ui["Scoring Interface"]
  node_scoring_actions["Scoring Actions<br/>[scoring.ts]"]
  node_score_display["Live Score Display"]
  node_display_page["Public Display Route<br/>[page.tsx]"]
  node_refresh["Live Refresh"]
end

subgraph group_domain["Scoring Domain"]
  node_score_rules["Scoring Rules<br/>[scoring.ts]"]
  node_stats["Match Statistics<br/>[stats.ts]"]
end

node_user(("User"))
node_supabase[("Supabase")]
node_google["Google Sign-In"]

node_user -->|"signs in"| node_login
node_login -->|"authenticates"| node_auth
node_auth -->|"uses auth"| node_supabase
node_login -->|"uses sign-in"| node_google
node_user -->|"browses"| node_home
node_home -->|"loads tournaments"| node_tournament_actions
node_home -->|"loads profile"| node_profile
node_tournament -->|"loads tournament"| node_tournament_actions
node_tournament -->|"checks access"| node_access
node_tournament -->|"loads matches"| node_match_setup
node_user -->|"manages access"| node_access_page
node_access_page -.->|"manages requests"| node_access
node_tournament_actions -->|"reads and writes"| node_supabase
node_match_setup -->|"checks access"| node_tournament_actions
node_match_setup -->|"reads and writes"| node_supabase
node_user -.->|"manages teams"| node_team_actions
node_user -->|"opens match"| node_match_page
node_match_page -->|"loads match"| node_match_setup
node_match_page -->|"loads innings"| node_scoring_actions
node_user -->|"scores match"| node_score_page
node_score_page -->|"renders controls"| node_scoring_ui
node_scoring_ui -->|"records balls"| node_scoring_actions
node_scoring_ui -->|"adds players"| node_match_setup
node_scoring_actions -->|"reads and writes"| node_supabase
node_scoring_actions -->|"uses rules"| node_score_rules
node_score_rules -->|"calculates statistics"| node_stats
node_user -->|"views scoreboard"| node_display_page
node_display_page -->|"loads match"| node_match_setup
node_display_page -->|"loads score data"| node_scoring_actions
node_display_page -->|"renders display"| node_score_display
node_display_page -->|"enables refresh"| node_refresh
node_refresh -->|"uses client"| node_supabase
node_score_display -->|"formats scores"| node_score_rules
node_user -->|"manages account"| node_profile
node_profile -->|"reads and writes"| node_supabase
node_access -->|"reads and writes"| node_supabase

click node_login "https://github.com/assassinash/scorecard/blob/main/src/app/login/page.tsx"
click node_auth "https://github.com/assassinash/scorecard/blob/main/src/app/actions/auth.ts"
click node_profile "https://github.com/assassinash/scorecard/blob/main/src/app/actions/profile.ts"
click node_access "https://github.com/assassinash/scorecard/blob/main/src/app/actions/access.ts"
click node_home "https://github.com/assassinash/scorecard/blob/main/src/app/page.tsx"
click node_tournament "https://github.com/assassinash/scorecard/blob/main/src/app/tournament/%5Bid%5D/page.tsx"
click node_tournament_actions "https://github.com/assassinash/scorecard/blob/main/src/app/actions/tournaments.ts"
click node_access_page "https://github.com/assassinash/scorecard/blob/main/src/app/tournament/%5Bid%5D/access/page.tsx"
click node_match_setup "https://github.com/assassinash/scorecard/blob/main/src/app/actions/matches.ts"
click node_team_actions "https://github.com/assassinash/scorecard/blob/main/src/app/actions/teams.ts"
click node_match_page "https://github.com/assassinash/scorecard/blob/main/src/app/match/%5Bid%5D/page.tsx"
click node_score_page "https://github.com/assassinash/scorecard/blob/main/src/app/match/%5Bid%5D/score/page.tsx"
click node_scoring_ui "https://github.com/assassinash/scorecard/blob/main/src/components/ScoringInterface.tsx"
click node_scoring_actions "https://github.com/assassinash/scorecard/blob/main/src/app/actions/scoring.ts"
click node_score_display "https://github.com/assassinash/scorecard/blob/main/src/components/FullscreenDisplay.tsx"
click node_display_page "https://github.com/assassinash/scorecard/blob/main/src/app/match/%5Bid%5D/display/page.tsx"
click node_refresh "https://github.com/assassinash/scorecard/blob/main/src/components/RealtimeRefresh.tsx"
click node_score_rules "https://github.com/assassinash/scorecard/blob/main/src/lib/cricket/scoring.ts"
click node_stats "https://github.com/assassinash/scorecard/blob/main/src/lib/cricket/stats.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_login,node_auth,node_profile,node_access,node_user toneBlue
class node_home,node_tournament,node_tournament_actions,node_access_page,node_supabase toneAmber
class node_match_setup,node_team_actions,node_match_page toneMint
class node_score_page,node_scoring_ui,node_scoring_actions,node_score_display,node_display_page,node_refresh toneRose
class node_score_rules,node_stats,node_google toneIndigo
```

## Components

### Identity and Roles

- [Sign In](https://github.com/assassinash/scorecard/blob/main/src/app/login/page.tsx): `src/app/login/page.tsx`
- [Authentication](https://github.com/assassinash/scorecard/blob/main/src/app/actions/auth.ts): `src/app/actions/auth.ts`
- [Profile and Credits](https://github.com/assassinash/scorecard/blob/main/src/app/actions/profile.ts): `src/app/actions/profile.ts`
- [Tournament Access](https://github.com/assassinash/scorecard/blob/main/src/app/actions/access.ts): `src/app/actions/access.ts`

### Tournament Operations

- [Tournament Browse](https://github.com/assassinash/scorecard/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Tournament View](https://github.com/assassinash/scorecard/blob/main/src/app/tournament/%5Bid%5D/page.tsx): `src/app/tournament/[id]/page.tsx`
- [Tournament Actions](https://github.com/assassinash/scorecard/blob/main/src/app/actions/tournaments.ts): `src/app/actions/tournaments.ts`
- [Access Management](https://github.com/assassinash/scorecard/blob/main/src/app/tournament/%5Bid%5D/access/page.tsx): `src/app/tournament/[id]/access/page.tsx`

### Match Operations

- [Match Setup](https://github.com/assassinash/scorecard/blob/main/src/app/actions/matches.ts): `src/app/actions/matches.ts`
- [Team Management](https://github.com/assassinash/scorecard/blob/main/src/app/actions/teams.ts): `src/app/actions/teams.ts`
- [Match Page](https://github.com/assassinash/scorecard/blob/main/src/app/match/%5Bid%5D/page.tsx): `src/app/match/[id]/page.tsx`

### Live Scoring

- [Scoring Page](https://github.com/assassinash/scorecard/blob/main/src/app/match/%5Bid%5D/score/page.tsx): `src/app/match/[id]/score/page.tsx`
- [Scoring Interface](https://github.com/assassinash/scorecard/blob/main/src/components/ScoringInterface.tsx): `src/components/ScoringInterface.tsx`
- [Scoring Actions](https://github.com/assassinash/scorecard/blob/main/src/app/actions/scoring.ts): `src/app/actions/scoring.ts`
- [Live Score Display](https://github.com/assassinash/scorecard/blob/main/src/components/FullscreenDisplay.tsx): `src/components/FullscreenDisplay.tsx`
- [Public Display Route](https://github.com/assassinash/scorecard/blob/main/src/app/match/%5Bid%5D/display/page.tsx): `src/app/match/[id]/display/page.tsx`
- [Live Refresh](https://github.com/assassinash/scorecard/blob/main/src/components/RealtimeRefresh.tsx): `src/components/RealtimeRefresh.tsx`

### Scoring Domain

- [Scoring Rules](https://github.com/assassinash/scorecard/blob/main/src/lib/cricket/scoring.ts): `src/lib/cricket/scoring.ts`
- [Match Statistics](https://github.com/assassinash/scorecard/blob/main/src/lib/cricket/stats.ts): `src/lib/cricket/stats.ts`

### Other components

- **User**
- **Supabase**
- **Google Sign-In**

## Connections

- User → Sign In: signs in
- Sign In → Authentication: authenticates (evidence: `src/app/login/page.tsx`)
- Authentication → Supabase: uses auth (evidence: `src/app/actions/auth.ts`)
- Sign In → Google Sign-In: uses sign-in
- User → Tournament Browse: browses
- Tournament Browse → Tournament Actions: loads tournaments (evidence: `src/app/page.tsx`)
- Tournament Browse → Profile and Credits: loads profile (evidence: `src/app/page.tsx`)
- Tournament View → Tournament Actions: loads tournament (evidence: `src/app/tournament/[id]/page.tsx`)
- Tournament View → Tournament Access: checks access (evidence: `src/app/tournament/[id]/page.tsx`)
- Tournament View → Match Setup: loads matches (evidence: `src/app/tournament/[id]/page.tsx`)
- User → Access Management: manages access
- Access Management → Tournament Access: manages requests
- Tournament Actions → Supabase: reads and writes (evidence: `src/app/actions/tournaments.ts`)
- Match Setup → Tournament Actions: checks access (evidence: `src/app/actions/matches.ts`)
- Match Setup → Supabase: reads and writes (evidence: `src/app/actions/matches.ts`)
- User → Team Management: manages teams
- User → Match Page: opens match
- Match Page → Match Setup: loads match (evidence: `src/app/match/[id]/page.tsx`)
- Match Page → Scoring Actions: loads innings (evidence: `src/app/match/[id]/page.tsx`)
- User → Scoring Page: scores match
- Scoring Page → Scoring Interface: renders controls (evidence: `src/app/match/[id]/score/page.tsx`)
- Scoring Interface → Scoring Actions: records balls (evidence: `src/components/ScoringInterface.tsx`)
- Scoring Interface → Match Setup: adds players (evidence: `src/components/ScoringInterface.tsx`)
- Scoring Actions → Supabase: reads and writes (evidence: `src/app/actions/scoring.ts`)
- Scoring Actions → Scoring Rules: uses rules (evidence: `src/app/actions/scoring.ts`)
- Scoring Rules → Match Statistics: calculates statistics (evidence: `src/lib/cricket/stats.ts`)
- User → Public Display Route: views scoreboard
- Public Display Route → Match Setup: loads match (evidence: `src/app/match/[id]/display/page.tsx`)
- Public Display Route → Scoring Actions: loads score data (evidence: `src/app/match/[id]/display/page.tsx`)
- Public Display Route → Live Score Display: renders display (evidence: `src/app/match/[id]/display/page.tsx`)
- Public Display Route → Live Refresh: enables refresh (evidence: `src/app/match/[id]/display/page.tsx`)
- Live Refresh → Supabase: uses client (evidence: `src/components/RealtimeRefresh.tsx`)
- Live Score Display → Scoring Rules: formats scores (evidence: `src/components/FullscreenDisplay.tsx`)
- User → Profile and Credits: manages account
- Profile and Credits → Supabase: reads and writes (evidence: `src/app/actions/profile.ts`)
- Tournament Access → Supabase: reads and writes (evidence: `src/app/actions/access.ts`)
