# Command Sovereignty — Completion Plan
**Last updated:** 2026-07-26
**Status:** Phase 2 complete, Phase 3 complete
---
## Phase 1: Data Integrity & API Verification ✅
- [x] **1.1** Seed estimate data — 28 estimates, $1.003M pipeline, 46.2% close rate
- [x] **1.2** API endpoint verification — `to_dict()` crash fixed, funnel analytics verified
- `GET /api/company/{id}/estimates` — 200 ✅
- `GET /api/company/{id}/estimates/funnel` — 200 ✅
- `GET /api/company/{id}/estimates/stats` — 200 ✅
- Stage transitions working via model ✅
- [x] **1.3** Frontend funnel dashboard — React SPA built and wired
- `frontend/src/api/estimates.ts` — Full API client with typed interfaces
- `frontend/src/pages/partner/EstimatesFunnelPage.tsx` — Funnel viz, stats, drop-off, source breakdown
- Route added: `/app/estimates` in `App.tsx`
- Sidebar nav: "Pipeline" section with Estimates entry
- Vite build: ✅ 793 modules, 273ms
### Bugs fixed (Phase 1)
| Bug | Fix |
|---|---|
| `to_dict()` crash on `stage_history` | `_parse_history()` defensive JSON parser added |
| `days_in_stage` crash (string - datetime) | `current_stage_timestamp` returns parsed datetime |
| Conversion rate >100% | Capped at 100% in funnel analytics |
---
## Phase 2: Connector Wiring
- [ ] **2.1** Jobber connector — test auth flow, pull real projects/estimates
- [ ] **2.2** Angi connector — lead import from Angi API
- [ ] **2.3** Five9 connector — call logging webhook
---
## Phase 3: React Funnel Dashboard
- [x] **3.1** Funnel visualization — stage counts + conversion rates chart
- [ ] **3.2** Estimate list table — sortable, filterable
- [ ] **3.3** Estimate detail view — stage history timeline
---
## Phase 4: Frontend Page Verification
- [ ] **4.1** All routes render with real data (no mock)
- [ ] **4.2** Auth flow (login → redirect)
- [ ] **4.3** Responsive layout on mobile
---
## Phase 5: Detector Validation
- [ ] **5.1** Revenue Leak detection engine — run against seeded data
- [ ] **5.2** Project margin leak detector — verify calculations
- [ ] **5.3** Scheduler heartbeat — leak reports fire on schedule
---
## Phase 6: Stripe Billing Integration
- [ ] **6.1** Stripe webhook endpoint
- [ ] **6.2** Subscription model (tier-based)
- [ ] **6.3** Trial → paid flow
---
## Phase 7: Infrastructure Hygiene
- [ ] **7.1** Git init + initial commit
- [ ] **7.2** Slack notification config (credentials)
- [ ] **7.3** API documentation
- [ ] **7.4** README update
---
## Technical Notes
**Database:** `instance/auth.db` (SQLite, WAL mode, FK enabled)
**Service:** `command-sovereignty.service` (systemd user, Gunicorn)
**Frontend:** React SPA (`frontend/src/`), Vite build
**Auth:** Session-based (Flask-Login), `SESSION_COOKIE_SECURE=true`
**Super Admin:** grepples15@gmail.com (user 3, pro plan)
**Companies:** Greenfield Landscaping (3), Metro Roofing (4), Premier HVAC (5)