High-Concurrency Multi-Tenant Athletic Facility Scheduler, Bi-Temporal Booking Engine & Financial Telemetry
A bi-temporal reservation kernel and complex operations engine engineered with PostgreSQL generalized search tree (GiST) spatio-temporal exclusion constraints, deterministic mulberry32 mock staging, and automated tabular financial reconciliation.
Modern athletic facilities (padel, tennis, squash, multisport arenas) operate under tight temporal allocation envelopes where double-bookings, volatile cancellation rates, and unverified deposit receipts inflict direct revenue degradation.
SportManager PlayHub delivers a fault-tolerant, multi-tenant scheduling and financial platform:
- Spatio-Temporal Conflict Elimination: Implements PostgreSQL
EXCLUDE USING gistexclusion constraints over court ID and half-open time ranges[start_time, end_time), guaranteeing zero double-allocation at the relational kernel level. - Deterministic Dual-Server Simulation: Incorporates a standalone HTTP mock server and client-side PRNG (
mulberry32), allowing identical demo state reproduction without external credentials. - Bi-Temporal Financial Reconciliation: Automated balance sheet parsing, ledger compilation, and Excel export via
xlsx.
┌────────────────────────────────────────────────────────────────────────┐
│ SPORTS COMPLEX SCHEDULING │
│ [Court Grid UI] ──► [Optimistic Slot Hold] ──► [PostgreSQL RPC] │
└──────────────────────────────────┬─────────────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────────────────┐
│ RELATIONAL CONCURRENCY & INTEGRITY LAYER │
│ • GiST Exclusion: `EXCLUDE USING gist (court_id WITH =, slot WITH &&)` │
│ • Multi-Tenant Isolation: Strict `complex_id` Foreign Key Constraints│
│ • Webhook Idempotency: Cryptographically Verified Payment Callbacks │
└──────────────────────────────────┬─────────────────────────────────────┘
│
┌─────────────────────────┴─────────────────────────┐
▼ ▼
┌──────────────────────────────────┐ ┌──────────────────────────────────┐
│ FINANCIAL TELEMETRY (XLSX) │ │ INTELLIGENT CLIENT MESSAGING │
│ Dynamic Ledger Compilation │ │ Automated WhatsApp Cloud Relay │
│ Balance Sheet Pivot Exports │ │ Transactional Email Dispatch │
└──────────────────────────────────┘ └──────────────────────────────────┘
Conventional application-layer conflict checks fail under concurrent HTTP race conditions (
Enforced in PostgreSQL via Generalized Search Trees:
ALTER TABLE reservations
ADD CONSTRAINT no_overlapping_slots
EXCLUDE USING gist (
court_id WITH =,
tstzrange(start_time, end_time, '[)') WITH &&
);Any parallel transaction attempting to book overlapping quantum intervals is rejected instantaneously with a serialized constraint violation exception.
| Layer | Technology | Specification / Architectural Utility |
|---|---|---|
| Framework | Next.js 16 | Turbopack compilation, React 19 Concurrent Server Components |
| Styling | Tailwind CSS v4 | Sports venue dynamic theming (Radix UI, tw-animate-css) |
| Data Engine | PostgreSQL 15 (Supabase) | Multi-tenant schema with Row Level Security (RLS) & RPCs |
| Tabular Analytics | SheetJS (xlsx) |
Zero-latency browser-side Excel generation & auditing |
| Visualization | Recharts 3.8 | Dynamic court occupancy heatmaps & period comparison charts |
| Data Validation | Zod 4.x | Type-safe schema validation across API boundaries |
The system features an autonomous Two-Tier Topology:
- Mock Microservice (
server/mock-api.mjs): A standalone lightweight HTTP daemon operating on port4000, generating deterministic pseudo-random fixture data viamulberry32. - Reverse Proxy Router (
/api/backend/*): Transparently proxies front-end requests to the active data tier with zero-CORS overhead and automated fallback to local state if the external daemon is partitioned.
sportmanager-playhub/
├── server/
│ └── mock-api.mjs # Autonomous deterministic backend daemon (:4000)
├── src/
│ ├── app/
│ │ ├── (auth)/login/ # Multi-tier role-based authentication portal
│ │ ├── api/backend/[...path]/ # Same-origin resilient proxy router
│ │ ├── dashboard/ # Operational cockpit, KPIs & occupancy charts
│ │ └── page.tsx # Interactive dynamic landing page
│ ├── components/
│ │ ├── calendar/ # Grid scheduling & slot booking modal
│ │ ├── dashboard/ # Metric cards, sidebars & telemetry views
│ │ └── marketing/ # Dynamic promotional interface
│ ├── lib/ # PRNG generators, auth wrappers & validators
│ ├── services/ # Unified abstraction layer (Mock ↔ Supabase)
│ └── types/database.ts # Generated TypeScript schema mirror
└── supabase/migrations/ # Hardened SQL migrations with GiST & RLS
-
Node.js:
$\ge 20.x$ -
NPM:
$\ge 10.x$
# Clone the repository
git clone https://github.com/ExeDevCentral/sportmanager-playhub.git
cd sportmanager-playhub
# Install dependencies deterministically
npm install
# Launch Backend Simulation Daemon (Terminal 1)
npm run backend
# Launch Next.js 16 Web Application (Terminal 2)
npm run dev# Run unit tests, typecheck, and lint
npm test
npm run typecheck
npm run lint
# Probe standalone mock daemon health
curl http://localhost:4000/health
# Verify Next.js proxy routing
curl http://localhost:3000/api/backend/demo/dashboard-datanpm run build
npm run start- Minimalist Mobile Bottom Docks: Dedicated 4-action thumb-zone dock on the public landing page (
Funciones,Simulador,Reservar,Admin) and a 4-action operator dock inside/dashboard(Resumen,Jugadores,Módulos,Landing) withpb-24clearance and zero overlap.
Distributed under the MIT License. Engineered for modern athletic complexes, padel clubs, and municipal sports facilities.