# martin-olh/trugen-scorer architecture

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

- Interactive diagram: https://gitdiagram.com/martin-olh/trugen-scorer
- Repository: https://github.com/martin-olh/trugen-scorer

## Overview

TRUGEN Scorer is a local scorekeeping app for Truco and Generala, with player rosters, match history, and player statistics. The evident workflow is to choose a game, set up and record a match, persist its scores, and review completed matches or player records. The graph connects routing and sampled data/service calls; page-to-hook wiring outside the sampled source is not asserted.

Main entry points: [`src/App.tsx`](https://github.com/martin-olh/trugen-scorer/blob/master/src/App.tsx) (App router), [`src/hooks/usePlayerStats.ts`](https://github.com/martin-olh/trugen-scorer/blob/master/src/hooks/usePlayerStats.ts) (Player stats hooks), [`src/data/repositories/trucoMatchRepository.ts`](https://github.com/martin-olh/trugen-scorer/blob/master/src/data/repositories/trucoMatchRepository.ts) (Truco match repository), [`src/data/repositories/generalaMatchRepository.ts`](https://github.com/martin-olh/trugen-scorer/blob/master/src/data/repositories/generalaMatchRepository.ts) (Generala match repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and pages"]
  node_app["App router<br/>[App.tsx]"]
  node_home["Home and roster<br/>[HomePage.tsx]"]
  node_history["Match history<br/>[HistoryPage.tsx]"]
  node_profile["Player profile"]
end

subgraph group_match["Match scoring"]
  node_truco_setup["Truco setup<br/>[TrucoSetupPage.tsx]"]
  node_truco_match["Truco match<br/>[TrucoMatchPage.tsx]"]
  node_generala_setup["Generala setup"]
  node_generala_match["Generala match"]
  node_truco_hook["Truco match hooks<br/>[useTrucoMatch.ts]"]
  node_generala_hook["Generala match hooks"]
  node_truco_tally["Truco tally rules<br/>[trucoTally.ts]"]
  node_generala_scoring["Generala scoring<br/>[generalaScoring.ts]"]
end

subgraph group_players["Players and stats"]
  node_player_hooks["Player hooks<br/>[usePlayers.ts]"]
  node_stats_hook["Player stats hooks<br/>[usePlayerStats.ts]"]
  node_stats["Stats calculations<br/>[statsService.ts]"]
end

subgraph group_storage["Local persistence"]
  node_truco_repo["Truco match repository"]
  node_generala_repo["Generala match repository"]
  node_player_repo["Player repository"]
  node_db[("IndexedDB store<br/>[db.ts]")]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"routes"| node_home
node_app -->|"routes"| node_history
node_app -->|"routes"| node_profile
node_app -->|"routes"| node_truco_setup
node_app -->|"routes"| node_truco_match
node_app -->|"routes"| node_generala_setup
node_app -->|"routes"| node_generala_match
node_home -->|"loads roster"| node_player_hooks
node_player_hooks -->|"calls"| node_player_repo
node_player_repo -->|"reads/writes"| node_db
node_truco_hook -->|"calls"| node_truco_repo
node_truco_repo -->|"reads/writes"| node_db
node_truco_repo -->|"applies scores"| node_truco_tally
node_truco_hook -->|"optimistic scoring"| node_truco_tally
node_generala_hook -->|"calls"| node_generala_repo
node_generala_repo -->|"reads/writes"| node_db
node_generala_repo -->|"resolves winner"| node_generala_scoring
node_stats_hook -->|"calculates"| node_stats
node_stats_hook -->|"loads matches"| node_truco_hook
node_stats_hook -->|"loads matches"| node_generala_hook

click node_app "https://github.com/martin-olh/trugen-scorer/blob/master/src/App.tsx"
click node_home "https://github.com/martin-olh/trugen-scorer/blob/master/src/pages/HomePage.tsx"
click node_history "https://github.com/martin-olh/trugen-scorer/blob/master/src/pages/HistoryPage.tsx"
click node_profile "https://github.com/martin-olh/trugen-scorer/blob/master/src/pages/PlayerProfilePage.tsx"
click node_truco_setup "https://github.com/martin-olh/trugen-scorer/blob/master/src/pages/truco/TrucoSetupPage.tsx"
click node_truco_match "https://github.com/martin-olh/trugen-scorer/blob/master/src/pages/truco/TrucoMatchPage.tsx"
click node_generala_setup "https://github.com/martin-olh/trugen-scorer/blob/master/src/pages/generala/GeneralaSetupPage.tsx"
click node_generala_match "https://github.com/martin-olh/trugen-scorer/blob/master/src/pages/generala/GeneralaMatchPage.tsx"
click node_truco_hook "https://github.com/martin-olh/trugen-scorer/blob/master/src/hooks/useTrucoMatch.ts"
click node_generala_hook "https://github.com/martin-olh/trugen-scorer/blob/master/src/hooks/useGeneralaMatch.ts"
click node_truco_repo "https://github.com/martin-olh/trugen-scorer/blob/master/src/data/repositories/trucoMatchRepository.ts"
click node_generala_repo "https://github.com/martin-olh/trugen-scorer/blob/master/src/data/repositories/generalaMatchRepository.ts"
click node_truco_tally "https://github.com/martin-olh/trugen-scorer/blob/master/src/services/trucoTally.ts"
click node_generala_scoring "https://github.com/martin-olh/trugen-scorer/blob/master/src/services/generalaScoring.ts"
click node_player_hooks "https://github.com/martin-olh/trugen-scorer/blob/master/src/hooks/usePlayers.ts"
click node_player_repo "https://github.com/martin-olh/trugen-scorer/blob/master/src/data/repositories/playerRepository.ts"
click node_stats_hook "https://github.com/martin-olh/trugen-scorer/blob/master/src/hooks/usePlayerStats.ts"
click node_stats "https://github.com/martin-olh/trugen-scorer/blob/master/src/services/statsService.ts"
click node_db "https://github.com/martin-olh/trugen-scorer/blob/master/src/data/db.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_app,node_home,node_history,node_profile,node_user toneBlue
class node_truco_setup,node_truco_match,node_generala_setup,node_generala_match,node_truco_hook,node_generala_hook,node_truco_tally,node_generala_scoring toneAmber
class node_player_hooks,node_stats_hook,node_stats toneMint
class node_truco_repo,node_generala_repo,node_player_repo,node_db toneRose
```

## Components

### App and pages

- [App router](https://github.com/martin-olh/trugen-scorer/blob/master/src/App.tsx): `src/App.tsx`
- [Home and roster](https://github.com/martin-olh/trugen-scorer/blob/master/src/pages/HomePage.tsx): `src/pages/HomePage.tsx`
- [Match history](https://github.com/martin-olh/trugen-scorer/blob/master/src/pages/HistoryPage.tsx): `src/pages/HistoryPage.tsx`
- [Player profile](https://github.com/martin-olh/trugen-scorer/blob/master/src/pages/PlayerProfilePage.tsx): `src/pages/PlayerProfilePage.tsx`

### Match scoring

- [Truco setup](https://github.com/martin-olh/trugen-scorer/blob/master/src/pages/truco/TrucoSetupPage.tsx): `src/pages/truco/TrucoSetupPage.tsx`
- [Truco match](https://github.com/martin-olh/trugen-scorer/blob/master/src/pages/truco/TrucoMatchPage.tsx): `src/pages/truco/TrucoMatchPage.tsx`
- [Generala setup](https://github.com/martin-olh/trugen-scorer/blob/master/src/pages/generala/GeneralaSetupPage.tsx): `src/pages/generala/GeneralaSetupPage.tsx`
- [Generala match](https://github.com/martin-olh/trugen-scorer/blob/master/src/pages/generala/GeneralaMatchPage.tsx): `src/pages/generala/GeneralaMatchPage.tsx`
- [Truco match hooks](https://github.com/martin-olh/trugen-scorer/blob/master/src/hooks/useTrucoMatch.ts): `src/hooks/useTrucoMatch.ts`
- [Generala match hooks](https://github.com/martin-olh/trugen-scorer/blob/master/src/hooks/useGeneralaMatch.ts): `src/hooks/useGeneralaMatch.ts`
- [Truco tally rules](https://github.com/martin-olh/trugen-scorer/blob/master/src/services/trucoTally.ts): `src/services/trucoTally.ts`
- [Generala scoring](https://github.com/martin-olh/trugen-scorer/blob/master/src/services/generalaScoring.ts): `src/services/generalaScoring.ts`

### Players and stats

- [Player hooks](https://github.com/martin-olh/trugen-scorer/blob/master/src/hooks/usePlayers.ts): `src/hooks/usePlayers.ts`
- [Player stats hooks](https://github.com/martin-olh/trugen-scorer/blob/master/src/hooks/usePlayerStats.ts): `src/hooks/usePlayerStats.ts`
- [Stats calculations](https://github.com/martin-olh/trugen-scorer/blob/master/src/services/statsService.ts): `src/services/statsService.ts`

### Local persistence

- [Truco match repository](https://github.com/martin-olh/trugen-scorer/blob/master/src/data/repositories/trucoMatchRepository.ts): `src/data/repositories/trucoMatchRepository.ts`
- [Generala match repository](https://github.com/martin-olh/trugen-scorer/blob/master/src/data/repositories/generalaMatchRepository.ts): `src/data/repositories/generalaMatchRepository.ts`
- [Player repository](https://github.com/martin-olh/trugen-scorer/blob/master/src/data/repositories/playerRepository.ts): `src/data/repositories/playerRepository.ts`
- [IndexedDB store](https://github.com/martin-olh/trugen-scorer/blob/master/src/data/db.ts): `src/data/db.ts`

### Other components

- **User**

## Connections

- User → App router: uses
- App router → Home and roster: routes
- App router → Match history: routes
- App router → Player profile: routes
- App router → Truco setup: routes
- App router → Truco match: routes
- App router → Generala setup: routes
- App router → Generala match: routes
- Home and roster → Player hooks: loads roster
- Player hooks → Player repository: calls
- Player repository → IndexedDB store: reads/writes
- Truco match hooks → Truco match repository: calls
- Truco match repository → IndexedDB store: reads/writes
- Truco match repository → Truco tally rules: applies scores
- Truco match hooks → Truco tally rules: optimistic scoring
- Generala match hooks → Generala match repository: calls
- Generala match repository → IndexedDB store: reads/writes
- Generala match repository → Generala scoring: resolves winner
- Player stats hooks → Stats calculations: calculates
- Player stats hooks → Truco match hooks: loads matches
- Player stats hooks → Generala match hooks: loads matches
