Skip to main content

Kiến trúc & Tech stack

Tech stack

LớpCông nghệ
FrameworkReact 18 + TypeScript 4.9
BuildCreate React App 5 + CRACO 7
Routingreact-router-dom v6
StylingTailwind CSS 3 + CSS variables
HTTPAxios 1.3
Formsreact-hook-form 7
Toastreact-hot-toast
Iconslucide-react
CAPTCHA@marsidev/react-turnstile
QR / Phoneqrcode, react-phone-number-input
Monorepo@kioskgaming/ui, @kioskgaming/page-loading
PWAService worker (không Capacitor)

Cấu trúc thư mục

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/ # Mua/phân phối/rút credit
│ │ ├── dashboard/ # HierarchyMiniTree
│ │ ├── finance/
│ │ └── shops/
│ └── utils/
├── public/ # SPA fallback, manifest, sw.js
├── craco.config.js
├── vercel.json
└── package.json

State management

PatternVị tríMục đích
React Contexthooks/useAuth.tsxAuth state
Local useStatePages/componentsUI state
Custom hooksuseAgentTransactions, useSuperAgentOnlineBalanceLedgerData fetching
localStorageagent_auth_token, agent_user_dataPersist auth
Custom Eventsagent-auth-token-changed, auth:unauthorizedCross-component sync
note

Storage keys dùng prefix agent_ (legacy naming) dù đây là Super Agent portal.


Biến môi trường

BiếnDefaultMô tả
REACT_APP_API_BASE_URLhttp://localhost:3001/apiBackend API
REACT_APP_TURNSTILE_ENABLEDfalseCloudflare Turnstile
REACT_APP_TURNSTILE_SITE_KEY''Site key
REACT_APP_APP_NAMEKiosk Gaming — AgentTên app
PORT3003Dev server port

Backend cần AGENT_FRONTEND_URL (hoặc URL super agent tương ứng) cho payment return /payment/return.


Deploy

FilePlatform
vercel.jsonVercel SPA rewrite
public/_redirectsNetlify / Cloudflare Pages
public/.htaccessApache
public/web.configIIS

Không có Capacitor — web SPA/PWA thuần.


Sơ đồ tổng quan

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