# DAWLA Group CRM — Leads to Treatment for a Medical-Tourism Company

> **Status:** Built for and used by DAWLA Group, an Istanbul medical-tourism and travel company; screenshots show a demo copy with invented people  
> **Repository:** Private  
> **Tech Stack:** Python, FastAPI, SQLAlchemy, SQLite / PostgreSQL, vanilla JavaScript, WebSockets, Twilio Voice & SMS, WhatsApp Business Cloud API, Meta Lead Ads, SMTP, TOTP 2FA, Caddy, systemd

---

## 1. Overview
A CRM built for **DAWLA Group**, a company that brings patients to Istanbul for dental work, hair transplants and cosmetic surgery, and books their hotel, airport transfer and tours around the treatment. Every enquiry, whether a WhatsApp message, a website form, a Meta ad or a phone call, lands in one place, moves through a pipeline from first contact to finished treatment, and carries the medical case, the travel bookings and the payments with it.

## 2. The Problem
- Enquiries arrived on WhatsApp, Instagram, Facebook ads, the website and the phone, and lived in personal phones and spreadsheets: leads were lost between agents.
- A medical-tourism sale is long: offer, deposit, appointment, arrival, treatment, then tours. Nobody could see where each patient stood.
- Every patient also needs a hotel, a driver and a clinic slot, tracked separately from the sale.

## 3. How It Works
- **One inbox:** WhatsApp (Business Cloud API), SMS, website forms and Meta lead ads arrive as leads automatically; agents reply from the CRM.
- **Calls from the browser:** outbound calls through Twilio Voice, recorded and attached to the lead with their duration.
- **Pipeline built for the business:** 14 stages from New Lead through Offer Sent, Deposit Paid, Appointment Booked and Arrival Confirmed to Treatment Completed and Tour Completed, as a list or a board.
- **Medical case and travel per lead:** treatment type, clinic, doctor, plan and quotation; bookings for hotel, airport transfer, VIP car, tours and yachts with supplier, driver and voucher; deposits, instalments and refunds.
- **Team work:** tasks with due dates and overdue alerts, a calendar, a live team chat (WebSockets), custom lead fields and file uploads.
- **Reports:** revenue, conversion, lead sources, stage distribution and medical vs tourism, with CSV export.

## 4. Design Choices
- **Locked down:** argon2 passwords, cookie sessions, optional TOTP two-factor with QR setup, admin and agent roles, an audit log of who changed what, and rate limits on sign-in.
- **Webhooks are verified:** WhatsApp and Twilio callbacks are checked against their signatures before anything is stored; the open CORS policy left from an early setup was removed rather than patched.
- **Moved off the office PC:** it first ran on an office computer behind a tunnel; the deploy plan moves it to a small Linux server with Caddy (automatic HTTPS), systemd and a nightly verified backup, so no lead or call recording is lost in the move.
