# hasttyr/torre architecture

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

- Interactive diagram: https://gitdiagram.com/hasttyr/torre
- Repository: https://github.com/hasttyr/torre

## Overview

Torre Central Hub manages university chess tournaments through a Vue client and an Express API, with PostgreSQL as the source of truth and Socket.IO notifications for live changes. The central workflow moves from tournament setup and player enrollment through Swiss pairing, result entry, standings and tournament closure; clients refresh data over REST after live events. The graph also preserves documented account, club/coach, dashboard, export and audit capabilities. Some subsystem links are documented only at a high level; unsampled implementation details are not inferred.

Main entry points: [`backend/src/app.ts`](https://github.com/hasttyr/torre/blob/main/backend/src/app.ts) (Express application), [`backend/src/controllers/tournaments.controller.ts`](https://github.com/hasttyr/torre/blob/main/backend/src/controllers/tournaments.controller.ts) (Tournament handlers), [`frontend/src/services/api.ts`](https://github.com/hasttyr/torre/blob/main/frontend/src/services/api.ts) (API services), [`frontend/src/services/socket.ts`](https://github.com/hasttyr/torre/blob/main/frontend/src/services/socket.ts) (Socket client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Vue client"]
  node_spa["Vue application<br/>[main.ts]"]
  node_tournament_views["Tournament screens"]
  node_round_manager["Round manager<br/>[RoundManager.vue]"]
  node_api_client["API services<br/>[api.ts]"]
  node_socket_client["Socket client<br/>[socket.ts]"]
end

subgraph group_api["REST API"]
  node_express["Express application<br/>[app.ts]"]
  node_routes["API routes"]
  node_tournament_controller["Tournament handlers"]
  node_round_controller["Round handlers"]
  node_auth_middleware["Session authorization<br/>[auth.ts]"]
  node_live_events["Tournament broadcasts<br/>[broadcast.ts]"]
end

subgraph group_tournament["Tournament domain"]
  node_tournament_service["Tournament lifecycle"]
  node_pairing["Swiss pairing<br/>[swissPairing.ts]"]
  node_results["Result recording<br/>[results.service.ts]"]
  node_standings["Standings and tiebreaks"]
  node_exports["PDF exports<br/>[exports.service.ts]"]
end

subgraph group_support["Account and insights"]
  node_identity["Authentication<br/>[auth.service.ts]"]
  node_dashboard["Role dashboards"]
  node_clubs_coaches["Clubs and coaches<br/>[clubs.service.ts]"]
  node_data_rights["Personal data rights"]
  node_audit["Administrative audit"]
end

node_people(("Tournament users"))
node_postgres[("PostgreSQL")]
node_socket_server["Socket.IO server"]

node_people -->|"use"| node_spa
node_spa -->|"requests data"| node_api_client
node_api_client -->|"REST calls"| node_express
node_express -->|"mounts routes"| node_routes
node_routes -->|"routes requests"| node_tournament_controller
node_tournament_controller -->|"invokes"| node_tournament_service
node_round_controller -.->|"generates pairings"| node_pairing
node_round_controller -.->|"records results"| node_results
node_round_manager -->|"uses services"| node_api_client
node_round_manager -.->|"listens live"| node_socket_client
node_tournament_views -->|"loads tournament data"| node_api_client
node_tournament_service -->|"reads and writes"| node_postgres
node_pairing -.->|"stores pairings"| node_postgres
node_results -.->|"stores results"| node_postgres
node_standings -.->|"reads tournament data"| node_postgres
node_tournament_controller -->|"gets standings"| node_standings
node_tournament_controller -->|"serves exports"| node_exports
node_express -->|"applies session checks"| node_auth_middleware
node_auth_middleware -->|"verifies sessions"| node_identity
node_identity -->|"reads and writes accounts"| node_postgres
node_express -->|"hosts live channel"| node_socket_server
node_socket_server -->|"dispatches events"| node_live_events
node_live_events -->|"notifies changes"| node_socket_client
node_socket_client -->|"prompts REST refresh"| node_tournament_views
node_dashboard -.->|"reads insights"| node_postgres
node_clubs_coaches -.->|"stores affiliations"| node_postgres
node_data_rights -.->|"handles requests"| node_postgres
node_audit -.->|"stores audit trail"| node_postgres
node_people -.->|"view by role"| node_dashboard

click node_spa "https://github.com/hasttyr/torre/blob/main/frontend/src/main.ts"
click node_tournament_views "https://github.com/hasttyr/torre/tree/main/frontend/src/views/tournament"
click node_round_manager "https://github.com/hasttyr/torre/blob/main/frontend/src/components/tournament-admin/RoundManager.vue"
click node_api_client "https://github.com/hasttyr/torre/blob/main/frontend/src/services/api.ts"
click node_socket_client "https://github.com/hasttyr/torre/blob/main/frontend/src/services/socket.ts"
click node_express "https://github.com/hasttyr/torre/blob/main/backend/src/app.ts"
click node_routes "https://github.com/hasttyr/torre/tree/main/backend/src/routes"
click node_tournament_controller "https://github.com/hasttyr/torre/blob/main/backend/src/controllers/tournaments.controller.ts"
click node_round_controller "https://github.com/hasttyr/torre/blob/main/backend/src/controllers/rounds.controller.ts"
click node_identity "https://github.com/hasttyr/torre/blob/main/backend/src/services/auth.service.ts"
click node_auth_middleware "https://github.com/hasttyr/torre/blob/main/backend/src/middlewares/auth.ts"
click node_tournament_service "https://github.com/hasttyr/torre/blob/main/backend/src/services/tournaments.service.ts"
click node_pairing "https://github.com/hasttyr/torre/blob/main/backend/src/services/pairing/swissPairing.ts"
click node_results "https://github.com/hasttyr/torre/blob/main/backend/src/services/results.service.ts"
click node_standings "https://github.com/hasttyr/torre/blob/main/backend/src/services/standings.service.ts"
click node_exports "https://github.com/hasttyr/torre/blob/main/backend/src/services/exports/exports.service.ts"
click node_live_events "https://github.com/hasttyr/torre/blob/main/backend/src/sockets/broadcast.ts"
click node_dashboard "https://github.com/hasttyr/torre/blob/main/backend/src/services/dashboard/dashboard.service.ts"
click node_clubs_coaches "https://github.com/hasttyr/torre/blob/main/backend/src/services/clubs.service.ts"
click node_data_rights "https://github.com/hasttyr/torre/blob/main/backend/src/services/dataRights.service.ts"
click node_audit "https://github.com/hasttyr/torre/blob/main/backend/src/services/auditLog.service.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_spa,node_tournament_views,node_round_manager,node_api_client,node_socket_client,node_people toneBlue
class node_express,node_routes,node_tournament_controller,node_round_controller,node_auth_middleware,node_live_events,node_postgres toneAmber
class node_tournament_service,node_pairing,node_results,node_standings,node_exports,node_socket_server toneMint
class node_identity,node_dashboard,node_clubs_coaches,node_data_rights,node_audit toneRose
```

## Components

### Vue client

- [Vue application](https://github.com/hasttyr/torre/blob/main/frontend/src/main.ts): `frontend/src/main.ts`
- [Tournament screens](https://github.com/hasttyr/torre/tree/main/frontend/src/views/tournament): `frontend/src/views/tournament`
- [Round manager](https://github.com/hasttyr/torre/blob/main/frontend/src/components/tournament-admin/RoundManager.vue): `frontend/src/components/tournament-admin/RoundManager.vue`
- [API services](https://github.com/hasttyr/torre/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [Socket client](https://github.com/hasttyr/torre/blob/main/frontend/src/services/socket.ts): `frontend/src/services/socket.ts`

### REST API

- [Express application](https://github.com/hasttyr/torre/blob/main/backend/src/app.ts): `backend/src/app.ts`
- [API routes](https://github.com/hasttyr/torre/tree/main/backend/src/routes): `backend/src/routes`
- [Tournament handlers](https://github.com/hasttyr/torre/blob/main/backend/src/controllers/tournaments.controller.ts): `backend/src/controllers/tournaments.controller.ts`
- [Round handlers](https://github.com/hasttyr/torre/blob/main/backend/src/controllers/rounds.controller.ts): `backend/src/controllers/rounds.controller.ts`
- [Session authorization](https://github.com/hasttyr/torre/blob/main/backend/src/middlewares/auth.ts): `backend/src/middlewares/auth.ts`
- [Tournament broadcasts](https://github.com/hasttyr/torre/blob/main/backend/src/sockets/broadcast.ts): `backend/src/sockets/broadcast.ts`

### Tournament domain

- [Tournament lifecycle](https://github.com/hasttyr/torre/blob/main/backend/src/services/tournaments.service.ts): `backend/src/services/tournaments.service.ts`
- [Swiss pairing](https://github.com/hasttyr/torre/blob/main/backend/src/services/pairing/swissPairing.ts): `backend/src/services/pairing/swissPairing.ts`
- [Result recording](https://github.com/hasttyr/torre/blob/main/backend/src/services/results.service.ts): `backend/src/services/results.service.ts`
- [Standings and tiebreaks](https://github.com/hasttyr/torre/blob/main/backend/src/services/standings.service.ts): `backend/src/services/standings.service.ts`
- [PDF exports](https://github.com/hasttyr/torre/blob/main/backend/src/services/exports/exports.service.ts): `backend/src/services/exports/exports.service.ts`

### Account and insights

- [Authentication](https://github.com/hasttyr/torre/blob/main/backend/src/services/auth.service.ts): `backend/src/services/auth.service.ts`
- [Role dashboards](https://github.com/hasttyr/torre/blob/main/backend/src/services/dashboard/dashboard.service.ts): `backend/src/services/dashboard/dashboard.service.ts`
- [Clubs and coaches](https://github.com/hasttyr/torre/blob/main/backend/src/services/clubs.service.ts): `backend/src/services/clubs.service.ts`
- [Personal data rights](https://github.com/hasttyr/torre/blob/main/backend/src/services/dataRights.service.ts): `backend/src/services/dataRights.service.ts`
- [Administrative audit](https://github.com/hasttyr/torre/blob/main/backend/src/services/auditLog.service.ts): `backend/src/services/auditLog.service.ts`

### Other components

- **Tournament users**
- **PostgreSQL**
- **Socket.IO server**

## Connections

- Tournament users → Vue application: use (evidence: `README.md`)
- Vue application → API services: requests data (evidence: `README.md`)
- API services → Express application: REST calls (evidence: `README.md`)
- Express application → API routes: mounts routes (evidence: `backend/src/app.ts`)
- API routes → Tournament handlers: routes requests (evidence: `backend/src/routes/tournaments.routes.ts`)
- Tournament handlers → Tournament lifecycle: invokes (evidence: `backend/src/controllers/tournaments.controller.ts`)
- Round handlers → Swiss pairing: generates pairings
- Round handlers → Result recording: records results
- Round manager → API services: uses services (evidence: `frontend/src/components/tournament-admin/RoundManager.vue`)
- Round manager → Socket client: listens live
- Tournament screens → API services: loads tournament data (evidence: `README.md`)
- Tournament lifecycle → PostgreSQL: reads and writes (evidence: `README.md`)
- Swiss pairing → PostgreSQL: stores pairings
- Result recording → PostgreSQL: stores results
- Standings and tiebreaks → PostgreSQL: reads tournament data
- Tournament handlers → Standings and tiebreaks: gets standings (evidence: `backend/src/controllers/tournaments.controller.ts`)
- Tournament handlers → PDF exports: serves exports
- Express application → Session authorization: applies session checks (evidence: `backend/src/app.ts`)
- Session authorization → Authentication: verifies sessions (evidence: `backend/src/middlewares/auth.ts`)
- Authentication → PostgreSQL: reads and writes accounts (evidence: `backend/src/services/auth.service.ts`)
- Express application → Socket.IO server: hosts live channel
- Socket.IO server → Tournament broadcasts: dispatches events
- Tournament broadcasts → Socket client: notifies changes (evidence: `README.md`)
- Socket client → Tournament screens: prompts REST refresh (evidence: `README.md`)
- Role dashboards → PostgreSQL: reads insights
- Clubs and coaches → PostgreSQL: stores affiliations
- Personal data rights → PostgreSQL: handles requests
- Administrative audit → PostgreSQL: stores audit trail
- Tournament users → Role dashboards: view by role
