Last updated: 2026-07-12
Stack
| Layer | Technology |
|---|---|
| Frontend | React 18 + TypeScript (Vite 5) — served by Cloudflare Pages |
| Backend API | Cloudflare Worker (TypeScript) |
| Database | Cloudflare D1 (SQLite) — caretaker_db |
| Auth | PBKDF2-SHA256 password hash in D1, HMAC-signed JWT tokens |
| Not yet wired — planned via Resend |
Repo & Local Path
| Item | Value |
|---|---|
| GitHub | github.com/sonantechai/caretaker-portal |
| Local root | E:\Claude_Projects\sonan-trackers\caretaker-portal-Claude\caretaker-portal\ |
| Wrangler env | castlecheckers |
Migrations
| File | What It Does |
|---|---|
| 0001_init.sql | Full schema — admin_users, clients, service_requests, appointments, invoices, invoice_items, notes, settings, properties |
| 0002_settings_seed.sql | Castle Checkers seed data — business config, service types, default checklist, and PBKDF2 admin password hash |
| 0003_flight_fields.sql | Adds extended flight columns to appointments: dep_flight, dep_airline, dep_date, dep_time, client_dep_pickup, arr_flight, arr_airline, arr_date, arr_time, client_arr_pickup, title |
| 0004_phone_index.sql | Adds an index on clients.phone for faster lookups |
| 0005_call_back_service.sql | Adds "Call Back" as a built-in service type option |
| 0006_blocked_days.sql | Creates blocked_days table (id, date, reason) for marking dates the admin is unavailable |
Database Schema
| Table | Purpose | Key Columns |
|---|---|---|
| admin_users | Admin login | id, name, email, password_hash (PBKDF2) |
| clients | Client records | id, full_name, email, phone, address, emergency_contact_name, emergency_contact_phone, status |
| service_requests | Public form submissions | id, full_name, email, phone, service_types (JSON), travel_details (JSON), home_care_details (JSON), internal_notes (JSON), status |
| appointments | Scheduled visits | id, client_id, type, appointment_date, start_time, notes, status, dep_flight, dep_airline, dep_date, dep_time, arr_flight, arr_airline, arr_date, arr_time, client_dep_pickup, client_arr_pickup, title |
| invoices | Billing | id, invoice_number, client_id, subtotal, tax, discount, total, status (Draft/Sent/Paid), issue_date |
| invoice_items | Line items | id, invoice_id, description, quantity, rate, amount |
| blocked_days | Admin unavailability | id, date (YYYY-MM-DD), reason |
| settings | Business config | key, value — business_name, service_types, task_checklist, invoice_footer, primary_color, etc. |
| notes | Entity notes | id, entity_type, entity_id, note |
| properties | Per-client properties | id, client_id, address, access_instructions |
Key API Routes
| Method | Route | Auth | Purpose |
|---|---|---|---|
| GET | /api/config | None | Public — returns settings JSON for public site |
| POST | /api/requests | None | Public — submit service request from wizard |
| POST | /api/auth/login | None | Admin login — returns HMAC-signed JWT |
| GET/POST/PUT/DELETE | /api/clients/* | JWT | Client CRUD |
| GET/POST/PUT/DELETE | /api/requests/* | JWT | Service request management + delete |
| GET/POST/PUT/DELETE | /api/appointments/* | JWT | Appointment CRUD (full flight field support) |
| GET/POST/PUT | /api/ |