# diogotocci/pelada-manager architecture

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

- Interactive diagram: https://gitdiagram.com/diogotocci/pelada-manager
- Repository: https://github.com/diogotocci/pelada-manager

## Overview

Pelada Manager organizes pickup-game groups: users sign in, create or join a pelada, manage members and players, mark attendance, and request balanced teams. The Flask app is the API and orchestration layer; browser modules drive the workflows, PostgreSQL persists application data, and a dedicated balancing service computes teams. The README only documents running the app, so feature detail comes from the supplied source excerpts and client help text; unsampled routes and storage behavior are represented conservatively.

Main entry points: [`app.py`](https://github.com/diogotocci/pelada-manager/blob/main/app.py) (Flask routes), [`static/js/api.js`](https://github.com/diogotocci/pelada-manager/blob/main/static/js/api.js) (API requests), [`storage/postgres_storage.py`](https://github.com/diogotocci/pelada-manager/blob/main/storage/postgres_storage.py) (PostgreSQL storage), [`static/js/auth.js`](https://github.com/diogotocci/pelada-manager/blob/main/static/js/auth.js) (Google session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_browser["Web app<br/>[index.html]"]
  node_home["Pelada and players<br/>[players.js]"]
  node_teams_ui["Attendance and teams<br/>[teams.js]"]
  node_auth_ui["Google session<br/>[auth.js]"]
  node_invites_ui["Invites and members<br/>[invites.js]"]
  node_admin_ui["Admin tools<br/>[admin.js]"]
  node_compare_ui["Team comparison<br/>[compare.js]"]
  node_api_client["API requests<br/>[api.js]"]
  node_ui_helpers["UI and help<br/>[ui.js]"]
  node_offline["Offline shell<br/>[sw.js]"]
end

subgraph group_server["Application API"]
  node_flask["Flask routes<br/>[app.py]"]
  node_entry["Deployment entry<br/>[index.py]"]
end

subgraph group_domain["Game domain"]
  node_identity["Player model<br/>[models.py]"]
  node_balancer["Team balancing<br/>[team_balancer.py]"]
end

subgraph group_persistence["Persistence"]
  node_postgres[("PostgreSQL storage")]
end

node_participant(("Participant"))
node_google{{"Google identity"}}
node_database[("PostgreSQL")]

node_participant -->|"uses"| node_browser
node_browser -->|"loads"| node_home
node_home -->|"requests"| node_api_client
node_teams_ui -->|"requests"| node_api_client
node_invites_ui -->|"requests"| node_api_client
node_auth_ui -->|"validates session"| node_flask
node_auth_ui -->|"authenticates with"| node_google
node_invites_ui -->|"checks session"| node_auth_ui
node_admin_ui -.->|"requests"| node_api_client
node_compare_ui -.->|"compares results"| node_teams_ui
node_api_client -.->|"calls API"| node_flask
node_entry -->|"exports app"| node_flask
node_flask -->|"reads and writes"| node_postgres
node_flask -->|"balances teams"| node_balancer
node_balancer -->|"uses player model"| node_identity
node_postgres -->|"maps players"| node_identity
node_postgres -.->|"queries"| node_database
node_offline -->|"caches shell"| node_browser

click node_browser "https://github.com/diogotocci/pelada-manager/blob/main/templates/index.html"
click node_home "https://github.com/diogotocci/pelada-manager/blob/main/static/js/players.js"
click node_teams_ui "https://github.com/diogotocci/pelada-manager/blob/main/static/js/teams.js"
click node_auth_ui "https://github.com/diogotocci/pelada-manager/blob/main/static/js/auth.js"
click node_invites_ui "https://github.com/diogotocci/pelada-manager/blob/main/static/js/invites.js"
click node_admin_ui "https://github.com/diogotocci/pelada-manager/blob/main/static/js/admin.js"
click node_compare_ui "https://github.com/diogotocci/pelada-manager/blob/main/static/js/compare.js"
click node_api_client "https://github.com/diogotocci/pelada-manager/blob/main/static/js/api.js"
click node_ui_helpers "https://github.com/diogotocci/pelada-manager/blob/main/static/js/ui.js"
click node_offline "https://github.com/diogotocci/pelada-manager/blob/main/templates/sw.js"
click node_flask "https://github.com/diogotocci/pelada-manager/blob/main/app.py"
click node_entry "https://github.com/diogotocci/pelada-manager/blob/main/api/index.py"
click node_identity "https://github.com/diogotocci/pelada-manager/blob/main/models.py"
click node_balancer "https://github.com/diogotocci/pelada-manager/blob/main/services/team_balancer.py"
click node_postgres "https://github.com/diogotocci/pelada-manager/blob/main/storage/postgres_storage.py"

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_browser,node_home,node_teams_ui,node_auth_ui,node_invites_ui,node_admin_ui,node_compare_ui,node_api_client,node_ui_helpers,node_offline toneBlue
class node_flask,node_entry,node_database toneAmber
class node_identity,node_balancer toneMint
class node_postgres toneRose
class node_participant,node_google toneIndigo
```

## Components

### Web client

- [Web app](https://github.com/diogotocci/pelada-manager/blob/main/templates/index.html): `templates/index.html`
- [Pelada and players](https://github.com/diogotocci/pelada-manager/blob/main/static/js/players.js): `static/js/players.js`
- [Attendance and teams](https://github.com/diogotocci/pelada-manager/blob/main/static/js/teams.js): `static/js/teams.js`
- [Google session](https://github.com/diogotocci/pelada-manager/blob/main/static/js/auth.js): `static/js/auth.js`
- [Invites and members](https://github.com/diogotocci/pelada-manager/blob/main/static/js/invites.js): `static/js/invites.js`
- [Admin tools](https://github.com/diogotocci/pelada-manager/blob/main/static/js/admin.js): `static/js/admin.js`
- [Team comparison](https://github.com/diogotocci/pelada-manager/blob/main/static/js/compare.js): `static/js/compare.js`
- [API requests](https://github.com/diogotocci/pelada-manager/blob/main/static/js/api.js): `static/js/api.js`
- [UI and help](https://github.com/diogotocci/pelada-manager/blob/main/static/js/ui.js): `static/js/ui.js`
- [Offline shell](https://github.com/diogotocci/pelada-manager/blob/main/templates/sw.js): `templates/sw.js`

### Application API

- [Flask routes](https://github.com/diogotocci/pelada-manager/blob/main/app.py): `app.py`
- [Deployment entry](https://github.com/diogotocci/pelada-manager/blob/main/api/index.py): `api/index.py`

### Game domain

- [Player model](https://github.com/diogotocci/pelada-manager/blob/main/models.py): `models.py`
- [Team balancing](https://github.com/diogotocci/pelada-manager/blob/main/services/team_balancer.py): `services/team_balancer.py`

### Persistence

- [PostgreSQL storage](https://github.com/diogotocci/pelada-manager/blob/main/storage/postgres_storage.py): `storage/postgres_storage.py`

### Other components

- **Participant**
- **Google identity**
- **PostgreSQL**

## Connections

- Participant → Web app: uses
- Web app → Pelada and players: loads
- Pelada and players → API requests: requests (evidence: `static/js/players.js`)
- Attendance and teams → API requests: requests (evidence: `static/js/teams.js`)
- Invites and members → API requests: requests (evidence: `static/js/invites.js`)
- Google session → Flask routes: validates session (evidence: `static/js/auth.js`)
- Google session → Google identity: authenticates with (evidence: `static/js/auth.js`)
- Invites and members → Google session: checks session (evidence: `static/js/invites.js`)
- Admin tools → API requests: requests
- Team comparison → Attendance and teams: compares results
- API requests → Flask routes: calls API
- Deployment entry → Flask routes: exports app (evidence: `api/index.py`)
- Flask routes → PostgreSQL storage: reads and writes (evidence: `app.py`)
- Flask routes → Team balancing: balances teams (evidence: `app.py`)
- Team balancing → Player model: uses player model (evidence: `services/team_balancer.py`)
- PostgreSQL storage → Player model: maps players (evidence: `storage/postgres_storage.py`)
- PostgreSQL storage → PostgreSQL: queries
- Offline shell → Web app: caches shell (evidence: `templates/sw.js`)
