|
| 1 | +# NEWM Admin Desktop Application |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +NEWM Admin is a desktop application for internal administrators to manage the NEWM platform. Built with Rust and GPUI (GPU-accelerated UI framework from Zed), it provides a performant, native interface for admin operations. |
| 6 | + |
| 7 | +**Tech Stack:** |
| 8 | +- **Language:** Rust (2024 edition) |
| 9 | +- **UI Framework:** GPUI + gpui-component |
| 10 | +- **HTTP Client:** reqwest with async-compat bridge |
| 11 | +- **Target Platform:** Desktop (Linux, macOS, Windows) |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## Current Features |
| 16 | + |
| 17 | +### ✅ Authentication |
| 18 | + |
| 19 | +**Status:** Completed (2026-01-07) |
| 20 | + |
| 21 | +| Feature | Description | |
| 22 | +|---------|-------------| |
| 23 | +| Admin Login | Email/password authentication against Garage/Studio APIs | |
| 24 | +| Environment Selection | Toggle between Garage (dev) and Studio (prod) environments | |
| 25 | +| JWT Validation | Verifies `admin: true` claim in JWT before allowing access | |
| 26 | +| Password Visibility Toggle | Eye icon to show/hide password input | |
| 27 | + |
| 28 | +**Files:** |
| 29 | +- [auth.rs](file:///home/westbam/Development/newm-server/newm-admin/src/auth.rs) — HTTP authentication client |
| 30 | +- [jwt.rs](file:///home/westbam/Development/newm-server/newm-admin/src/jwt.rs) — JWT claims parsing |
| 31 | +- [login.rs](file:///home/westbam/Development/newm-server/newm-admin/src/views/login.rs) — Login view UI |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +### ✅ Admin Dashboard |
| 36 | + |
| 37 | +**Status:** Completed (2026-01-07) |
| 38 | + |
| 39 | +| Feature | Description | |
| 40 | +|---------|-------------| |
| 41 | +| Sidebar Navigation | 200px fixed sidebar with menu items | |
| 42 | +| View State Management | Event-driven switching from Login → Dashboard via `LoginSuccessEvent` | |
| 43 | +| Menu Items | Earnings (`IconName::ChartPie`), Refunds (`IconName::Undo`) | |
| 44 | +| Dynamic Work Area | Content changes based on selected menu | |
| 45 | +| Mock Statistics Cards | Placeholder cards showing sample data | |
| 46 | + |
| 47 | +**Architecture:** |
| 48 | + |
| 49 | +```mermaid |
| 50 | +graph LR |
| 51 | + A[LoginView] -->|LoginSuccessEvent| B[AdminApp] |
| 52 | + B -->|Switch View| C[DashboardView] |
| 53 | + C --> D[Sidebar - 200px] |
| 54 | + C --> E[Work Area] |
| 55 | + D --> F[Earnings Menu] |
| 56 | + D --> G[Refunds Menu] |
| 57 | + E --> H[Earnings Panel] |
| 58 | + E --> I[Refunds Panel] |
| 59 | +``` |
| 60 | + |
| 61 | +**Event-Driven View Switching:** |
| 62 | +- `LoginView` emits `LoginSuccessEvent` on successful authentication |
| 63 | +- `AdminApp` subscribes to this event and switches `AppView` enum from `Login` to `Dashboard` |
| 64 | +- This pattern allows decoupled views and clean state management |
| 65 | + |
| 66 | +**Files:** |
| 67 | +- [app.rs](file:///home/westbam/Development/newm-server/newm-admin/src/app.rs) — App state, view switching, event subscription |
| 68 | +- [dashboard.rs](file:///home/westbam/Development/newm-server/newm-admin/src/views/dashboard.rs) — Dashboard view with sidebar and work area |
| 69 | +- [colors.rs](file:///home/westbam/Development/newm-server/newm-admin/src/colors.rs) — Shared color palette |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +## Planned Features |
| 74 | + |
| 75 | +### 🔲 Earnings Management |
| 76 | + |
| 77 | +**Priority:** High |
| 78 | + |
| 79 | +| Requirement | Status | |
| 80 | +|-------------|--------| |
| 81 | +| List all earnings with pagination | ⬜ Not started | |
| 82 | +| Filter by artist, song, date range | ⬜ Not started | |
| 83 | +| View earnings details | ⬜ Not started | |
| 84 | +| Export earnings data | ⬜ Not started | |
| 85 | + |
| 86 | +### 🔲 Refunds Processing |
| 87 | + |
| 88 | +**Priority:** High |
| 89 | + |
| 90 | +| Requirement | Status | |
| 91 | +|-------------|--------| |
| 92 | +| List refund requests | ⬜ Not started | |
| 93 | +| Approve/reject refunds | ⬜ Not started | |
| 94 | +| View refund history | ⬜ Not started | |
| 95 | +| Audit trail for refund actions | ⬜ Not started | |
| 96 | + |
| 97 | +### 🔲 Token Refresh |
| 98 | + |
| 99 | +**Priority:** Medium |
| 100 | + |
| 101 | +| Requirement | Status | |
| 102 | +|-------------|--------| |
| 103 | +| Automatic token refresh before expiry | ⬜ Not started | |
| 104 | +| Token storage (secure) | ⬜ Not started | |
| 105 | +| Session timeout handling | ⬜ Not started | |
| 106 | + |
| 107 | +--- |
| 108 | + |
| 109 | +## Project Structure |
| 110 | + |
| 111 | +``` |
| 112 | +newm-admin/ |
| 113 | +├── src/ |
| 114 | +│ ├── main.rs # Entry point, window setup |
| 115 | +│ ├── app.rs # App state, view coordinator |
| 116 | +│ ├── auth.rs # Authentication client |
| 117 | +│ ├── jwt.rs # JWT parsing utilities |
| 118 | +│ ├── colors.rs # Shared color palette |
| 119 | +│ └── views/ |
| 120 | +│ ├── mod.rs # View module exports |
| 121 | +│ ├── login.rs # Login view |
| 122 | +│ └── dashboard.rs # Dashboard view |
| 123 | +├── Cargo.toml # Dependencies |
| 124 | +├── DESIGN_GUIDE.md # UI styling reference |
| 125 | +└── README.md # Setup instructions |
| 126 | +``` |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +## Design System |
| 131 | + |
| 132 | +The application follows NEWM Studio's visual language: |
| 133 | + |
| 134 | +| Element | Specification | |
| 135 | +|---------|---------------| |
| 136 | +| Background | `#000000` (primary), `#1a1a1a` (surface) | |
| 137 | +| Sidebar | 200px fixed width | |
| 138 | +| Primary Button | Purple-to-pink gradient (`#C341F0` → `#F53C69`) | |
| 139 | +| Text | White (`#ffffff`), secondary gray (`#a1a1aa`) | |
| 140 | +| Icons | From gpui-component-assets | |
| 141 | + |
| 142 | +See [DESIGN_GUIDE.md](file:///home/westbam/Development/newm-server/newm-admin/DESIGN_GUIDE.md) for full specifications. |
| 143 | + |
| 144 | +--- |
| 145 | + |
| 146 | +## Development Commands |
| 147 | + |
| 148 | +```bash |
| 149 | +# Build |
| 150 | +cd newm-admin && cargo build |
| 151 | + |
| 152 | +# Run (development) |
| 153 | +cd newm-admin && cargo run |
| 154 | + |
| 155 | +# Format code |
| 156 | +cd newm-admin && cargo fmt |
| 157 | + |
| 158 | +# Lint |
| 159 | +cd newm-admin && cargo clippy |
| 160 | +``` |
| 161 | + |
| 162 | +--- |
| 163 | + |
| 164 | +## Backend API Dependencies |
| 165 | + |
| 166 | +The admin app communicates with the NEWM backend: |
| 167 | + |
| 168 | +| Endpoint | Purpose | |
| 169 | +|----------|---------| |
| 170 | +| `POST /v1/auth/login` | Admin authentication | |
| 171 | +| `GET /v1/auth/refresh` | Token refresh | |
| 172 | +| `GET /v1/earnings/*` | Earnings data (planned) | |
| 173 | +| `POST /v1/refunds/*` | Refund operations (planned) | |
| 174 | + |
| 175 | +--- |
| 176 | + |
| 177 | +## Change Log |
| 178 | + |
| 179 | +| Date | Feature | Description | |
| 180 | +|------|---------|-------------| |
| 181 | +| 2026-01-07 | Dashboard | Added sidebar nav with Earnings/Refunds, work area panels | |
| 182 | +| 2026-01-07 | Auth | JWT admin validation, login view with environment selector | |
| 183 | +| 2026-01-06 | Init | Project setup with GPUI, basic login UI | |
| 184 | + |
| 185 | +--- |
| 186 | + |
| 187 | +**Status:** 🚧 In Progress |
| 188 | +**Last Updated:** 2026-01-08 |
0 commit comments