How alonsoospino/goongingaproyectdesigning works
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: api Typed API client · services Domain services · schema.prisma Prisma schema · routes HTTP routes
Components 19
Frontend
Next.js app with public pages, consoles, drafts, and overlays
- Public pages · Standings, schedule, teams, stats, and news surfaces for league users
migration-uidesign/frontend/src/app - Ops consoles · Admin, manager, captain, editor, profile, and content management pages
migration-uidesign/frontend/src/app - Draft UI · Draft table page, polling hooks, and reusable draft components
migration-uidesign/frontend/src/app/draft-table - Overlay routes · OBS browser-source pages for leaderboard, roster, match header, map pool, and win cards
migration-uidesign/frontend/src/app/overlay - Typed API client · Shared wrappers for auth, match, draft, team, news, stats, and overlay asset calls
migration-uidesign/frontend/src/lib/api - Session state · Client-side session persistence and login state for authenticated flows
migration-uidesign/frontend/src/features/session - Uploads & assets · 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 · Starts the API, mounts routes, serves assets, checks DB health, and runs draft-timeout behavior
migration-uidesign/backend/app.js - HTTP routes · Endpoint layer for draft, match, team, news, stats, overlays, auth, and system DB operations
migration-uidesign/backend/routes - Controllers · Request handlers for domain workflows and response shaping
migration-uidesign/backend/controllers - Domain services · Draft state machine, OCR parsing, auth, content, and league domain rules
migration-uidesign/backend/services - Repositories · Prisma-backed query layer for teams, matches, drafts, stats, news, and overlays
migration-uidesign/backend/repositories - Role middleware · Admin, manager, captain, editor, optional auth, and draft/match permission checks
migration-uidesign/backend/middlewares - Backend assets · Server-side asset storage and generated media utilities
migration-uidesign/backend/assets
Persistence
PostgreSQL schema, migrations, and seed/maintenance assets
- Prisma schema · Canonical model for tournaments, teams, members, matches, drafts, stats, maps, heroes, news, and overlay assets
migration-uidesign/backend/prisma/schema.prisma - Migrations · Schema evolution history for draft assets, member settings, OBS URLs, banners, and overlay assets
migration-uidesign/backend/prisma/migrations - Seed 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 · Backup, refresh, seed, wipe, sequence-fix, and validation utilities
migration-uidesign/backend/scripts - Ops utilities · Backup SQL, Discord webhook, admin bootstrap, and image-generation helpers
migration-uidesign/backend/utils
Connections 23
- 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