How uneven-coder/tournament-prototype works
1. Overall shape
This is a Next.js App Router prototype for tournament management. The repository is split into three main layers: route-driven UI under app/, reusable UI and feature components under components/, and local persistence/data access under lib/db/ backed by data/tournament.sqlite.
2. Route topology
The UI is organized by route groups: app/(auth) for login/register screens and app/(app) for the authenticated product area. The authenticated group contains pages for dashboard, tournaments, teams, profile, matches, scoring, schedule, attendance, approvals, venues, leaderboard, rules, settings, and related subflows like score entry and match creation/results. Most route files are thin page entry points that compose feature components.
3. App shell and navigation
app/(app)/layout.tsx is the persistent application frame, backed by components/blocks/app-shell.tsx and app-shell-client.tsx. This is the main boundary for global navigation, page chrome, and client-side app state. The README describes a header/sidebar style shell with active navigation and user info, so the architecture centers around a shared layout rather than per-page navigation.
4. Authentication boundary
Authentication is split into app/(auth)/login, app/(auth)/register, and several API routes under app/api/auth/* such as login, signup, admin login/register, magic link, session, and verify. The implementation is prototype-style: session state is held client-side in context, while the API routes simulate credential checks against the seeded SQLite data. This means auth is both a UI flow and a mocked server boundary.
5. Data access layer
lib/db/connection.ts, schema.ts, queries.ts, seed.ts, and id.ts form the persistence subsystem. The app reads and writes through this layer instead of directly touching the SQLite file from UI code. The README indicates the database is auto-seeded on first API hit, so the data layer is responsible for initializing demo records and keeping the prototype stateful across requests.
6. API surface
app/api/ exposes the functional backend for the prototype. There are endpoints for tournaments, teams, venues, users, rules, profile, registry, approvals, attendance, leaderboard, matches, games, fixed events, and score submission. These routes are the integration point between UI actions and the SQLite-backed data layer, and they simulate create/update/delete behavior even though the product is not wired to a real production backend.
7. State management
Global client state is intentionally split by concern in lib/hooks/: user-context.tsx, teams-context.tsx, and tournaments-context.tsx, plus a shared provider composition in providers.tsx. This matches the README’s guidance: authentication state, team data, and tournament data are separated rather than using one monolithic store. The app shell and many pages likely consume these contexts to keep lists and session state in sync after API interactions.
8. Feature component layer
components/features/ contains domain-focused form and editor blocks such as auth-form.tsx, profile-settings.tsx, teams-manager.tsx, and tournament-form.tsx. These are the main reusable business UI units, sitting above the primitive UI library and below the route pages. This separation keeps page files small and makes it easier to reuse forms across create/edit flows.
9. UI system
The UI is built on shadcn-style primitives in components/ui/ with components.json, Tailwind via globals.css, and theme support in components/theme-provider.tsx. This layer provides buttons, inputs, cards, tables, dialogs, tabs, toasts, and form controls used across the app. Architecturally, this is the presentation foundation shared by every route and feature component.
10. Page families and subflows
Several route groups represent distinct product workflows rather than independent pages: tournament creation/detail under app/(app)/tournaments, score entry under app/(app)/score-entry, and match browsing/results under app/(app)/matches and app/(app)/match-results. Similarly, participants, registry, sessions, roles, and access-links suggest administrative and operational screens around the core tournament model. These are best viewed as domain slices around the same underlying tournament/team/match data.
11. Presentation route
app/presentation/[id]/page.tsx is a separate viewing path, likely for display or shareable tournament presentation mode. It sits outside the main app shell pattern and should be treated as a consumer-facing read-only boundary, distinct from the authenticated management UI.
12. Key data flow
The common flow is: user interacts with a page component → feature component handles form/UI state → context or API route is used → SQLite-backed query layer reads/writes data → updated state is reflected back in the UI. Because this is a prototype, the “backend” is intentionally lightweight and many actions are simulated, but the architectural boundary is still clear: route/UI, client state, API, and local database.
Main entry points: (app)/layout.tsx App Shell Route · queries.ts Queries · providers.tsx Providers · app/layout.tsx Root Layout
Components 32
App UI
Route-driven screens and route shells
- Root Layout · Global document shell
app/layout.tsx - Home · Entry point into the prototype
app/page.tsx - Auth Layout · Login and registration shell
app/(auth)/layout.tsx - Login · Sign-in screen
app/(auth)/login/page.tsx - Register · Account creation screen
app/(auth)/register/page.tsx - App Shell Route · Authenticated product frame
app/(app)/layout.tsx - Dashboard · Main authenticated landing page
app/(app)/dashboard/page.tsx - Tournaments · Tournament listing and management
app/(app)/tournaments/[id]/page.tsx - Teams · Team administration screen
app/(app)/teams/page.tsx - Matches · Match browsing and operations
app/(app)/matches/page.tsx - Score Entry · Manual score submission flow
app/(app)/score-entry/page.tsx - Presentation · Shareable display view
app/presentation/[id]/page.tsx
API Layer
Local backend endpoints over SQLite
- Auth API · Login, signup, session, and verification routes
app/api/auth/login/route.ts - Tournaments API · Tournament CRUD endpoints
app/api/tournaments/route.ts - Teams API · Team endpoints
app/api/teams/route.ts - Matches API · Match CRUD and score endpoints
app/api/matches/route.ts - Score API · Score submission endpoint
app/api/matches/[id]/score/route.ts - Ops API · Approvals, attendance, leaderboard, registry, rules, profile, venues, users
app/api/venues/route.ts
Shared System
Reusable components, state, and persistence
- App Shell · Shared header/sidebar frame
components/blocks/app-shell.tsx - Shell Client · Client-side shell behavior
components/blocks/app-shell-client.tsx - Providers · Composes global client contexts
lib/hooks/providers.tsx - User Context · Session and user state
lib/hooks/user-context.tsx - Teams Context · Teams state cache
lib/hooks/teams-context.tsx - Tournaments Context · Tournament state cache
lib/hooks/tournaments-context.tsx - Auth Form · Reusable login/register form
components/features/auth-form.tsx - Tournament Form · Tournament editor component
components/features/tournament-form.tsx - Teams Manager · Team administration UI
components/features/teams-manager.tsx - Profile Settings · Account settings editor
components/features/profile-settings.tsx - DB Connection · SQLite connection setup
lib/db/connection.ts - Queries · Persistence query layer
lib/db/queries.ts - Seed Data · Initial demo records
lib/db/seed.ts
Connections 39
- Root Layout → Home: routes · Root entry renders landing page
- Root Layout → Auth Layout: routes · Routes into auth area
- Root Layout → App Shell Route: routes · Routes into authenticated area
- Auth Layout → Login: wraps · Auth shell renders login screen
- Auth Layout → Register: wraps · Auth shell renders registration screen
- App Shell Route → App Shell: uses · Authenticated area uses shared shell
- App Shell Route → Providers: wraps · Injects global client state
- App Shell → Shell Client: composes · Shell includes client-side behavior
- Providers → User Context: includes · Session state provider
- Providers → Teams Context: includes · Teams state provider
- Providers → Tournaments Context: includes · Tournament state provider
- App Shell Route → Dashboard: navigates · Default authenticated landing screen
- App Shell Route → Tournaments: navigates · Tournament management area
- App Shell Route → Teams: navigates · Team management area
- App Shell Route → Matches: navigates · Match operations area
- App Shell Route → Score Entry: navigates · Score submission workflow
- App Shell Route → Presentation: navigates · Presentation/read-only view
- Login → Auth Form: uses · Login screen composes form
- Register → Auth Form: uses · Register screen composes form
- Tournaments → Tournament Form: uses · Create/edit tournament flow
- Teams → Teams Manager: uses · Team administration UI
- Dashboard → Tournaments Context: reads · Dashboard reflects tournament state
- Profile Settings → User Context: reads · Profile UI uses current user state
- Login → Auth API: calls · Authenticates through API
- Register → Auth API: calls · Registers through API
- Tournaments → Tournaments API: calls · Loads and updates tournaments
- Teams → Teams API: calls · Loads and updates teams
- Matches → Matches API: calls · Reads match data
- Score Entry → Score API: calls · Submits scores
- Presentation → Matches API: reads · Presentation consumes match data
- Ops API → Queries: reads/writes · Operational endpoints persist through queries
- Auth API → Queries: reads/writes · Auth operations persist through queries
- Tournaments API → Queries: reads/writes · Tournament persistence
- Teams API → Queries: reads/writes · Team persistence
- Matches API → Queries: reads/writes · Match persistence
- Score API → Queries: writes · Score submission updates state
- Queries → DB Connection: uses · Runs against SQLite connection
- Seed Data → DB Connection: initializes · Seeds demo database on startup
- DB Connection → SQLite File: opens · Connection targets bundled SQLite file