# abimanyu2515/cricscore architecture

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

- Interactive diagram: https://gitdiagram.com/abimanyu2515/cricscore
- Repository: https://github.com/abimanyu2515/cricscore

## Overview

CricScore is a mobile-first team cricket tracker. Users browse and filter players, open profiles, record or edit per-player innings, and view rankings; a separate match-history area records team match results. Admins manage player records, while LYST answers natural-language performance questions through Gemini tools. The graph emphasizes documented page/API and assistant flows; many UI details and unsampled implementations are represented at their exact enclosing paths, with uncertain links omitted.

Main entry points: [`lib/supabase.ts`](https://github.com/abimanyu2515/cricscore/blob/main/lib/supabase.ts) (Supabase clients), [`lib/assistant/assistantOrchestrator.ts`](https://github.com/abimanyu2515/cricscore/blob/main/lib/assistant/assistantOrchestrator.ts) (Turn orchestrator), [`app/api/players/route.ts`](https://github.com/abimanyu2515/cricscore/blob/main/app/api/players/route.ts) (Player API), [`app/admin/page.tsx`](https://github.com/abimanyu2515/cricscore/blob/main/app/admin/page.tsx) (Player administration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_player["Player tracking"]
  node_home["Player directory<br/>[page.tsx]"]
  node_playerapi["Player API<br/>[route.ts]"]
  node_playerdetail["Player API detail<br/>[route.ts]"]
  node_scorecreate["Record score<br/>[page.tsx]"]
  node_scoreedit["Edit score<br/>[page.tsx]"]
  node_scoreapi["Score entry API<br/>[route.ts]"]
  node_scoreentryapi["Score edit API<br/>[route.ts]"]
  node_profile["Player profile<br/>[page.tsx]"]
  node_leaderboard["Leaderboard<br/>[page.tsx]"]
  node_admin["Player administration<br/>[page.tsx]"]
end

subgraph group_match["Match records"]
  node_matchespage["Match history<br/>[page.tsx]"]
  node_matchapi["Match API<br/>[route.ts]"]
end

subgraph group_assistant["LYST assistant"]
  node_assistantui["Assistant chat<br/>[AssistantChat.tsx]"]
  node_assistantroute["Assistant endpoint<br/>[route.ts]"]
  node_orchestrator["Turn orchestrator"]
  node_toolrouter["Tool dispatcher<br/>[assistantTools.ts]"]
  node_domaintools["Stats and query tools<br/>[tools.ts]"]
  node_matchesquery["Match query tools"]
  node_gemini["Gemini service<br/>[gemini.ts]"]
  node_modelqueue["Model queue<br/>[modelQueue.ts]"]
  node_duplicate["Duplicate-call guard"]
end

subgraph group_platform["Access and data"]
  node_roster["Cached player roster<br/>[playerRoster.ts]"]
  node_supabaseclient["Supabase clients<br/>[supabase.ts]"]
  node_database[("Supabase database")]
  node_access["Access gates<br/>[proxy.ts]"]
end

node_visitor(("Team user"))
node_geminiservice["Google Gemini"]

node_visitor -->|"browses"| node_home
node_home -->|"fetches players"| node_playerapi
node_playerapi -->|"queries players"| node_supabaseclient
node_supabaseclient -.->|"reads and writes"| node_database
node_visitor -->|"records innings"| node_scorecreate
node_visitor -->|"edits innings"| node_scoreedit
node_scorecreate -->|"submits score"| node_scoreapi
node_scoreedit -->|"updates score"| node_scoreentryapi
node_scoreapi -.->|"persists entries"| node_supabaseclient
node_scoreentryapi -.->|"updates entries"| node_supabaseclient
node_visitor -->|"views profile"| node_profile
node_profile -.->|"loads player"| node_playerdetail
node_visitor -->|"views rankings"| node_leaderboard
node_leaderboard -->|"fetches rankings"| node_playerapi
node_visitor -->|"manages players"| node_admin
node_admin -->|"loads roster"| node_playerapi
node_admin -->|"updates players"| node_playerdetail
node_playerdetail -->|"mutates records"| node_supabaseclient
node_visitor -->|"views match log"| node_matchespage
node_matchespage -.->|"loads and creates"| node_matchapi
node_matchapi -->|"queries matches"| node_supabaseclient
node_visitor -->|"asks questions"| node_assistantui
node_assistantui -->|"posts prompt"| node_assistantroute
node_assistantroute -->|"runs turn"| node_orchestrator
node_orchestrator -->|"loads roster"| node_roster
node_roster -->|"reads players"| node_supabaseclient
node_orchestrator -->|"queues generation"| node_modelqueue
node_modelqueue -->|"schedules calls"| node_gemini
node_orchestrator -->|"deduplicates calls"| node_duplicate
node_orchestrator -->|"dispatches tools"| node_toolrouter
node_toolrouter -.->|"delegates tools"| node_domaintools
node_domaintools -.->|"queries team data"| node_supabaseclient
node_toolrouter -.->|"dispatches match queries"| node_matchesquery
node_matchesquery -->|"queries match data"| node_supabaseclient
node_gemini -.->|"calls model"| node_geminiservice
node_access -.->|"gates routes"| node_visitor

click node_home "https://github.com/abimanyu2515/cricscore/blob/main/app/page.tsx"
click node_playerapi "https://github.com/abimanyu2515/cricscore/blob/main/app/api/players/route.ts"
click node_playerdetail "https://github.com/abimanyu2515/cricscore/blob/main/app/api/players/%5Bid%5D/route.ts"
click node_scorecreate "https://github.com/abimanyu2515/cricscore/blob/main/app/player/%5Bid%5D/add-score/page.tsx"
click node_scoreedit "https://github.com/abimanyu2515/cricscore/blob/main/app/player/%5Bid%5D/add-score/%5BentryId%5D/edit/page.tsx"
click node_scoreapi "https://github.com/abimanyu2515/cricscore/blob/main/app/api/players/%5Bid%5D/scores/route.ts"
click node_scoreentryapi "https://github.com/abimanyu2515/cricscore/blob/main/app/api/players/%5Bid%5D/scores/%5BentryId%5D/route.ts"
click node_profile "https://github.com/abimanyu2515/cricscore/blob/main/app/player/%5Bid%5D/profile/page.tsx"
click node_leaderboard "https://github.com/abimanyu2515/cricscore/blob/main/app/leaderboard/page.tsx"
click node_admin "https://github.com/abimanyu2515/cricscore/blob/main/app/admin/page.tsx"
click node_matchespage "https://github.com/abimanyu2515/cricscore/blob/main/app/matches/page.tsx"
click node_matchapi "https://github.com/abimanyu2515/cricscore/blob/main/app/api/matches/route.ts"
click node_assistantui "https://github.com/abimanyu2515/cricscore/blob/main/components/assistant/AssistantChat.tsx"
click node_assistantroute "https://github.com/abimanyu2515/cricscore/blob/main/app/api/assistant/route.ts"
click node_orchestrator "https://github.com/abimanyu2515/cricscore/blob/main/lib/assistant/assistantOrchestrator.ts"
click node_toolrouter "https://github.com/abimanyu2515/cricscore/blob/main/lib/assistant/assistantTools.ts"
click node_domaintools "https://github.com/abimanyu2515/cricscore/blob/main/lib/assistant/tools.ts"
click node_matchesquery "https://github.com/abimanyu2515/cricscore/blob/main/lib/matchesQueryTool.ts"
click node_gemini "https://github.com/abimanyu2515/cricscore/blob/main/lib/assistant/gemini.ts"
click node_modelqueue "https://github.com/abimanyu2515/cricscore/blob/main/lib/assistant/modelQueue.ts"
click node_duplicate "https://github.com/abimanyu2515/cricscore/blob/main/lib/duplicateCallDetect.ts"
click node_roster "https://github.com/abimanyu2515/cricscore/blob/main/lib/playerRoster.ts"
click node_supabaseclient "https://github.com/abimanyu2515/cricscore/blob/main/lib/supabase.ts"
click node_access "https://github.com/abimanyu2515/cricscore/blob/main/proxy.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_home,node_playerapi,node_playerdetail,node_scorecreate,node_scoreedit,node_scoreapi,node_scoreentryapi,node_profile,node_leaderboard,node_admin,node_visitor toneBlue
class node_matchespage,node_matchapi toneAmber
class node_assistantui,node_assistantroute,node_orchestrator,node_toolrouter,node_domaintools,node_matchesquery,node_gemini,node_modelqueue,node_duplicate toneMint
class node_roster,node_supabaseclient,node_database,node_access toneRose
class node_geminiservice toneIndigo
```

## Components

### Player tracking

- [Player directory](https://github.com/abimanyu2515/cricscore/blob/main/app/page.tsx): `app/page.tsx`
- [Player API](https://github.com/abimanyu2515/cricscore/blob/main/app/api/players/route.ts): `app/api/players/route.ts`
- [Player API detail](https://github.com/abimanyu2515/cricscore/blob/main/app/api/players/%5Bid%5D/route.ts): `app/api/players/[id]/route.ts`
- [Record score](https://github.com/abimanyu2515/cricscore/blob/main/app/player/%5Bid%5D/add-score/page.tsx): `app/player/[id]/add-score/page.tsx`
- [Edit score](https://github.com/abimanyu2515/cricscore/blob/main/app/player/%5Bid%5D/add-score/%5BentryId%5D/edit/page.tsx): `app/player/[id]/add-score/[entryId]/edit/page.tsx`
- [Score entry API](https://github.com/abimanyu2515/cricscore/blob/main/app/api/players/%5Bid%5D/scores/route.ts): `app/api/players/[id]/scores/route.ts`
- [Score edit API](https://github.com/abimanyu2515/cricscore/blob/main/app/api/players/%5Bid%5D/scores/%5BentryId%5D/route.ts): `app/api/players/[id]/scores/[entryId]/route.ts`
- [Player profile](https://github.com/abimanyu2515/cricscore/blob/main/app/player/%5Bid%5D/profile/page.tsx): `app/player/[id]/profile/page.tsx`
- [Leaderboard](https://github.com/abimanyu2515/cricscore/blob/main/app/leaderboard/page.tsx): `app/leaderboard/page.tsx`
- [Player administration](https://github.com/abimanyu2515/cricscore/blob/main/app/admin/page.tsx): `app/admin/page.tsx`

### Match records

- [Match history](https://github.com/abimanyu2515/cricscore/blob/main/app/matches/page.tsx): `app/matches/page.tsx`
- [Match API](https://github.com/abimanyu2515/cricscore/blob/main/app/api/matches/route.ts): `app/api/matches/route.ts`

### LYST assistant

- [Assistant chat](https://github.com/abimanyu2515/cricscore/blob/main/components/assistant/AssistantChat.tsx): `components/assistant/AssistantChat.tsx`
- [Assistant endpoint](https://github.com/abimanyu2515/cricscore/blob/main/app/api/assistant/route.ts): `app/api/assistant/route.ts`
- [Turn orchestrator](https://github.com/abimanyu2515/cricscore/blob/main/lib/assistant/assistantOrchestrator.ts): `lib/assistant/assistantOrchestrator.ts`
- [Tool dispatcher](https://github.com/abimanyu2515/cricscore/blob/main/lib/assistant/assistantTools.ts): `lib/assistant/assistantTools.ts`
- [Stats and query tools](https://github.com/abimanyu2515/cricscore/blob/main/lib/assistant/tools.ts): `lib/assistant/tools.ts`
- [Match query tools](https://github.com/abimanyu2515/cricscore/blob/main/lib/matchesQueryTool.ts): `lib/matchesQueryTool.ts`
- [Gemini service](https://github.com/abimanyu2515/cricscore/blob/main/lib/assistant/gemini.ts): `lib/assistant/gemini.ts`
- [Model queue](https://github.com/abimanyu2515/cricscore/blob/main/lib/assistant/modelQueue.ts): `lib/assistant/modelQueue.ts`
- [Duplicate-call guard](https://github.com/abimanyu2515/cricscore/blob/main/lib/duplicateCallDetect.ts): `lib/duplicateCallDetect.ts`

### Access and data

- [Cached player roster](https://github.com/abimanyu2515/cricscore/blob/main/lib/playerRoster.ts): `lib/playerRoster.ts`
- [Supabase clients](https://github.com/abimanyu2515/cricscore/blob/main/lib/supabase.ts): `lib/supabase.ts`
- **Supabase database**
- [Access gates](https://github.com/abimanyu2515/cricscore/blob/main/proxy.ts): `proxy.ts`

### Other components

- **Team user**
- **Google Gemini**

## Connections

- Team user → Player directory: browses (evidence: `app/page.tsx`)
- Player directory → Player API: fetches players (evidence: `app/page.tsx`)
- Player API → Supabase clients: queries players (evidence: `app/api/players/route.ts`)
- Supabase clients → Supabase database: reads and writes
- Team user → Record score: records innings (evidence: `app/player/[id]/add-score/page.tsx`)
- Team user → Edit score: edits innings (evidence: `app/player/[id]/add-score/[entryId]/edit/page.tsx`)
- Record score → Score entry API: submits score (evidence: `app/player/[id]/add-score/page.tsx`)
- Edit score → Score edit API: updates score (evidence: `app/player/[id]/add-score/[entryId]/edit/page.tsx`)
- Score entry API → Supabase clients: persists entries (evidence: `app/api/players/[id]/scores/route.ts`)
- Score edit API → Supabase clients: updates entries (evidence: `app/api/players/[id]/scores/[entryId]/route.ts`)
- Team user → Player profile: views profile (evidence: `app/player/[id]/profile/page.tsx`)
- Player profile → Player API detail: loads player
- Team user → Leaderboard: views rankings (evidence: `app/leaderboard/page.tsx`)
- Leaderboard → Player API: fetches rankings (evidence: `app/leaderboard/page.tsx`)
- Team user → Player administration: manages players (evidence: `app/admin/page.tsx`)
- Player administration → Player API: loads roster (evidence: `app/admin/page.tsx`)
- Player administration → Player API detail: updates players (evidence: `app/admin/page.tsx`)
- Player API detail → Supabase clients: mutates records (evidence: `app/api/players/[id]/route.ts`)
- Team user → Match history: views match log (evidence: `app/matches/page.tsx`)
- Match history → Match API: loads and creates
- Match API → Supabase clients: queries matches (evidence: `app/api/matches/route.ts`)
- Team user → Assistant chat: asks questions (evidence: `README.md`)
- Assistant chat → Assistant endpoint: posts prompt (evidence: `README.md`)
- Assistant endpoint → Turn orchestrator: runs turn (evidence: `app/api/assistant/route.ts`)
- Turn orchestrator → Cached player roster: loads roster (evidence: `lib/assistant/assistantOrchestrator.ts`)
- Cached player roster → Supabase clients: reads players (evidence: `lib/playerRoster.ts`)
- Turn orchestrator → Model queue: queues generation (evidence: `lib/assistant/assistantOrchestrator.ts`)
- Model queue → Gemini service: schedules calls (evidence: `lib/assistant/assistantOrchestrator.ts`)
- Turn orchestrator → Duplicate-call guard: deduplicates calls (evidence: `lib/assistant/assistantOrchestrator.ts`)
- Turn orchestrator → Tool dispatcher: dispatches tools (evidence: `lib/assistant/assistantOrchestrator.ts`)
- Tool dispatcher → Stats and query tools: delegates tools
- Stats and query tools → Supabase clients: queries team data
- Tool dispatcher → Match query tools: dispatches match queries
- Match query tools → Supabase clients: queries match data (evidence: `lib/matchesQueryTool.ts`)
- Gemini service → Google Gemini: calls model
- Access gates → Team user: gates routes (evidence: `README.md`)
