# Dashboard Plan (Admin + User)

This file is the single dashboard planning and operations reference.

## 1) Dashboard objectives

1. Operate Dewemoji safely (subscriptions, webhooks, settings).
2. Manage Personal plan lifecycle and pricing.
3. Give Personal users fast keyword/API key management.

## 2) Current admin routes (implemented)

- `GET /dashboard/admin/analytics`
- `GET /dashboard/admin/users`
- `POST /dashboard/admin/users/tier`
- `GET /dashboard/admin/subscriptions`
- `POST /dashboard/admin/subscriptions/grant`
- `POST /dashboard/admin/subscriptions/revoke`
- `GET /dashboard/admin/pricing`
- `POST /dashboard/admin/pricing/update`
- `POST /dashboard/admin/pricing/reset`
- `GET /dashboard/admin/webhooks`
- `POST /dashboard/admin/webhooks/{id}/replay`
- `GET /dashboard/admin/settings`
- `POST /dashboard/admin/settings/update`

## 3) Admin module scope

### Analytics

- user/subscription/payment/webhook totals
- recent webhook and billing activity

### Users

- filter by tier/role/search
- controlled tier update operations

### Subscriptions and payments

- grant/revoke workflows
- provider/status visibility (`paypal`, `qris/pakasir`, `admin`)
- pending/paid/failed/expired status clarity

### Webhooks

- recent events list
- replay support
- idempotency-safe processing expectations

### Pricing

- edit plan values and provider toggles
- preserve change log snapshots for auditability

### Settings

- maintenance flag
- public access guard values (`public_enforce`, origins, extension IDs, hourly limit)

## 4) User dashboard scope

### User states

1. visitor: no dashboard
2. free logged-in: dashboard access with locked personalization areas
3. personal: full access

### User modules

- Overview (summary metrics)
- My Keywords (CRUD, filter, import/export)
- API Keys (create/revoke)
- Billing (current plan + payment history + resume pending)
- Preferences (theme/tone; optional expansion)

### UX priority

- quick-add keywords on emoji detail pages (primary)
- dashboard bulk management (secondary)

## 5) Billing integration expectations

Target data model coverage:

- `orders`
- `payments`
- `subscriptions`
- `webhook_events`

Required runtime behaviors:

1. webhook-confirmed status transitions
2. pending checkout cooldown enforcement
3. resume pending checkout from billing page
4. safe downgrade when no active subscription remains

## 6) Access and security

- Admin access is role-based session auth (`users.role = admin`).
- `X-Admin-Token` should remain internal/dev usage only.
- Log sensitive actions (tier changes, pricing updates, manual grants/revokes, webhook replays).

## 7) Implementation priorities

1. strengthen payments/subscriptions observability
2. finalize user dashboard CRUD ergonomics
3. enforce non-destructive confirmations for sensitive admin actions
4. add pagination/filter/sorting consistency across large admin lists
