Developing Service Booking Platform
Service booking platform connects service providers (specialists, craftsmen, landlords) with customers through online booking system. Key components: schedule management, time slots, prepayment and cancellations, notifications.
Schedule Model
Provider's schedule determines available slots for booking:
-- Regular working schedule
CREATE TABLE schedules (
provider_id, day_of_week INT (0-6),
start_time TIME, end_time TIME
);
-- Exceptions (days off, vacation)
CREATE TABLE schedule_exceptions (
provider_id, exception_date DATE,
is_available BOOLEAN, -- false = unavailable
custom_start TIME, custom_end TIME -- different schedule this day
);
-- Booked slots
CREATE TABLE bookings (
id, provider_id, client_id, service_id,
start_at TIMESTAMPTZ, end_at TIMESTAMPTZ,
status ENUM('pending', 'confirmed', 'cancelled', 'completed')
);
Algorithm for generating available slots: take working hours of the day → subtract already booked → subtract buffer time between sessions → return free intervals.
Preventing Double Booking
Race condition: two clients simultaneously book one slot. Solution via PostgreSQL advisory lock:
SELECT pg_advisory_xact_lock(provider_id, unix_timestamp_of_slot);
-- check availability
-- create booking
-- lock automatically released at transaction end
Or via INSERT ... ON CONFLICT DO NOTHING with unique index on (provider_id, start_at).
Managing Provider Services
Each provider configures their services:
- Name and description
- Duration (30 min, 1 hour, 1.5 hours)
- Price
- Buffer after session (time to prepare for next)
- Client requirements (fill form, attach documents)
Cancellation and Refund Policy
Standard policies:
- Flexible: cancellation 24 hours before — full refund
- Moderate: 5 days before — full, 24 hours — 50%
- Strict: 14 days before — 50%, later — no refund
Provider chooses policy. On client cancellation — automatic refund amount calculation via Stripe Refund.
Reminders
Automatic notifications:
- Booking confirmation (immediately)
- Reminder 24 hours before
- Reminder 1 hour before
- Request for review 2 hours after visit
Channels: email + SMS (via Twilio / SMS.ru) + push.
Google Calendar / Outlook Integration
Provider can sync their schedule with Google Calendar:
- OAuth2 authorization
- Blocking events from Calendar → unavailable slots on platform
- New bookings → create events in Calendar
Google Calendar API via googleapis SDK.
Timeline
MVP (provider profile, schedule, booking, payment, notifications): 2–3 months. With multiple providers, marketplace features, analytics and mobile app: 4–6 months.







