# hosoo-code/arhat-edit architecture

> Architecture diagram of the GitHub repository hosoo-code/arhat-edit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hosoo-code/arhat-edit
- Repository: https://github.com/hosoo-code/arhat-edit

## Overview

Arhat Edit is a browser-based Mobile Legends account showcase editor with sign-in, VIP access, payment, and administration. The main user flow is to enter the editor, arrange account and skin images, optionally detect cards in collection screenshots, preview a template, and download the rendered image. The tree also contains Next.js route components alongside a Vite-style client app; the supplied excerpts show the client editor flow more clearly than the Next.js editor internals. Wire payment sequencing and several admin capabilities are documented in the README, but their implementation details were not sampled.

Main entry points: [`src/App.tsx`](https://github.com/hosoo-code/arhat-edit/blob/main/src/App.tsx) (Client app), [`src/components/EditorView.tsx`](https://github.com/hosoo-code/arhat-edit/blob/main/src/components/EditorView.tsx) (Editor interface), [`src/app/payment/page.tsx`](https://github.com/hosoo-code/arhat-edit/blob/main/src/app/payment/page.tsx) (Payment page), [`src/state/useEditor.ts`](https://github.com/hosoo-code/arhat-edit/blob/main/src/state/useEditor.ts) (Editor state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_client_app["Client app<br/>[App.tsx]"]
  node_home["Home and plans<br/>[page.tsx]"]
end

subgraph group_editor["Editing and rendering"]
  node_editor_ui["Editor interface<br/>[EditorView.tsx]"]
  node_editor_state["Editor state<br/>[useEditor.ts]"]
  node_image_tools["Image processing<br/>[image.ts]"]
  node_crop_detection["Collection crop detection<br/>[detect.ts]"]
  node_browser_store[("Local image store<br/>[db.ts]")]
  node_preview["Live preview<br/>[LivePreview.tsx]"]
  node_renderer["Canvas renderer<br/>[render.ts]"]
  node_templates["Template registry<br/>[index.ts]"]
  node_export["Image export<br/>[export.ts]"]
end

subgraph group_identity["Identity and access"]
  node_auth["Auth state<br/>[useAuth.ts]"]
  node_access["Access checks<br/>[access.ts]"]
  node_supabase[("Supabase<br/>[server.ts]")]
end

subgraph group_operations["Payments and administration"]
  node_payment_page["Payment page<br/>[page.tsx]"]
  node_wire_create["Create payment<br/>[create.js]"]
  node_wire_service["Wire / QPay"]
  node_wire_check["Check payment<br/>[check.js]"]
  node_wire_webhook["Payment webhook<br/>[webhook.js]"]
  node_admin["Admin management<br/>[page.tsx]"]
  node_admin_actions["Admin actions<br/>[actions.ts]"]
end

node_user(("User"))

node_user -->|"opens app"| node_client_app
node_client_app -->|"loads identity"| node_auth
node_client_app -->|"renders editor"| node_editor_ui
node_client_app -.->|"renders home route"| node_home
node_home -->|"loads access and plans"| node_access
node_access -->|"reads account data"| node_supabase
node_editor_ui -->|"uses editor state"| node_editor_state
node_editor_ui -->|"detects screenshot cards"| node_crop_detection
node_editor_ui -->|"processes images"| node_image_tools
node_editor_state -->|"hashes and decodes images"| node_image_tools
node_editor_state -->|"persists image blobs"| node_browser_store
node_preview -->|"renders preview"| node_renderer
node_preview -->|"exports image"| node_export
node_renderer -.->|"uses template config"| node_templates
node_user -->|"starts VIP purchase"| node_payment_page
node_payment_page -->|"requests payment"| node_wire_create
node_wire_create -->|"creates checkout"| node_wire_service
node_wire_service -->|"returns checkout"| node_payment_page
node_payment_page -->|"checks payment status"| node_wire_check
node_wire_check -->|"reads payment state"| node_wire_service
node_wire_webhook -.->|"updates premium"| node_supabase
node_user -->|"opens admin"| node_admin
node_admin -.->|"manages settings and users"| node_admin_actions
node_admin_actions -.->|"updates account records"| node_supabase

click node_client_app "https://github.com/hosoo-code/arhat-edit/blob/main/src/App.tsx"
click node_home "https://github.com/hosoo-code/arhat-edit/blob/main/src/app/page.tsx"
click node_auth "https://github.com/hosoo-code/arhat-edit/blob/main/src/state/useAuth.ts"
click node_access "https://github.com/hosoo-code/arhat-edit/blob/main/src/lib/access.ts"
click node_supabase "https://github.com/hosoo-code/arhat-edit/blob/main/src/lib/supabase/server.ts"
click node_editor_ui "https://github.com/hosoo-code/arhat-edit/blob/main/src/components/EditorView.tsx"
click node_editor_state "https://github.com/hosoo-code/arhat-edit/blob/main/src/state/useEditor.ts"
click node_image_tools "https://github.com/hosoo-code/arhat-edit/blob/main/src/lib/image.ts"
click node_crop_detection "https://github.com/hosoo-code/arhat-edit/blob/main/src/cv/detect.ts"
click node_browser_store "https://github.com/hosoo-code/arhat-edit/blob/main/src/lib/db.ts"
click node_preview "https://github.com/hosoo-code/arhat-edit/blob/main/src/components/editor/LivePreview.tsx"
click node_renderer "https://github.com/hosoo-code/arhat-edit/blob/main/src/lib/render.ts"
click node_templates "https://github.com/hosoo-code/arhat-edit/blob/main/src/templates/index.ts"
click node_export "https://github.com/hosoo-code/arhat-edit/blob/main/src/lib/export.ts"
click node_payment_page "https://github.com/hosoo-code/arhat-edit/blob/main/src/app/payment/page.tsx"
click node_wire_create "https://github.com/hosoo-code/arhat-edit/blob/main/api/wire/create.js"
click node_wire_check "https://github.com/hosoo-code/arhat-edit/blob/main/api/wire/check.js"
click node_wire_webhook "https://github.com/hosoo-code/arhat-edit/blob/main/api/wire/webhook.js"
click node_admin "https://github.com/hosoo-code/arhat-edit/blob/main/src/app/admin/page.tsx"
click node_admin_actions "https://github.com/hosoo-code/arhat-edit/blob/main/src/app/admin/actions.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_app,node_home,node_user toneBlue
class node_editor_ui,node_editor_state,node_image_tools,node_crop_detection,node_browser_store,node_preview,node_renderer,node_templates,node_export toneAmber
class node_auth,node_access,node_supabase toneMint
class node_payment_page,node_wire_create,node_wire_service,node_wire_check,node_wire_webhook,node_admin,node_admin_actions toneRose
```

## Components

### User experience

- [Client app](https://github.com/hosoo-code/arhat-edit/blob/main/src/App.tsx): `src/App.tsx`
- [Home and plans](https://github.com/hosoo-code/arhat-edit/blob/main/src/app/page.tsx): `src/app/page.tsx`

### Editing and rendering

- [Editor interface](https://github.com/hosoo-code/arhat-edit/blob/main/src/components/EditorView.tsx): `src/components/EditorView.tsx`
- [Editor state](https://github.com/hosoo-code/arhat-edit/blob/main/src/state/useEditor.ts): `src/state/useEditor.ts`
- [Image processing](https://github.com/hosoo-code/arhat-edit/blob/main/src/lib/image.ts): `src/lib/image.ts`
- [Collection crop detection](https://github.com/hosoo-code/arhat-edit/blob/main/src/cv/detect.ts): `src/cv/detect.ts`
- [Local image store](https://github.com/hosoo-code/arhat-edit/blob/main/src/lib/db.ts): `src/lib/db.ts`
- [Live preview](https://github.com/hosoo-code/arhat-edit/blob/main/src/components/editor/LivePreview.tsx): `src/components/editor/LivePreview.tsx`
- [Canvas renderer](https://github.com/hosoo-code/arhat-edit/blob/main/src/lib/render.ts): `src/lib/render.ts`
- [Template registry](https://github.com/hosoo-code/arhat-edit/blob/main/src/templates/index.ts): `src/templates/index.ts`
- [Image export](https://github.com/hosoo-code/arhat-edit/blob/main/src/lib/export.ts): `src/lib/export.ts`

### Identity and access

- [Auth state](https://github.com/hosoo-code/arhat-edit/blob/main/src/state/useAuth.ts): `src/state/useAuth.ts`
- [Access checks](https://github.com/hosoo-code/arhat-edit/blob/main/src/lib/access.ts): `src/lib/access.ts`
- [Supabase](https://github.com/hosoo-code/arhat-edit/blob/main/src/lib/supabase/server.ts): `src/lib/supabase/server.ts`

### Payments and administration

- [Payment page](https://github.com/hosoo-code/arhat-edit/blob/main/src/app/payment/page.tsx): `src/app/payment/page.tsx`
- [Create payment](https://github.com/hosoo-code/arhat-edit/blob/main/api/wire/create.js): `api/wire/create.js`
- **Wire / QPay**
- [Check payment](https://github.com/hosoo-code/arhat-edit/blob/main/api/wire/check.js): `api/wire/check.js`
- [Payment webhook](https://github.com/hosoo-code/arhat-edit/blob/main/api/wire/webhook.js): `api/wire/webhook.js`
- [Admin management](https://github.com/hosoo-code/arhat-edit/blob/main/src/app/admin/page.tsx): `src/app/admin/page.tsx`
- [Admin actions](https://github.com/hosoo-code/arhat-edit/blob/main/src/app/admin/actions.ts): `src/app/admin/actions.ts`

### Other components

- **User**

## Connections

- User → Client app: opens app (evidence: `src/App.tsx`)
- Client app → Auth state: loads identity (evidence: `src/App.tsx`)
- Client app → Editor interface: renders editor (evidence: `src/App.tsx`)
- Client app → Home and plans: renders home route
- Home and plans → Access checks: loads access and plans (evidence: `src/app/page.tsx`)
- Access checks → Supabase: reads account data (evidence: `src/lib/access.ts`)
- Editor interface → Editor state: uses editor state (evidence: `src/App.tsx`)
- Editor interface → Collection crop detection: detects screenshot cards (evidence: `src/components/EditorView.tsx`)
- Editor interface → Image processing: processes images (evidence: `src/components/EditorView.tsx`)
- Editor state → Image processing: hashes and decodes images (evidence: `src/state/useEditor.ts`)
- Editor state → Local image store: persists image blobs (evidence: `src/state/useEditor.ts`)
- Live preview → Canvas renderer: renders preview (evidence: `src/components/editor/LivePreview.tsx`)
- Live preview → Image export: exports image (evidence: `src/components/editor/LivePreview.tsx`)
- Canvas renderer → Template registry: uses template config
- User → Payment page: starts VIP purchase (evidence: `README.md`)
- Payment page → Create payment: requests payment (evidence: `README.md`)
- Create payment → Wire / QPay: creates checkout (evidence: `README.md`)
- Wire / QPay → Payment page: returns checkout (evidence: `README.md`)
- Payment page → Check payment: checks payment status (evidence: `README.md`)
- Check payment → Wire / QPay: reads payment state (evidence: `README.md`)
- Payment webhook → Supabase: updates premium
- User → Admin management: opens admin (evidence: `README.md`)
- Admin management → Admin actions: manages settings and users
- Admin actions → Supabase: updates account records
