How ekirmen/zeatingmaps works
1. Overall shape
ZeatingMaps is a multi-tenant ticketing platform split into three main runtime surfaces: a public storefront, an organizer backoffice, and SaaS/admin consoles. The frontend is a single React/Vite codebase under src/, while backend capabilities are mostly Vercel serverless functions under api/, backed by Supabase PostgreSQL.
2. Primary user-facing applications
The UI is partitioned by business role, not just by route:
- src/store/ is the buyer-facing storefront for discovering events, choosing seats, paying, and downloading tickets.
- src/backoffice/ is the organizer/tenant operations app for event setup, seating maps, sales, CRM, email campaigns, and reporting.
- src/saas/ and src/admin-saas/ are super-admin / tenant-management surfaces for platform-level billing, access control, monitoring, and tenant lifecycle.
3. Core data boundary: Supabase multi-tenancy
Supabase is the system of record and the primary isolation boundary. The repo strongly centers on tenant_id-scoped data with Row Level Security enforcement. Client code uses Supabase through shared config and service wrappers in src/config/, src/supabaseClient.jsx, and src/services/, while serverless functions use elevated service credentials when needed.
4. Transaction and payment pipeline
Payment flows are orchestrated from the storefront and backoffice through service modules such as src/store/services/paymentGatewaysService.js, src/services/paymentTransactionsService.jsx, and related payment processors. On the server side, the /api/payments/... functions and api-lib/payments/ handle intent creation, transaction creation, locator-based lookup, email follow-up, and ticket output generation.
5. Seat inventory and locking
Seat availability is managed as a shared real-time concern. The frontend has dedicated seat stores and sync hooks (src/services/seatLocksService.jsx, src/hooks/useMapaSeatsSync.jsx, src/store/components/SeatSelectionTimer.jsx, etc.), while the backend exposes atomic lock endpoints under /api/seat-locks/. This is a key consistency boundary to prevent double-selling in both the online store and the box office.
6. Event and venue domain model
The backoffice’s operational model is built around Recinto (venue), Sala (hall), Zona (zone), Evento (event), and Función (performance). These concepts are reflected in the API (/api/recintos, /api/zonas, /api/mapas/[salaId]) and in dedicated backoffice pages for CRUD, pricing, discounts, promotions, and seat configuration.
7. Seating-map editor and runtime viewer
A major subsystem is the custom seating-map engine. The editor lives mostly in src/backoffice/components/CrearMapa/ and related compMapa components, with many hooks for selection, snapping, history, transforms, validation, and drag/drop. The storefront and backoffice consumers reuse seating-view components under src/components/ and src/store/components/, with worker-based computation for layout and seat calculations.
8. Checkout, carts, and state management
Cart and session state are managed client-side with Zustand stores and custom hooks. The storefront uses src/store/cartStore.js, src/store/hooks/, and local persistence patterns to support seat reservations, timers, restored carts, and payment retries. This layer is the boundary between UI selection and payment execution.
9. Tickets, downloads, and post-payment fulfillment
Fulfillment is handled after transaction completion by generating downloadable artifacts. The repository includes PDF ticket generation and Apple Wallet support through api/download-ticket.js and api-lib/payments/pkpass-generator.js, plus download helpers in src/utils/downloadTicket.jsx and src/utils/downloadPkpass.jsx. Email delivery of tickets is also part of this fulfillment path.
10. Email and campaign subsystem
Email is a first-class subsystem, not just a notification utility. api/send-email/, api/webhooks/resend.js, and backoffice email tooling support transactional mail, campaign composition, template editing, open tracking, and tenant-specific configuration. Supporting services exist in src/backoffice/services/ and src/services/emailTemplateService.jsx.
11. PWA, offline, and performance helpers
The public experience is optimized for mobile and intermittent connectivity. public/service-worker.js, public/offline.html, public/seatCalculations.worker.js, and the src/workers/ folder indicate offline/PWA support and background computation. There are also preloading, lazy-loading, and image optimization utilities used to keep the storefront and seating maps responsive.
12. Printing and on-site sales
The backoffice includes a presencial sales/box-office workflow (src/backoffice/pages/Boleteria.jsx) with printer integrations. The repo explicitly supports BOCA and Godex thermal printing via services/components under src/backoffice/services/bocaPrinterService.jsx and printer config UI, which affects the architecture as a separate fulfillment/output channel.
13. Auxiliary local infrastructure
Two local helper servers exist outside the main Vercel deployment path: local-sync-server/ and servidor-local/. These suggest local synchronization/test harnesses for map or data workflows during development, distinct from production serverless APIs.
14. Cross-cutting boundaries
Authentication, tenant access, roles, and audit logging are pervasive concerns. They are implemented via shared contexts, protected-route wrappers, role-based access components, audit services, and tenant guards across all three app surfaces. For an architecture diagram, these should be drawn as shared platform layers cutting across storefront, backoffice, and SaaS admin, with Supabase RLS and serverless service-role functions as the main enforcement boundaries.
Main entry points: StoreApp.jsx Storefront · BackofficeAppWithRoles.jsx Backoffice · supabase.jsx Supabase client · AuthContext.jsx Auth & tenant
Components 19
Frontend surfaces
React/Vite app partitioned by business role.
- Storefront · Public event discovery, seat selection, checkout, and ticket access.
src/store/StoreApp.jsx - Backoffice · Organizer operations for events, seating maps, CRM, campaigns, reporting, and box office.
src/backoffice/BackofficeAppWithRoles.jsx - SaaS admin · Super-admin and tenant-management console for platform operations.
src/saas - Admin SaaS · Admin-facing tenant and payment-gateway management surface.
src/admin-saas/AdminSaasApp.jsx - Ops tools · Event, venue, pricing, CRM, reports, printing, and support workflows.
src/backoffice/pages - Checkout flow · Cart, timers, seat reservation, payment screens, and success pages.
src/store/pages/Pay.jsx
Backend APIs
Serverless endpoints and payment helpers.
- Seat locks API · Atomic seat-lock endpoints to prevent double-selling.
api/seat-locks/[[...action]].js - Payments API · Payment intent, transaction, locator lookup, and follow-up actions.
api/payments/[locator]/[[...action]].js - Domain API · Venue, zone, map, audit, and event-domain endpoints.
api/recintos/[id]/delete.js - Email API · Send-email and provider webhook endpoints for transactional mail.
api/send-email/[[...provider]].js
Shared platform
Cross-cutting client-side data, auth, tenancy, and shared subsystems.
- Supabase client · Shared client configuration and service wrappers for multi-tenant data access.
src/config/supabase.jsx - Auth & tenant · Shared authentication, tenant switching, access control, and role enforcement.
src/contexts/AuthContext.jsx - Shared services · Client-side domain services for events, venues, users, audit, and payments.
src/services - Seat sync · Seat locks, cleanup, and live synchronization used by storefront and box office.
src/services/seatLocksService.jsx - Map engine · Custom seating-map editor, viewer, and worker-based layout computation.
src/components/SeatingMap.jsx - Payments · Cart, processors, transactions, retries, and gateway orchestration.
src/store/services/paymentGatewaysService.js - Fulfillment · Ticket PDF, Apple Wallet, email delivery, and downloads after payment.
api/download-ticket.js - Email system · Transactional and campaign email, templates, config, and webhook handling.
src/backoffice/services/emailService.jsx
Local tooling
Developer-side helper servers outside the main production path.
- Local helpers · Local sync and test harnesses for development workflows.
local-sync-server/server.js
Connections 24
- Storefront → Supabase client: reads/writes · Buyer UI uses shared Supabase access for public data and session state.
- Backoffice → Supabase client: reads/writes · Organizer UI uses shared Supabase access for tenant-scoped operations.
- SaaS admin → Supabase client: reads/writes · Platform admin UI uses shared data access for platform records.
- Admin SaaS → Supabase client: reads/writes · Admin console uses shared data access for management workflows.
- Storefront → Auth & tenant: protects · Public app is gated by auth, tenant context, and role-aware routes.
- Backoffice → Auth & tenant: protects · Backoffice uses guards and role-based access.
- SaaS admin → Auth & tenant: protects · SaaS surface uses admin authentication and guards.
- Admin SaaS → Auth & tenant: protects · Admin SaaS uses admin auth hooks and route guards.
- Storefront → Checkout flow: orchestrates · Storefront drives cart, seat selection, and payment screens.
- Backoffice → Ops tools: orchestrates · Backoffice coordinates CRUD, CRM, reports, printing, and support tools.
- Backoffice → Map engine: uses · Backoffice embeds the seating-map editor and viewer.
- Storefront → Map engine: uses · Buyer seat selection reuses the seating-map runtime.
- Storefront → Seat sync: locks seats · Seat selection relies on shared locking and live sync.
- Backoffice → Seat sync: locks seats · Box office and organizer tools share the same reservation boundary.
- Checkout flow → Payments: executes · Checkout hands off to payment processors and transaction tracking.
- Ops tools → Payments: executes · Backoffice can create, search, refund, or reconcile transactions.
- Payments → Payments API: calls · Client payment modules use the serverless payment endpoints.
- Seat sync → Seat locks API: calls · Seat locking is enforced through atomic API endpoints.
- Shared services → Domain API: calls · Shared domain services back event, venue, map, and audit operations.
- Fulfillment → Payments API: extends · Post-payment fulfillment is triggered from payment actions.
- Fulfillment → Email API: sends · Ticket delivery and follow-up mail use the email endpoints.
- Email system → Email API: calls · Backoffice email tooling uses the send-email and webhook APIs.
- Email system → Supabase client: reads/writes · Email config, templates, and campaign data are persisted in Supabase.
- Local helpers → Supabase client: syncs · Local helper servers support development-time data and map workflows.