Phase 8 — Admin Console (`apps/admin`)
Goal: every staff screen in the build inventory (37–55). Each task builds both the admin API routes in apps/dashboard-api’s admin route group and the screens in apps/admin, because most admin actions have no backend yet.
Done when: every admin screen works against staging behind Cloudflare Access, every write requires its reason and is audit-logged, and Support is read-only except its listed actions.
Rules for every task here:
- Admin routes use the staff middleware from P5.11: staff flag, two-factor, Admin or Support role.
- Money and access changes require a reason and write an audit event (P4.07).
apps/adminis its own Pages project and never shares a bundle with the dashboard.
| ID | Task | Who | Needs | Status |
|---|---|---|---|---|
| P8.01 | Admin shell, staging Access, staff management (50) | You + agent | P5.11, P7.01 | merged — UI through the integration branch, code #65 (#30 closed), API code #34; staging Access done 2026-11-02 (application on admin-staging.router.africa and *.router-africa-admin.pages.dev, staff allow-list, Cloudflare login) |
| P8.02 | Overview, orgs, users, workspaces (37–40) | Agent | P8.01, P5.12 | merged — UI through the integration branch, code #65 (#30 closed), API code #34 |
| P8.03 | Keys and gateway sync (41, 48) | Agent | P8.01, P4.06 | merged — UI through the integration branch, code #65 (#30 closed), API code #34, code #35 |
| P8.04 | Pricing configuration (42–45, 51, 52) | Agent | P8.01, P4.03 | merged — UI through the integration branch, code #65 (#30 closed), API code #35 |
| P8.05 | Money: transactions, margin, unbilled usage (46, 47, 53) | Agent | P8.01, P6.07, P4.05 | merged — UI through the integration branch, code #65 (#30 closed), API code #35; release a stuck hold (Unbilled usage page) code #102 |
| P8.06 | Audit log and scheduled jobs (49, 54) | Agent | P8.01, P4.02 | merged — UI through the integration branch, code #65 (#30 closed), API code #34 |
| P8.07 | Edge rate limits (55) | You + agent | P8.01 | merged — UI through the integration branch, code #65 (#30 closed), API code #35. Operator part deferred (2026-11-02): the Cloudflare rules and the API token. Until then screen 55 uses the in-memory stand-in. The setup steps (plan rule limits, ra-edge:* rule names, token scope, secret names CLOUDFLARE_EDGE_LIMITS_TOKEN and CLOUDFLARE_ZONE_ID) are in the 2026-11-02 session notes in the status doc |
P8.01 — Admin shell, staging Access, staff management (50)
Section titled “P8.01 — Admin shell, staging Access, staff management (50)”Who: You + agent · Needs: P5.11, P7.01
- Agent:
- the admin app shell, on the same
ui-webcomponents - the staff sign-in, with two-factor required
- screen 50: the staff list and admin roles
- the admin app shell, on the same
- You: put
admin-staging.router.africabehind Cloudflare Access now, with the same allow-list policy as production (decisions log, Admin origin access), so admin is never reachable openly, even in staging. - Spec:
../product/build-inventory.mdscreen 50, Staff access, Admin origin; decisions log, Admin hosting - Done when: the staging admin requires Access and then staff sign-in, and a non-staff user is refused after Access.
P8.02 — Overview, orgs, users, workspaces (37–40)
Section titled “P8.02 — Overview, orgs, users, workspaces (37–40)”Who: Agent · Needs: P8.01, P5.12
- Overview (37): sign-ups, active workspaces, requests, spend and margin today, failed top-ups, gateway sync errors.
- Orgs (38): search; set rate limits and the hold toggle (synced to the gateway); set the in-flight cap, “Requests at once” (code #107); suspend and reactivate with a reason (decisions log, Org suspension).
- Users (39): search; suspend, force logout, resend verification, and view as customer (starts P5.12).
- Workspace detail (40): balance, ledger and keys; freeze; manual balance adjustment with a required reason; Move credits to another workspace (uses P6.06; shows the rate before confirming). Adjust and move take at most 8 decimals, and each dialog sends an
operationId, so a double click or retry applies once (code #117). - Spec:
../product/build-inventory.mdscreens 37–40; decisions log, Per-organization hold toggle, Rate limiting / abuse prevention - Done when: an org’s rate-limit change reaches every key’s virtual key (checked by key reconciliation), suspending an org refuses its keys on the next request and reactivating restores them, and an adjustment writes a ledger entry with the reason.
P8.03 — Keys and gateway sync (41, 48)
Section titled “P8.03 — Keys and gateway sync (41, 48)”Who: Agent · Needs: P8.01, P4.06
- Keys (41): search by name or pasted key (hashed for the lookup); revoke; show the rate limit each key inherits.
- Gateway sync (48): the discrepancy view, with retry, clean up and dismiss.
- Spec:
../product/build-inventory.mdscreens 41 and 48;../architecture/db-schema.mdgateway_discrepancies - Done when: a pasted full key finds its row without the key being stored or logged, and each discrepancy action resolves its row.
P8.04 — Pricing configuration (42–45, 51, 52)
Section titled “P8.04 — Pricing configuration (42–45, 51, 52)”Who: Agent · Needs: P8.01, P4.03
- Rates (42): today’s published rates, refresh status, recompute, history.
- Markup rules (43): list and edit, flat or percentage, by scope, including the FX markup (percentage, global or per currency).
- FX and currencies (44): rates, manual override, enable or disable a currency; minimum hold and rate significant figures.
- Model catalog (45): enable or disable, onboarding defaults, deprecated flag, the hold parameters (
max_tokensceiling and default, input allowance). - Top-up fees (51): per vendor and currency.
- Workspace discounts (52): reason required.
- Spec:
../product/build-inventory.mdscreens 42–45, 51, 52;../product/pricing-model.md - Done when: a markup change followed by a recompute publishes a new rate in staging, and enabling a model with no rate is refused.
P8.05 — Money: transactions, margin, unbilled usage (46, 47, 53)
Section titled “P8.05 — Money: transactions, margin, unbilled usage (46, 47, 53)”Who: Agent · Needs: P8.01, P6.07, P4.05
- Transactions and top-ups (46): search; pending and failed top-ups; reconcile against Niobi.
- Margin report (47): gateway cost against the charge, by model, currency and day; top-up fees shown separately.
- Unbilled usage (53): charge (a settle with
source = 'recon') or release, with a reason. - Spec:
../product/build-inventory.mdscreens 46, 47, 53;../architecture/db-schema.mdusage_discrepancies - Done when: charging an unbilled row writes a settlement and closes any open hold in one transaction.
P8.06 — Audit log and scheduled jobs (49, 54)
Section titled “P8.06 — Audit log and scheduled jobs (49, 54)”Who: Agent · Needs: P8.01, P4.02
- Audit log (49): filter by org, user, action and date.
- Scheduled jobs (54): status, history, edit schedule and config, enable or disable with a reason, run now.
- Permissions: Admin edits; Support reads.
- Spec:
../product/build-inventory.mdscreens 49 and 54; decisions log, Scheduled jobs admin page - Done when: “run now” can’t overlap a scheduled run, and each edit is audited.
P8.07 — Edge rate limits (55)
Section titled “P8.07 — Edge rate limits (55)”Who: You + agent · Needs: P8.01
- You: create the Cloudflare rate-limiting rules (
api.and the auth paths ofapp., for staging and production). Check the plan’s rule limits. Create the API token limited to editing this zone’s rate-limiting rules. - Agent: screen 55 reads and updates those rules through the Cloudflare API from
dashboard-api. A reason is required, the change is audit-logged asrate_limit.changed, Admin edits and Support reads. - Spec: decisions log, Edge rate limiting;
../product/build-inventory.mdscreen 55 - Done when: a change made in the admin app shows in Cloudflare, and a burst from one IP in staging is blocked at the edge.