Multi-tenant Django REST API for appointment bookings featuring M-Pesa STK push payments, real-time polling, automated SMS/WhatsApp alerts via Africa's Talking & Twilio, and Google Calendar sync.
# Appointment Booking Backend API
A multi-tenant Django REST Framework API for managing service bookings, staff availability, M-Pesa payment automation, notification alerts, and Google Calendar synchronization.
## Key Features
* **Multi-Tenant Architecture:** Isolated business accounts, staff schedules, customer profiles, and service offerings.
* **M-Pesa STK Push Integration:** Automated mobile payment prompts and callback processing via Safaricom Daraja API.
* **Payment Polling Endpoint:** Endpoint allowing frontends to query real-time M-Pesa transaction status (`/api/payments/status/ /`).
* **Automated Notifications:** SMS and WhatsApp alerts sent to customers upon booking creation via Africa's Talking and Twilio.
* **Google Calendar Sync:** Automated event creation on Google Calendar when appointments are confirmed.
* **Double-Booking & Cross-Tenant Prevention:** Validation logic ensuring zero slot overlaps across staff schedules and business boundaries.
* **Production Ready:** Configured for Render deployment using PostgreSQL, Gunicorn, WhiteNoise, and CORS handling.
## Tech Stack
* **Framework:** Python 3.12, Django 6.1, Django REST Framework
* **Database:** PostgreSQL (Production / Render), SQLite (Local Dev)
* **Authentication:** SimpleJWT (JSON Web Tokens)
* **Third-Party Integrations:** Safaricom Daraja API, Africa's Talking, Twilio API, Google Calendar API
* **Deployment & Web Server:** Render, Gunicorn, WhiteNoise
## Project Structure
```text
appointment_booking_backend/
│── config/ # Django project settings & URL routing
│── core/ # Main application app (Models, Views, Signals, Services)
│ ├── models.py # Business, Staff, Service, Customer, Appointment, Payment models
│ ├── views.py # ViewSets & M-Pesa payment views
│ ├── signals.py # Post-save listeners for notifications & calendar sync
│ ├── services.py # External API integrations (M-Pesa, SMS, WhatsApp, Google Calendar …