Files
where_woof/openspec/changes/admin-insights-pages/design.md

40 lines
2.0 KiB
Markdown

## Context
Four quick wins (tuxedo board): dashboard insights, users→tags, customer pause, public pages. All small; no new external deps.
## Goals / Non-Goals
**Goals:**
- Dashboard shows customers + revenue (needs orders.amount).
- Admin sees each customer's tags; can pause a customer.
- Public About/What-is-this/Contact pages exist.
**Non-Goals:**
- Fancy contact form backend (mailto suffices until email infra exists).
- Revenue breakdowns by period/tag (later).
- Pause ≠ billing automation (still manual; renewals are a later slice).
## Decisions
1. **`users.paused`** (idempotent bool, default false): simplest customer-level kill switch. `shouldAlert` loads the owner (`GetUserByID` on `tag.OwnerID`) and returns false when paused; the contact path checks the same. Scan recording continues.
2. **`orders.amount NUMERIC(10,2) DEFAULT 0`** (idempotent): revenue = `SUM(amount) WHERE status='paid'` (Eloquent aggregate). OrderResource gains an amount input. Existing orders default 0 → revenue is accurate going forward.
3. **Public pages**: three templates extending `base.html` (about / what-is-this / contact), handlers mirroring `Home`, routes in main.go. Contact = contact details + `mailto:` (no email system yet).
4. **Admin**: StatsOverview adds Customers + Revenue stats; UserResource gains a `paused` Toggle + a `TagsRelationManager` (Filament v3 auto-discovers `UserResource/RelationManagers/*`).
## Risks / Trade-offs
- [Pause is all-or-nothing per customer] → matches the 2014 model; per-tag suspend already exists separately.
- [Revenue 0 for existing orders] → accepted; going forward the admin enters amounts.
- [Public pages minimal] → intentional; expand with the info-tag/multilingual work later.
## Migration Plan
1. `make db-up` (two ALTERs); sqlc regen.
2. Go: pause gate + 3 pages; build.
3. Admin: stats, relation manager, pause toggle, order amount.
4. Verify (new suite + regressions); deploy (frontend binary+templates; admin rebuild).
## Open Questions
- None blocking.