System Overview
Reservations is built as a monolithic application that compiles into a single binary. The architecture combines a Go backend with two embedded React frontends, all served through a unified HTTP server.Tech Stack
Backend Technologies
Go 1.21+
HTTP Server & Business Logic
- Chi router for HTTP routing
- Standard library HTTP server
- Context-based request handling
- Clean architecture patterns
PostgreSQL + PostGIS
Data Persistence
- PostgreSQL 14+ for relational data
- PostGIS extension for geospatial features
- pgx/v5 driver for performance
- Connection pooling with pgxpool
JWT Authentication
Security & Auth
- Access tokens (15 min expiry)
- Refresh tokens (7 day expiry)
- Token versioning for revocation
- OAuth2 integration
Resend
Email Delivery
- Transactional emails
- Scheduled email reminders
- HTML templates with i18n
- Email cancellation support
Frontend Technologies
React 19
UI Framework
- Functional components with hooks
- React Router for navigation
- TanStack Query for data fetching
- React Compiler for optimization
Vite
Build Tool
- Fast HMR in development
- Optimized production builds
- Code splitting
- Asset optimization
Tailwind CSS 4
Styling
- Utility-first CSS
- JIT compilation
- Custom design system
- Responsive design
FullCalendar
Scheduling UI
- Interactive calendar views
- Drag-and-drop booking
- Multiple view modes
- Event management
Application Structure
Backend Architecture
The backend follows clean architecture principles with clear separation of concerns:Key Components
- Router
- Application Bootstrap
- Services Layer
- Repositories
The router handles request routing and serves both API and frontend apps.From The router uses the
backend/internal/api/router.go:45-113:NotFound handler to serve frontend apps, allowing the Go server to handle both API and SPA routing.Frontend Architecture
Frontend Features
Jabulani (Merchant App)
Key Features:
- Full calendar view with FullCalendar
- Drag-and-drop booking management
- Service catalog CRUD
- Customer management with blacklist
- Team member management
- Business hours configuration
- External calendar integration
- Analytics dashboard with Recharts
Tango (Customer App)
Key Features:
- Merchant discovery
- Service browsing
- Self-service booking flow
- Booking cancellation
- Account management
- Multi-language support
- Responsive mobile design
Data Flow
Booking Creation Flow
Here’s how a customer booking flows through the system:Customer selects service and time
Customer browses merchant’s services in Tango app and selects a time slot.
JWT middleware authenticates request
The middleware validates the JWT token and extracts user information.From
backend/internal/api/middleware/jwt/jwt.go:Handler validates and delegates to service
The booking handler validates input and calls the service layer.
Service validates business rules
The booking service checks:
- Merchant exists and is active
- Service is available
- Time slot is valid (within booking window)
- Customer is not blacklisted
- No scheduling conflicts
Authentication & Authorization
JWT Token Flow
Role-Based Access Control
The system implements RBAC with three merchant roles:- Owner
- Admin
- Staff
Full access to all merchant features:
- Delete merchant account
- Update merchant name
- Manage team members and roles
- All staff and admin permissions
backend/internal/api/middleware/rbac.go:
OAuth Integration
Support for Google and Facebook OAuth:Database Schema
Core Entities
The database schema supports multi-tenancy and complex booking relationships:- Merchants & Users
- Services & Catalog
- Bookings
- Recurring Bookings
- Locations & Calendar
Email System
The email system uses Resend for delivery and supports:Immediate Emails
Sent immediately after events:
- Booking confirmation
- Booking cancellation
- Booking modification
- Password reset
- Email verification
Scheduled Emails
Scheduled for future delivery:
- Booking reminders (24h before)
- Cancellable via email ID
- Reschedulable when booking changes
Email Templates
Templates use Go’shtml/template with i18n support:
Deployment
Single Binary Deployment
The application compiles into a single, self-contained binary:- No separate frontend deployment
- Single container/process
- Simplified CI/CD
- Atomic deployments
Environment Configuration
All configuration via environment variables:Production Build
backend/bin/reservations(Linux/macOS)backend/bin/reservations.exe(Windows)
- Jabulani frontend
- Tango frontend
- Email templates
Performance Considerations
Database Optimization
- Connection pooling with pgxpool
- Prepared statements
- Efficient queries with joins
- Indexes on foreign keys
- PostGIS for geospatial queries
API Performance
- Chi router (low overhead)
- Context-based request handling
- Streaming responses where applicable
- Gzip compression
- Static asset caching
Frontend Optimization
- Code splitting with Vite
- React Compiler for optimizations
- TanStack Query caching
- Lazy loading routes
- Optimized images and assets
Scalability
- Stateless API (horizontal scaling)
- Database connection pooling
- Transaction isolation
- Efficient email queuing
- Timezone-aware scheduling
Next Steps
API Reference
Explore the REST API endpoints and request/response formats
Deployment Guide
Learn how to deploy the application to production