Architecture & Tech stack
Tech stack
| Layer | Technology |
|---|---|
| Framework | React 18 + TypeScript 4.9 |
| Build | Create React App 5 + CRACO 7 |
| Routing | react-router-dom v6 |
| Styling | Tailwind CSS 3 + CSS variables |
| HTTP | Axios 1.3 |
| Forms | react-hook-form 7 |
| Toast | react-hot-toast |
| Icons | lucide-react |
| CAPTCHA | @marsidev/react-turnstile |
| QR / Phone | qrcode, react-phone-number-input |
| Monorepo | @kioskgaming/ui, @kioskgaming/page-loading |
| PWA | Service worker (no Capacitor) |
Directory structure
kioskgaming_superagent/
├── src/
│ ├── index.tsx
│ ├── App.tsx
│ ├── config/env.ts
│ ├── constants/index.ts
│ ├── types/index.ts
│ ├── services/api.ts
│ ├── hooks/ # useAuth, ledger, zerox methods
│ ├── pages/
│ ├── components/
│ │ ├── auth/
│ │ ├── layout/ # AppLayout
│ │ ├── credits/ # Buy/distribute/withdraw credits
│ │ ├── dashboard/ # HierarchyMiniTree
│ │ ├── finance/
│ │ └── shops/
│ └── utils/
├── public/ # SPA fallback, manifest, sw.js
├── craco.config.js
├── vercel.json
└── package.json
State management
| Pattern | Location | Purpose |
|---|---|---|
| React Context | hooks/useAuth.tsx | Auth state |
| Local useState | Pages/components | UI state |
| Custom hooks | useAgentTransactions, useSuperAgentOnlineBalanceLedger | Data fetching |
| localStorage | agent_auth_token, agent_user_data | Persist auth |
| Custom Events | agent-auth-token-changed, auth:unauthorized | Cross-component sync |
note
Storage keys use prefix agent_ (legacy naming) even though this is the Super Agent portal.
Environment variables
| Variable | Default | Description |
|---|---|---|
REACT_APP_API_BASE_URL | http://localhost:3001/api | Backend API |
REACT_APP_TURNSTILE_ENABLED | false | Cloudflare Turnstile |
REACT_APP_TURNSTILE_SITE_KEY | '' | Site key |
REACT_APP_APP_NAME | Kiosk Gaming — Agent | App name |
PORT | 3003 | Dev server port |
Backend requires AGENT_FRONTEND_URL (or equivalent super agent URL) for payment return /payment/return.
Deploy
| File | Platform |
|---|---|
vercel.json | Vercel SPA rewrite |
public/_redirects | Netlify / Cloudflare Pages |
public/.htaccess | Apache |
public/web.config | IIS |
No Capacitor — pure web SPA/PWA.
Overview diagram
flowchart TB
subgraph Client["kioskgaming_superagent"]
App[App.tsx] --> Auth[AuthProvider]
Auth --> Router[React Router]
Router --> Protected[ProtectedRoute + Pages]
Protected --> Layout[AppLayout]
Layout --> API[services/api.ts]
end
subgraph Backend["kioskgaming_backend"]
API -->|Bearer token| SA["/super-agent/*"]
API --> AuthAPI["/super-agent-auth/*"]
end