feat(phase-4): SMS gateway dashboard + stats + health + retry

Backend (backend/app/routers/sms.py):
- GET /api/sms/stats: aggregate totals by status, daily volume chart
  (configurable N days), per-school top-10 breakdown, delivery rate,
  live queue depth
- POST /api/sms/jobs/{id}/retry: reset failed/cancelled job to pending
- GET /api/sms/health: Semaphore API connectivity check + credit balance
- POST /api/sms/trigger-queue: manually fire sms.process_queue Celery task

Frontend (frontend/src/pages/SmsPage.vue) — rebuilt from scratch:
- Semaphore health badge with live status indicator and balance display
- 'Process Queue' button calling POST /api/sms/trigger-queue
- KPI row: Total, Sent, Failed, Pending (queue depth), Delivery Rate %;
  period picker switching between 7/30/90 day views
- Volume bar chart: daily sent vs failed bars with hover tooltips,
  x-axis date labels, legend; no charting library required
- School breakdown panel: top 10 schools by volume with delivery
  percentage bars
- Jobs table: status + school + phone number filters; inline error
  message on failed rows; Retry button for failed/cancelled jobs;
  retry count display; pagination

api.ts: getSmsStats, retrySmsJob, getSmsHealth, triggerSmsQueue

PAUL: Phase 4 marked complete, STATE + ROADMAP updated
This commit is contained in:
kevin-asprec
2026-03-16 10:37:23 +08:00
parent a5430736d9
commit 5cab1938b1
6 changed files with 512 additions and 38 deletions

View File

@@ -19,8 +19,8 @@ SMS flow: On-prem TapTrack polls Hub every 30s → Hub queues SMS jobs → Hub s
## Current Milestone
**v1.0 — Foundation & Core Services**
Status: Phase 3 complete — Phase 4 next
Phases: 3 of 15 complete
Status: Phase 4 complete — Phase 5 next
Phases: 4 of 15 complete
---
@@ -31,7 +31,7 @@ Phases: 3 of 15 complete
| 1 | Project Setup & Infrastructure | 1 | ✅ Complete | 2026-03-15 |
| 2 | School Registry + License Mgmt | 2 | ✅ Complete | 2026-03-15 |
| 3 | On-Prem License Validation | 1 | ✅ Complete | 2026-03-15 |
| 4 | SMS Gateway (credits + queue) | TBD | Not started | |
| 4 | SMS Gateway (credits + queue) | 2 | ✅ Complete | 2026-03-15 |
| 5 | On-Prem SMS Polling Agent | TBD | Not started | — |
| 6 | Super Admin Dashboard UI | TBD | Not started | — |
| 7 | School Admin Portal UI | TBD | Not started | — |

View File

@@ -3,10 +3,10 @@
## Current Position
Milestone: v1.0 — Foundation & Core Services
Phase: 3 of 15 (On-Prem License Validation — complete)
Plan: Phase 3 complete — Phase 4 next
Status: **Phase 3 applied — ready to begin Phase 4**
Last activity: 2026-03-15 — Phase 3 complete (TapTrack on-prem: license validation task, startup check, hub router, frontend warning banner)
Phase: 4 of 15 (SMS Gateway — complete)
Plan: Phase 4 complete — Phase 5 next
Status: **Phase 4 applied — ready to begin Phase 5**
Last activity: 2026-03-15 — Phase 4 complete (SMS stats/health/retry/trigger endpoints + full SmsPage dashboard with chart, KPIs, school breakdown)
## Loop Position
@@ -22,7 +22,7 @@ PLAN ──▶ APPLY ──▶ UNIFY
- Phase 1 (Project Setup & Infrastructure): [██████████] 100% ✓
- Phase 2 (School Registry + License Mgmt): [██████████] 100% ✓
- Phase 3 (On-Prem License Validation): [██████████] 100% ✓
- Phase 4 (SMS Gateway): [░░░░░░░░░░] 0%
- Phase 4 (SMS Gateway): [██████████] 100% ✓
- Phase 5 (On-Prem SMS Polling Agent): [░░░░░░░░░░] 0%
- Phase 6 (Super Admin Dashboard UI): [░░░░░░░░░░] 0%
- Phase 7 (School Admin Portal UI): [░░░░░░░░░░] 0%
@@ -37,8 +37,8 @@ PLAN ──▶ APPLY ──▶ UNIFY
## Next Action
Run: `/paul:plan` for Phase 4SMS Gateway (credits + queue)
Resume file: .paul/ROADMAP.md → Phase 4
Run: `/paul:plan` for Phase 5On-Prem SMS Polling Agent
Resume file: .paul/ROADMAP.md → Phase 5
## Repo

View File

@@ -1,9 +1,25 @@
# Phase 04: SMS Gateway (Credits + Queue)
**Status:** Not started
**Status:** ✅ Complete — 2026-03-15
## Goal
Schools submit SMS jobs via Hub; Hub sends via Semaphore; credits deducted per message.
Full SMS dashboard for super admin with stats, charts, job table, Semaphore health.
## Plans
- [ ] TBD — run /paul:plan when Phase 3 is complete
## Completed
### 4-01: Backend stats + retry + health + trigger
- `GET /api/sms/stats` — aggregate totals, daily chart (N days), school breakdown
- `POST /api/sms/jobs/{id}/retry` — reset failed/cancelled job to pending
- `GET /api/sms/health` — Semaphore connectivity + credit balance
- `POST /api/sms/trigger-queue` — manual Celery task trigger (admin)
- `api.ts`: getSmsStats, retrySmsJob, getSmsHealth, triggerSmsQueue
### 4-02: SmsPage full dashboard
- Semaphore health badge (green/red, shows balance)
- Process Queue button (fires trigger-queue)
- KPI row: Total, Sent, Failed, Pending, Delivery Rate %, period picker 7/30/90d
- Volume bar chart (daily sent vs failed, hover tooltips)
- School breakdown panel (top 10, sent/total ratio bars)
- Jobs table: status + school + phone filters, error message on failed rows,
Retry button, retry count, pagination