GolfLabs API powers a 24/7 self-service golf simulator facility in Cherryhill, New Jersey. This backend system manages the complete customer journey from booking to facility access, enabling fully automated operations without on-site staff.
Our API handles:
- Real-time Booking System - Instant reservations with conflict prevention
- Payment Processing - Stripe integration with automatic confirmations
- Smart Access Control - Time-limited door unlocking via Shelly switches
- Automated Notifications - Email reminders with unlock links
- Facility Management - Bay status monitoring and usage analytics
Rather than microservices, we chose a modular monolith architecture that provides the benefits of modular organization while maintaining operational simplicity for our scale.
Why Modular Monolith?
- Simplified Deployment - Single application deployment reduces DevOps complexity
- Shared Resources - Efficient use of database connections and memory
- Cross-Module Communication - Direct function calls instead of network overhead
- Easier Development - Single codebase with clear module boundaries
- Cost Effective - Lower infrastructure costs for our business size
src/
├── modules/                 # Business domain modules
│   ├── bookings/           # Reservation management
│   ├── payments/           # Stripe payment processing
│   ├── unlock/             # Door access control
│   ├── email/              # Notification system
│   ├── sockets/            # Real-time communication
│   ├── logs/               # Access and audit logging
│   ├── bays/               # Bay management
│   ├── locations/          # Facility locations
│   └── pricing/            # Dynamic pricing rules
├── jobs/                   # Background tasks
├── shared/                 # Common utilities
└── config/                 # Application configuration
Each module follows a consistent pattern:
- *.routes.ts- HTTP endpoint definitions
- *.controller.ts- Request/response handling
- *.service.ts- Business logic implementation
- *.types.ts- TypeScript interfaces
- Node.js - Runtime environment
- Express.js - Web application framework
- TypeScript - Type-safe JavaScript development
- Socket.io - Real-time bidirectional communication
- Supabase - PostgreSQL database with real-time features
- Custom Functions - Stored procedures for complex booking logic
- Row Level Security - Database-level access control
- Stripe - Payment processing and webhook handling
- Resend - Transactional email delivery
- Shelly API - IoT switch control for door unlocking
- Date-fns-tz - Timezone-aware date handling
- Background Jobs - Scheduled tasks for reminders and cleanup
- Webhook Processing - Stripe and email event handling
- Health Monitoring - System status endpoints
- CORS Support - Cross-origin resource sharing
- Time-limited unlock tokens in booking reminder emails
- Direct Shelly switch integration for door control
- Automatic expiration when sessions end
- Comprehensive access logging
- Stripe Payment Intents for secure transactions
- Webhook-driven booking confirmations
- Automatic refund processing for cancellations
- 24-hour cancellation policy enforcement
- Booking confirmation emails with details
- 15-minute reminder emails with unlock links
- Light/dark mode email templates
- Failed delivery tracking and retry logic
- Socket.io for instant kiosk communication
- Bay status monitoring and updates
- Conflict prevention for overlapping bookings
- Dynamic pricing based on time slots
- Access attempt tracking
- Performance monitoring
- Security audit trails
- Business intelligence data collection
Automated tasks handle critical business operations:
- Reminder Job - Sends 15-minute booking reminders with unlock tokens
- Expired Reservations - Cleans up unpaid bookings automatically
- Notifications - Handles failed email delivery attempts
- Scheduler - Manages job execution timing
- bookings- Reservation records with status tracking
- payments- Stripe payment intent management
- access_logs- Security and usage audit trail
- bays- Facility bay configuration and status
- pricing_rules- Time-based pricing configuration
- Timezone Support - Location-specific time handling
- Conflict Prevention - Database constraints prevent double-booking
- Audit Trails - Complete booking lifecycle tracking
- Performance Optimization - Indexed queries for fast responses
# Install dependencies
npm install
# Start development server with hot reload
npm run dev
# Build for production
npm run build
# Start production server
npm startRequired environment variables:
SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_ROLE_KEY=your_service_key
STRIPE_SECRET_KEY=your_stripe_secret
STRIPE_WEBHOOK_SECRET=your_webhook_secret
RESEND_API_KEY=your_resend_key
PORT=4242- POST /bookings/reserve- Create booking reservation
- POST /bookings/:id/create-payment-intent- Initialize payment
- GET /users/:id/bookings/*- User booking history
- POST /unlock- Process door unlock requests
- GET /bays- Bay availability and status
- GET /locations- Facility information
- POST /calculate-price- Dynamic pricing calculation
- GET /pricing-rules- Current pricing configuration
- POST /stripe-webhook- Payment event processing
- ✅ Booking system with payment processing
- ✅ Automated email notifications
- ✅ Smart door unlock functionality
- ✅ Real-time kiosk communication
- ✅ Comprehensive audit logging
- 🚧 Advanced analytics dashboard (planned)
- 📋 Multi-location support (future)
The modular monolith approach provides:
- Developer Productivity - Single repository with clear boundaries
- Operational Simplicity - One application to deploy and monitor
- Performance - No network latency between modules
- Consistency - Shared database transactions across modules
- Scalability - Easy to extract modules to microservices later
GolfLabs API - Powering automated golf simulation experiences