# Network Implemented State ## Admin - `/admin/network` renders inside Ballbox. - Ballbox owns the canonical shared `network` model for venues, vending machines, screens, and tv devices; clubs are now ATC-sourced via `atcSportclubId` and hydrated at runtime. - Network admin/API reads from Ballbox Postgres through Prisma. - Current network CRUD covers clubs, venues, and vending machines. - The sports-side club area now also reuses shared `Club` + `Venue` data for both the club dashboard metrics layer and the separate configuration workspace. - Sports-side club flows now also write venue configuration on the shared `Venue` records: opening time, closing time, weekly coach hours, whether external coaches are allowed, per-court coach enablement, coach-class reservation price, a club-coach-only discount over that reservation price, and late-cancellation hours. - Sports-side coach flows now also read those shared `Venue` scheduling fields to clamp coach availability and preview the extra club fee added on top of the coach's own package price, applying the venue discount only when that coach belongs to the club. - Club list/detail/admin data shaping now lives in a dedicated backend network module instead of only inside `lib/ballbox-store.ts`. - Club create/update/delete helpers now also live in a dedicated backend network module instead of only inside `lib/ballbox-store.ts`. - Venue create/update/delete helpers now also live in a dedicated backend network module instead of only inside `lib/ballbox-store.ts`. - Vending-machine route handlers now call `lib/network-backend-vending-machines.ts` directly and use `lib/prisma-errors.ts` for unique-constraint classification. - Club + venue network route handlers and `/admin/network` page now call `lib/network-backend-clubs.ts`, `lib/network-backend-club-mutations.ts`, and `lib/network-backend-venues.ts` directly (plus `lib/prisma-errors.ts`) instead of `lib/ballbox-store.ts`. ## APIs - `/api/network` - `/api/network/[clubId]` - Network API contract is defined from `Zod` schemas in `lib/contracts/network.ts`. - Network routes now return strict success/error shapes validated against shared `Zod` schemas. - Network contract tests now cover list/detail/mutation/delete response shapes and dependency errors. ## Persistence - Ballbox persists `Club`, `Venue`, and `VendingMachine` rows directly in Ballbox Postgres. - `Club` rows are now ATC link-only (source of truth is `atcSportclubId`); name/location are resolved from ATC at read time. - `Club.atcSportclubId` allows `null` for legacy/local rows without ATC linkage, and `db:backfill-atc-clubs` can sync current local club names to ATC summary data when an ATC id exists. - `Screen` and `TvDevice` also live in the same shared core and are consumed today by TVs and payments flows. - Running `pnpm db:seed` upserts the network bootstrap dataset from `prisma/seed-data.ts`. ## Current Gaps - Some UI copy outside `/admin/network` still says `clubs` instead of the shared `network` language. - Cross-links from TVs/payments back into `/admin/network` are not in place yet.