# goncaloazev14/loko_fees architecture

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

- Interactive diagram: https://gitdiagram.com/goncaloazev14/loko_fees
- Repository: https://github.com/goncaloazev14/loko_fees

## Overview

FC Lokomotiv is a responsive fines-and-club-cash tracker: visitors look up players, balances, fines and payments, while administrators sign in to record and manage club finances. The app routes these screens through a shared API to Supabase; queued changes can be stored locally and synchronized later. The README also documents season archiving, change history, admin invitations and regulation controls. Some page and backend implementations were not sampled, so those capabilities are shown without guessed internal call chains.

Main entry points: [`src/App.tsx`](https://github.com/goncaloazev14/loko_fees/blob/main/src/App.tsx) (Route and layout), [`src/lib/api.ts`](https://github.com/goncaloazev14/loko_fees/blob/main/src/lib/api.ts) (Data API), [`src/lib/sync.ts`](https://github.com/goncaloazev14/loko_fees/blob/main/src/lib/sync.ts) (Offline sync), [`src/lib/hooks.ts`](https://github.com/goncaloazev14/loko_fees/blob/main/src/lib/hooks.ts) (Query hooks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public club records"]
  node_dashboard["Club dashboard<br/>[Dashboard.tsx]"]
  node_players["Player roster<br/>[Players.tsx]"]
  node_player_detail["Player account<br/>[PlayerDetail.tsx]"]
  node_fines["Fines browser<br/>[Fines.tsx]"]
end

subgraph group_admin["Administration"]
  node_regulations["Rules and fine types<br/>[Regulamento.tsx]"]
  node_add_fine["Record fines<br/>[AddFine.tsx]"]
  node_payments["Record payments<br/>[Payments.tsx]"]
  node_money["Income and expenses<br/>[Money.tsx]"]
  node_settings["Season settings<br/>[Settings.tsx]"]
  node_history["Change history<br/>[History.tsx]"]
  node_archive["Season archive<br/>[Archive.tsx]"]
  node_admins["Admin management<br/>[Admins.tsx]"]
  node_invite_fn["Admin invitations<br/>[index.ts]"]
end

subgraph group_runtime["App runtime"]
  node_app["Route and layout<br/>[App.tsx]"]
  node_login["Sign-in and access<br/>[Login.tsx]"]
  node_auth["Session and admin checks<br/>[auth.tsx]"]
end

subgraph group_data["Data and sync"]
  node_api["Data API<br/>[api.ts]"]
  node_hooks["Query hooks<br/>[hooks.ts]"]
  node_sync_manager["Sync coordinator<br/>[SyncManager.tsx]"]
  node_sync["Offline sync<br/>[sync.ts]"]
  node_outbox["Local change queue<br/>[outbox.ts]"]
  node_supabase["Supabase client<br/>[supabase.ts]"]
end

node_visitor(("Visitor or admin"))
node_database[("Supabase database and auth")]

node_visitor -->|"opens"| node_app
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_players
node_app -->|"routes to"| node_player_detail
node_app -->|"routes to"| node_fines
node_app -->|"routes to"| node_regulations
node_app -->|"routes to"| node_login
node_app -->|"uses"| node_auth
node_app -->|"mounts"| node_sync_manager
node_app -->|"routes to"| node_add_fine
node_app -->|"routes to"| node_payments
node_app -->|"routes to"| node_money
node_app -->|"routes to"| node_settings
node_app -->|"routes to"| node_history
node_login -->|"uses"| node_auth
node_dashboard -->|"queries through"| node_hooks
node_fines -->|"queries through"| node_hooks
node_player_detail -->|"queries through"| node_hooks
node_payments -->|"invokes"| node_api
node_money -->|"invokes"| node_api
node_history -->|"invokes"| node_api
node_hooks -->|"queries and acts"| node_api
node_api -->|"submits changes"| node_sync
node_api -->|"reads and writes"| node_supabase
node_sync_manager -->|"coordinates"| node_sync
node_sync -->|"queues changes"| node_outbox
node_sync -->|"sends changes"| node_supabase
node_auth -->|"checks session"| node_supabase
node_supabase -->|"connects to"| node_database
node_invite_fn -.->|"invites admins"| node_database
node_admins -.->|"requests invitations"| node_invite_fn
node_settings -.->|"manages seasons"| node_archive

click node_app "https://github.com/goncaloazev14/loko_fees/blob/main/src/App.tsx"
click node_dashboard "https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/Dashboard.tsx"
click node_players "https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/Players.tsx"
click node_player_detail "https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/PlayerDetail.tsx"
click node_fines "https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/Fines.tsx"
click node_regulations "https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/Regulamento.tsx"
click node_login "https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/Login.tsx"
click node_auth "https://github.com/goncaloazev14/loko_fees/blob/main/src/lib/auth.tsx"
click node_add_fine "https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/admin/AddFine.tsx"
click node_payments "https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/admin/Payments.tsx"
click node_money "https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/admin/Money.tsx"
click node_settings "https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/admin/Settings.tsx"
click node_history "https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/admin/History.tsx"
click node_archive "https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/admin/Archive.tsx"
click node_admins "https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/admin/Admins.tsx"
click node_invite_fn "https://github.com/goncaloazev14/loko_fees/blob/main/supabase/functions/invite-admin/index.ts"
click node_api "https://github.com/goncaloazev14/loko_fees/blob/main/src/lib/api.ts"
click node_hooks "https://github.com/goncaloazev14/loko_fees/blob/main/src/lib/hooks.ts"
click node_sync_manager "https://github.com/goncaloazev14/loko_fees/blob/main/src/components/SyncManager.tsx"
click node_sync "https://github.com/goncaloazev14/loko_fees/blob/main/src/lib/sync.ts"
click node_outbox "https://github.com/goncaloazev14/loko_fees/blob/main/src/lib/outbox.ts"
click node_supabase "https://github.com/goncaloazev14/loko_fees/blob/main/src/lib/supabase.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_dashboard,node_players,node_player_detail,node_fines toneBlue
class node_regulations,node_add_fine,node_payments,node_money,node_settings,node_history,node_archive,node_admins,node_invite_fn,node_database toneAmber
class node_app,node_login,node_auth toneMint
class node_api,node_hooks,node_sync_manager,node_sync,node_outbox,node_supabase toneRose
class node_visitor toneIndigo
```

## Components

### Public club records

- [Club dashboard](https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/Dashboard.tsx): `src/pages/Dashboard.tsx`
- [Player roster](https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/Players.tsx): `src/pages/Players.tsx`
- [Player account](https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/PlayerDetail.tsx): `src/pages/PlayerDetail.tsx`
- [Fines browser](https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/Fines.tsx): `src/pages/Fines.tsx`

### Administration

- [Rules and fine types](https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/Regulamento.tsx): `src/pages/Regulamento.tsx`
- [Record fines](https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/admin/AddFine.tsx): `src/pages/admin/AddFine.tsx`
- [Record payments](https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/admin/Payments.tsx): `src/pages/admin/Payments.tsx`
- [Income and expenses](https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/admin/Money.tsx): `src/pages/admin/Money.tsx`
- [Season settings](https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/admin/Settings.tsx): `src/pages/admin/Settings.tsx`
- [Change history](https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/admin/History.tsx): `src/pages/admin/History.tsx`
- [Season archive](https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/admin/Archive.tsx): `src/pages/admin/Archive.tsx`
- [Admin management](https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/admin/Admins.tsx): `src/pages/admin/Admins.tsx`
- [Admin invitations](https://github.com/goncaloazev14/loko_fees/blob/main/supabase/functions/invite-admin/index.ts): `supabase/functions/invite-admin/index.ts`

### App runtime

- [Route and layout](https://github.com/goncaloazev14/loko_fees/blob/main/src/App.tsx): `src/App.tsx`
- [Sign-in and access](https://github.com/goncaloazev14/loko_fees/blob/main/src/pages/Login.tsx): `src/pages/Login.tsx`
- [Session and admin checks](https://github.com/goncaloazev14/loko_fees/blob/main/src/lib/auth.tsx): `src/lib/auth.tsx`

### Data and sync

- [Data API](https://github.com/goncaloazev14/loko_fees/blob/main/src/lib/api.ts): `src/lib/api.ts`
- [Query hooks](https://github.com/goncaloazev14/loko_fees/blob/main/src/lib/hooks.ts): `src/lib/hooks.ts`
- [Sync coordinator](https://github.com/goncaloazev14/loko_fees/blob/main/src/components/SyncManager.tsx): `src/components/SyncManager.tsx`
- [Offline sync](https://github.com/goncaloazev14/loko_fees/blob/main/src/lib/sync.ts): `src/lib/sync.ts`
- [Local change queue](https://github.com/goncaloazev14/loko_fees/blob/main/src/lib/outbox.ts): `src/lib/outbox.ts`
- [Supabase client](https://github.com/goncaloazev14/loko_fees/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`

### Other components

- **Visitor or admin**
- **Supabase database and auth**

## Connections

- Visitor or admin → Route and layout: opens (evidence: `README.md`)
- Route and layout → Club dashboard: routes to (evidence: `src/App.tsx`)
- Route and layout → Player roster: routes to (evidence: `src/App.tsx`)
- Route and layout → Player account: routes to (evidence: `src/App.tsx`)
- Route and layout → Fines browser: routes to (evidence: `src/App.tsx`)
- Route and layout → Rules and fine types: routes to (evidence: `src/App.tsx`)
- Route and layout → Sign-in and access: routes to (evidence: `src/App.tsx`)
- Route and layout → Session and admin checks: uses (evidence: `src/App.tsx`)
- Route and layout → Sync coordinator: mounts (evidence: `src/App.tsx`)
- Route and layout → Record fines: routes to (evidence: `src/App.tsx`)
- Route and layout → Record payments: routes to (evidence: `src/App.tsx`)
- Route and layout → Income and expenses: routes to (evidence: `src/App.tsx`)
- Route and layout → Season settings: routes to (evidence: `src/App.tsx`)
- Route and layout → Change history: routes to (evidence: `src/App.tsx`)
- Sign-in and access → Session and admin checks: uses (evidence: `src/pages/Login.tsx`)
- Club dashboard → Query hooks: queries through (evidence: `src/pages/Dashboard.tsx`)
- Fines browser → Query hooks: queries through (evidence: `src/pages/Fines.tsx`)
- Player account → Query hooks: queries through (evidence: `src/pages/PlayerDetail.tsx`)
- Record payments → Data API: invokes (evidence: `src/pages/admin/Payments.tsx`)
- Income and expenses → Data API: invokes (evidence: `src/pages/admin/Money.tsx`)
- Change history → Data API: invokes (evidence: `src/pages/admin/History.tsx`)
- Query hooks → Data API: queries and acts (evidence: `src/lib/hooks.ts`)
- Data API → Offline sync: submits changes (evidence: `src/lib/api.ts`)
- Data API → Supabase client: reads and writes (evidence: `src/lib/api.ts`)
- Sync coordinator → Offline sync: coordinates (evidence: `src/components/SyncManager.tsx`)
- Offline sync → Local change queue: queues changes (evidence: `src/lib/sync.ts`)
- Offline sync → Supabase client: sends changes (evidence: `src/lib/sync.ts`)
- Session and admin checks → Supabase client: checks session (evidence: `src/lib/auth.tsx`)
- Supabase client → Supabase database and auth: connects to (evidence: `src/lib/supabase.ts`)
- Admin invitations → Supabase database and auth: invites admins
- Admin management → Admin invitations: requests invitations
- Season settings → Season archive: manages seasons (evidence: `README.md`)
