# apps/admin — oO Admin Console Next.js 15 app. Deployed at `admin.o.alogins.net` (dev: `http://localhost:3080`). ## Contract - All routes are admin-only. The Next.js middleware calls `GET /api/user/me` on every request and checks `role === 'admin'`. First admin is seeded via `ADMIN_SEED_EMAIL` env var at API startup. - Admin write actions are appended to the `admin_actions` audit log in the DB. ## Authentication Two ways to sign in: | Method | How | |--------|-----| | Google OAuth | Click "Sign in with Google" on the login page | | Token | `POST /api/auth/token` with `{ token }` matching `ADMIN_TOKEN` env var; sets `sid` cookie valid for 24 h. Used by Playwright tests and CI automation. | ## Pages | Route | Description | |-------|-------------| | `/` | Overview: DAU/WAU KPI cards, tips served, reaction breakdown, activation funnel | | `/users` | User list (paginated, searchable) | | `/users/:id` | User detail: identity, consents, integrations, profile features (completion rate, dismiss rate, dwell, preferred hour, tip volume), tip stats, reward history; revoke-integration + reset-bandit + rebuild-profile actions | | `/audit` | Admin action audit log with timestamps and descriptions | | `/events` | Live event stream viewer with filters by subject/user/time; tail of `signals.*` from ring buffer or NATS JetStream | | `/features` | Feature store browser: features sent to `ml/serving` per scoring call; freshness status; per-feature SLA tracking | | `/tips` | Served tips explorer: tip content, score, policy, model, feedback reactions; per-user timeline | | `/reward-analytics` | Reaction distribution + per-policy / per-model / per-prompt-version breakdowns with avg reward; time-series and cohort slicing | | `/data-quality` | Missing-feature rate heatmap, stale-token rate, daily completeness, per-feature freshness SLA status | | `/health` | System health rollup: api, ml/serving, SQLite, event-bus, MLflow with 15s auto-refresh | | `/sql` | Read-only SQL runner against SQLite; saved queries support; sunsets to Superset in M4 | | `/simulate` | Offline simulation runner: launch `ml/experiments/sim`, track runs, judge selection, policy comparison | | `/docs` | Admin documentation and ops runbooks inline | | `/ops` | Operational dashboard (deprecation candidate; pending UX refinement #107) | ## Dev ```bash pnpm --filter @oo/admin dev # starts on :3080 # also run the API: pnpm --filter @oo/api dev (port 3078) ``` ## Extraction criteria Stays as a Next.js app in the monorepo permanently — it's not a candidate for extraction. It gets richer (more pages, embedded MLflow/Grafana) but not split. ## Known issues & pending improvements - `@tremor/react 3.x` declares a peer dep on React 18; the workspace uses React 19. Works in practice. Will resolve naturally when Tremor ships React 19 support or when we switch to Tremor v4 (which targets React 18+). - UX refinements pending (#100–102): feedback options consolidation, config page UI migration, settings UI placement