Overview
The service layer (backend/internal/service/) implements the business logic of the application. Services orchestrate operations across multiple repositories, enforce business rules, and handle complex workflows.
Service Organization
Each service is organized in its own package:Core Services
Booking Service
Handles all booking-related operations including creation, cancellation, and recurring bookings.Key Booking Operations
Key Booking Operations
Creating a BookingThe booking creation process involves multiple steps:
Recurring Bookings
Recurring Bookings
The system supports recurring bookings using RRULE (RFC 5545):
Merchant Service
Manages merchant operations, dashboard statistics, and business settings.Dashboard Statistics
Dashboard Statistics
The dashboard provides key metrics:
- Revenue - Total revenue for the period with change percentage
- Bookings - Number of bookings with trend
- Cancellations - Cancellation count and rate
- Average Duration - Average booking duration
Customer Service
Handles customer CRUD operations, blacklisting, and booking transfers.Customer Blacklisting
Customer Blacklisting
Merchants can blacklist problematic customers:Blacklisted customers cannot make new bookings but existing bookings are preserved.
Booking Transfers
Booking Transfers
Transfer bookings from dummy customers to registered users:
Catalog Service
Manages services, service categories, and service phases.Auth Service
Handles authentication, user registration, and OAuth flows.OAuth Integration
OAuth Integration
Supports Google and Facebook OAuth:
auth/oauth.go
Service Patterns
Context-Based Authentication
Services extract authentication data from context:Transaction Coordination
Complex operations use transactions:Input Validation
Services define input structs for type-safe parameters:Error Handling
Services wrap errors with context:Email Service
Handles transactional emails using Resend:External Calendar Service
Syncs with Google Calendar to block unavailable times:Next Steps
Domain Models
Review the domain entities used by services
Repositories
See how services interact with data layer