# alonsoospino/goongingaproyectdesigning architecture

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

- Interactive diagram: https://gitdiagram.com/alonsoospino/goongingaproyectdesigning
- Repository: https://github.com/alonsoospino/goongingaproyectdesigning

## Overview

1. **Repository shape**
   This is a monorepo for a league operations platform. The two core deployable systems are `migration-uidesign/frontend` (Next.js UI) and `migration-uidesign/backend` (Express API + Prisma). A third piece, mentioned in the README, is an Electron launcher for local OBS workflows.

2. **Frontend boundary**
   The frontend is a Next.js App Router application. It contains both public league pages and authenticated operational consoles, plus a dedicated set of OBS browser-source overlay routes under `/overlay/*`. All backend calls go through typed wrappers in `src/lib/api`, so the UI does not talk to the database or business logic directly.

3. **Backend boundary**
   The backend is layered as routes → controllers → services → repositories. Routes expose the HTTP API, controllers orchestrate workflows, services hold domain logic such as draft handling and OCR parsing, and repositories encapsulate Prisma queries. `app.js` is the entry point that mounts routes, serves assets, checks DB health, and starts background behavior such as draft timeouts.

4. **Persistence and schema**
   Prisma is the data access layer, with migrations and schema under `backend/prisma`. PostgreSQL is the canonical store. The main domain tables visible from the tree/README are tournament, team, member, match, draft table, draft actions, player stats, maps, heroes, news, and leaderboard overlay assets.

5. **Authentication and roles**
   Login is centered on `/member/login`, with JWT-based session state returned by the backend and persisted client-side in the frontend session feature. Access is controlled by middleware for roles such as admin, manager, captain, and editor. This role boundary determines who can edit content, manage matches, perform draft actions, or publish news.

6. **Match and draft system**
   The live draft is a major subsystem. The frontend draft table page polls the backend for authoritative state, while the backend `draft` controller/service pair owns the state machine, turn timing, and ordered draft action log. Captains can act only for their own team, whereas managers/admins can operate both sides and can also access read-only overlay-style views via a key.

7. **League content and public surfaces**
   Public-facing pages cover standings, schedule, teams, stats, and news. Those views are backed by match, team, player stat, and news APIs. The same data also feeds operational pages, so public and admin views share the same backend model rather than maintaining separate content stores.

8. **OCR and stat registration**
   Player stat registration is a distinct pipeline. Screenshot uploads come from the frontend into the backend, which uses a Google Vision integration and parsing services to recover scoreboard text, match players, and role composition. The workflow supports preview/correction before batch-creating `PlayerStat` records.

9. **Broadcast overlays**
   OBS browser-source pages are first-class frontend routes, not a separate app. Overlay components render leaderboard, roster, match header, map pool, and win-card graphics, pulling live data plus persisted overlay settings from the backend. This makes broadcast output part of the same data flow as admin and public UI.

10. **Assets and uploads**
   The system manages several asset classes: hero art, map images, team branding, content images, and overlay backgrounds. The backend serves some static game assets from the frontend asset folders, while upload helpers and API routes handle user-provided media and overlay configuration persistence.

11. **Operational scripts and maintenance**
   The backend includes scripts for DB backup, seeding maps, refreshing map/hero data, wiping, and fixing sequences. These are part of the operational boundary around the database rather than the user-facing product, and they indicate the repo is designed for live league administration with maintenance workflows built in.

12. **Key architecture diagram boundaries**
   The most important arrows to show are: Next.js pages and overlays → typed API client → Express routes → controllers → services → repositories → Prisma/Postgres. A second important path is frontend asset/admin tools → overlay asset persistence → OBS overlay pages. A third path is screenshot upload → OCR/parse services → player stat records → stats/public views.

Main entry points: [`migration-uidesign/frontend/src/lib/api`](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/frontend/src/lib/api) (Typed API client), [`migration-uidesign/backend/services`](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/services) (Domain services), [`migration-uidesign/backend/prisma/schema.prisma`](https://github.com/alonsoospino/goongingaproyectdesigning/blob/main/migration-uidesign/backend/prisma/schema.prisma) (Prisma schema), [`migration-uidesign/backend/routes`](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/routes) (HTTP routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_fe_pages["Public pages<br/>Next.js routes"]
  node_fe_admin["Ops consoles<br/>Next.js routes"]
  node_fe_draft["Draft UI<br/>Next.js feature"]
  node_fe_overlay["Overlay routes<br/>Next.js broadcast UI"]
  node_fe_api["Typed API client<br/>Frontend data layer"]
  node_fe_session["Session state<br/>Frontend auth"]
  node_fe_uploads["Uploads & assets<br/>Frontend asset tools"]
end

subgraph group_backend["Backend"]
  node_be_app["App entry<br/>Express bootstrap<br/>[app.js]"]
  node_be_routes["HTTP routes<br/>Express routes"]
  node_be_ctrl["Controllers<br/>API orchestration"]
  node_be_svc["Domain services<br/>Business logic"]
  node_be_repo["Repositories<br/>Data access"]
  node_be_mw["Role middleware<br/>Auth guard"]
  node_be_assets["Backend assets<br/>File/static assets"]
end

subgraph group_data["Persistence"]
  node_db_schema[("Prisma schema<br/>Database schema<br/>[schema.prisma]")]
  node_db_migrations["Migrations"]
  node_db_seed["Seed data<br/>Bootstrap data<br/>[seed.js]"]
end

subgraph group_ops["Operations"]
  node_ops_scripts["Maintenance scripts<br/>Ops scripts"]
  node_ops_utils["Ops utilities<br/>Operational helpers"]
end

node_fe_pages -->|"data fetch"| node_fe_api
node_fe_admin -->|"admin actions"| node_fe_api
node_fe_draft -->|"poll/state"| node_fe_api
node_fe_overlay -->|"live data"| node_fe_api
node_fe_session -->|"auth header"| node_fe_api
node_fe_uploads -->|"upload requests"| node_fe_api
node_fe_uploads -.->|"media flow"| node_be_assets
node_fe_api -->|"HTTP calls"| node_be_routes
node_be_app -->|"mounts"| node_be_routes
node_be_routes -->|"guards"| node_be_mw
node_be_routes -->|"dispatch"| node_be_ctrl
node_be_ctrl -->|"business logic"| node_be_svc
node_be_svc -->|"queries"| node_be_repo
node_be_repo -->|"prisma models"| node_db_schema
node_db_schema -->|"evolution"| node_db_migrations
node_db_schema -->|"bootstrap"| node_db_seed
node_be_svc -.->|"domain state"| node_db_schema
node_be_svc -.->|"asset ops"| node_be_assets
node_be_app -.->|"backup helpers"| node_ops_utils
node_ops_scripts -->|"maintenance"| node_db_schema
node_ops_scripts -->|"uses"| node_ops_utils
node_be_svc -.->|"draft workflow"| node_fe_draft
node_be_svc -.->|"broadcast data"| node_fe_overlay

click node_fe_pages "https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/frontend/src/app"
click node_fe_admin "https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/frontend/src/app"
click node_fe_draft "https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/frontend/src/app/draft-table"
click node_fe_overlay "https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/frontend/src/app/overlay"
click node_fe_api "https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/frontend/src/lib/api"
click node_fe_session "https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/frontend/src/features/session"
click node_fe_uploads "https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/frontend/src/lib"
click node_be_app "https://github.com/alonsoospino/goongingaproyectdesigning/blob/main/migration-uidesign/backend/app.js"
click node_be_routes "https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/routes"
click node_be_ctrl "https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/controllers"
click node_be_svc "https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/services"
click node_be_repo "https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/repositories"
click node_be_mw "https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/middlewares"
click node_be_assets "https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/assets"
click node_db_schema "https://github.com/alonsoospino/goongingaproyectdesigning/blob/main/migration-uidesign/backend/prisma/schema.prisma"
click node_db_migrations "https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/prisma/migrations"
click node_db_seed "https://github.com/alonsoospino/goongingaproyectdesigning/blob/main/migration-uidesign/backend/prisma/seed.js"
click node_ops_scripts "https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/scripts"
click node_ops_utils "https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/utils"

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_fe_pages,node_fe_admin,node_fe_draft,node_fe_overlay,node_fe_api,node_fe_session,node_fe_uploads toneBlue
class node_be_app,node_be_routes,node_be_ctrl,node_be_svc,node_be_repo,node_be_mw,node_be_assets toneAmber
class node_db_schema,node_db_migrations,node_db_seed toneMint
class node_ops_scripts,node_ops_utils toneRose
```

## Components

### Frontend

Next.js app with public pages, consoles, drafts, and overlays

- [Public pages](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/frontend/src/app): Next.js routes · Standings, schedule, teams, stats, and news surfaces for league users · `migration-uidesign/frontend/src/app`
- [Ops consoles](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/frontend/src/app): Next.js routes · Admin, manager, captain, editor, profile, and content management pages · `migration-uidesign/frontend/src/app`
- [Draft UI](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/frontend/src/app/draft-table): Next.js feature · Draft table page, polling hooks, and reusable draft components · `migration-uidesign/frontend/src/app/draft-table`
- [Overlay routes](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/frontend/src/app/overlay): Next.js broadcast UI · OBS browser-source pages for leaderboard, roster, match header, map pool, and win cards · `migration-uidesign/frontend/src/app/overlay`
- [Typed API client](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/frontend/src/lib/api): Frontend data layer · Shared wrappers for auth, match, draft, team, news, stats, and overlay asset calls · `migration-uidesign/frontend/src/lib/api`
- [Session state](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/frontend/src/features/session): Frontend auth · Client-side session persistence and login state for authenticated flows · `migration-uidesign/frontend/src/features/session`
- [Uploads & assets](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/frontend/src/lib): Frontend asset tools · Blob upload helpers, asset URL handling, and image-backed content flows · `migration-uidesign/frontend/src/lib`

### Backend

Express API, domain services, and Prisma data access

- [App entry](https://github.com/alonsoospino/goongingaproyectdesigning/blob/main/migration-uidesign/backend/app.js): Express bootstrap · Starts the API, mounts routes, serves assets, checks DB health, and runs draft-timeout behavior · `migration-uidesign/backend/app.js`
- [HTTP routes](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/routes): Express routes · Endpoint layer for draft, match, team, news, stats, overlays, auth, and system DB operations · `migration-uidesign/backend/routes`
- [Controllers](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/controllers): API orchestration · Request handlers for domain workflows and response shaping · `migration-uidesign/backend/controllers`
- [Domain services](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/services): Business logic · Draft state machine, OCR parsing, auth, content, and league domain rules · `migration-uidesign/backend/services`
- [Repositories](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/repositories): Data access · Prisma-backed query layer for teams, matches, drafts, stats, news, and overlays · `migration-uidesign/backend/repositories`
- [Role middleware](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/middlewares): Auth guard · Admin, manager, captain, editor, optional auth, and draft/match permission checks · `migration-uidesign/backend/middlewares`
- [Backend assets](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/assets): File/static assets · Server-side asset storage and generated media utilities · `migration-uidesign/backend/assets`

### Persistence

PostgreSQL schema, migrations, and seed/maintenance assets

- [Prisma schema](https://github.com/alonsoospino/goongingaproyectdesigning/blob/main/migration-uidesign/backend/prisma/schema.prisma): Database schema · Canonical model for tournaments, teams, members, matches, drafts, stats, maps, heroes, news, and overlay assets · `migration-uidesign/backend/prisma/schema.prisma`
- [Migrations](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/prisma/migrations): Prisma migrations · Schema evolution history for draft assets, member settings, OBS URLs, banners, and overlay assets · `migration-uidesign/backend/prisma/migrations`
- [Seed data](https://github.com/alonsoospino/goongingaproyectdesigning/blob/main/migration-uidesign/backend/prisma/seed.js): Bootstrap data · Map and user seeding plus SQL generation helpers · `migration-uidesign/backend/prisma/seed.js`

### Operations

Scripts and workflows for maintenance and local production support

- [Maintenance scripts](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/scripts): Ops scripts · Backup, refresh, seed, wipe, sequence-fix, and validation utilities · `migration-uidesign/backend/scripts`
- [Ops utilities](https://github.com/alonsoospino/goongingaproyectdesigning/tree/main/migration-uidesign/backend/utils): Operational helpers · Backup SQL, Discord webhook, admin bootstrap, and image-generation helpers · `migration-uidesign/backend/utils`

## Connections

- Public pages → Typed API client: data fetch · Public pages load league content through the typed client
- Ops consoles → Typed API client: admin actions · Operational consoles use the shared client for mutations and reads
- Draft UI → Typed API client: poll/state · Draft UI polls authoritative draft state from the backend
- Overlay routes → Typed API client: live data · Overlay routes consume match, leaderboard, and overlay asset APIs
- Session state → Typed API client: auth header · Session state feeds authenticated API access
- Uploads & assets → Typed API client: upload requests · Frontend asset tools send media and asset configuration requests
- Uploads & assets → Backend assets: media flow · User-provided and generated media ultimately aligns with backend asset handling
- Typed API client → HTTP routes: HTTP calls · All frontend backend communication goes through API endpoints
- App entry → HTTP routes: mounts · Application bootstrap registers the route surface
- HTTP routes → Role middleware: guards · Routes apply role and auth middleware where needed
- HTTP routes → Controllers: dispatch · Route handlers delegate workflow orchestration to controllers
- Controllers → Domain services: business logic · Controllers call services for draft, OCR, auth, and domain rules
- Domain services → Repositories: queries · Services rely on repositories for persistence access
- Repositories → Prisma schema: prisma models · Repositories operate on the Prisma schema
- Prisma schema → Migrations: evolution · Migrations define and evolve the schema
- Prisma schema → Seed data: bootstrap · Seed scripts populate core reference data
- Domain services → Prisma schema: domain state · Services read and mutate league state through the schema-backed model
- Domain services → Backend assets: asset ops · Services and utilities manage uploaded and generated media
- App entry → Ops utilities: backup helpers · Startup and maintenance workflows share operational helpers
- Maintenance scripts → Prisma schema: maintenance · Scripts inspect, refresh, seed, and repair the database
- Maintenance scripts → Ops utilities: uses · Maintenance scripts rely on shared operational utilities
- Domain services → Draft UI: draft workflow · Draft state machine feeds the polling draft UI
- Domain services → Overlay routes: broadcast data · Leaderboard, roster, match header, map pool, and win-card overlays are driven by backend state
