# dayzko1/mjh_app architecture

> Architecture diagram of the GitHub repository dayzko1/mjh_app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dayzko1/mjh_app
- Repository: https://github.com/dayzko1/mjh_app

## Overview

This repository provides a Mahjong tile-matching game in mini-app and browser forms, a browser-based themed game, and an administrative console backed by cloud-function services. Players launch and log in, play levels, earn ad rewards, and access profile, ranking, invitation, and withdrawal features; operators manage users, ads, games, invitations, withdrawals, and configuration. The mini-app API documents platform-specific cloud/HTTP routing, while sampled backend modules show service implementations. Several page and backend connections are not shown in excerpts, so those links are omitted rather than inferred.

Main entry points: [`admin/src/App.tsx`](https://github.com/dayzko1/mjh_app/blob/main/admin/src/App.tsx) (Admin Router), [`mah-miniapp/services/api.js`](https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/services/api.js) (Cloud API), [`mah/src/App.tsx`](https://github.com/dayzko1/mjh_app/blob/main/mah/src/App.tsx) (Game Shell), [`mah-miniapp/utils/platform.js`](https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/utils/platform.js) (Platform Adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mini["Mini-app Game"]
  node_miniapp["App Lifecycle<br/>[app.js]"]
  node_minigame["Tile Game<br/>[game.js]"]
  node_gamecore["Game Engine<br/>[game.js]"]
  node_minipages["Player Pages"]
  node_miniapi["Cloud API<br/>[api.js]"]
end

subgraph group_webgame["Web Themed Game"]
  node_webentry["Web Game Entry<br/>[main.tsx]"]
  node_webapp["Game Shell<br/>[App.tsx]"]
  node_webgameplay["Match Gameplay<br/>[Game.tsx]"]
  node_themeconfig["Theme Builder<br/>[ConfigDialog.tsx]"]
  node_themes["Theme Definitions<br/>[interface.ts]"]
  node_score["Score Display<br/>[Score.tsx]"]
  node_webstate[("Browser Game State<br/>[utils.ts]")]
end

subgraph group_admin["Admin Console"]
  node_adminapp["Admin Router<br/>[App.tsx]"]
  node_login["Admin Login<br/>[index.tsx]"]
  node_dashboard["Dashboard<br/>[index.tsx]"]
  node_users["User Management<br/>[index.tsx]"]
  node_withdrawals["Withdrawal Management<br/>[index.tsx]"]
  node_admanage["Ad Management<br/>[index.tsx]"]
  node_gamemanage["Game Management<br/>[index.tsx]"]
  node_invites["Invite Management<br/>[index.tsx]"]
  node_configmanage["Configuration<br/>[index.tsx]"]
end

subgraph group_backend["Cloud Services"]
  node_userfn["User Service<br/>[index.js]"]
  node_gamefn["Game Service<br/>[index.js]"]
  node_adfn["Ad Service<br/>[index.js]"]
  node_withdrawfn["Withdrawal Service<br/>[index.js]"]
  node_adminfn["Admin Service<br/>[index.js]"]
  node_logger["Cloud Logger<br/>[logger.js]"]
  node_dyservices["Douyin Services"]
end

subgraph group_runtime["Platform Runtime"]
  node_ads["Ad Rewards<br/>[ad.js]"]
  node_sound["Audio<br/>[sound.js]"]
  node_platform["Platform Adapter<br/>[platform.js]"]
  node_webplatform["Web Adapter<br/>[platform-web.js]"]
end

node_player(("Player"))
node_operator(("Operator"))

node_player -->|"launches"| node_miniapp
node_miniapp -->|"initializes"| node_ads
node_miniapp -->|"initializes"| node_sound
node_miniapp -->|"logs in through"| node_miniapi
node_player -->|"plays"| node_minigame
node_minigame -->|"saves progress"| node_miniapi
node_minigame -->|"shows rewards"| node_ads
node_minigame -->|"plays audio"| node_sound
node_gamecore -->|"uses"| node_platform
node_miniapi -->|"calls through"| node_platform
node_ads -->|"creates ads through"| node_platform
node_sound -->|"creates audio through"| node_platform
node_webplatform -->|"adapts for web"| node_platform
node_miniapi -->|"routes user actions"| node_userfn
node_miniapi -->|"routes game actions"| node_gamefn
node_miniapi -->|"routes ad actions"| node_adfn
node_miniapi -->|"routes withdrawal actions"| node_withdrawfn
node_operator -->|"uses"| node_adminapp
node_adminapp -->|"routes to"| node_login
node_adminapp -->|"routes to"| node_dashboard
node_adminapp -->|"routes to"| node_users
node_adminapp -->|"routes to"| node_withdrawals
node_adminapp -->|"routes to"| node_admanage
node_adminapp -->|"routes to"| node_gamemanage
node_adminapp -->|"routes to"| node_invites
node_adminapp -->|"routes to"| node_configmanage
node_adminfn -->|"uses"| node_logger
node_gamefn -->|"uses"| node_logger
node_userfn -->|"uses"| node_logger
node_webentry -->|"renders"| node_webapp
node_webentry -->|"loads theme"| node_themes
node_webapp -->|"renders"| node_webgameplay
node_webapp -->|"opens"| node_themeconfig
node_webapp -->|"accepts theme"| node_themes
node_webapp -->|"reads and resets"| node_webstate
node_webgameplay -->|"renders"| node_score
node_webgameplay -->|"stores progress"| node_webstate

click node_miniapp "https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/app.js"
click node_minigame "https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/pages/game/game.js"
click node_gamecore "https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/game.js"
click node_minipages "https://github.com/dayzko1/mjh_app/tree/main/mah-miniapp/pages"
click node_miniapi "https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/services/api.js"
click node_ads "https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/utils/ad.js"
click node_sound "https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/utils/sound.js"
click node_platform "https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/utils/platform.js"
click node_webplatform "https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/web/platform-web.js"
click node_webentry "https://github.com/dayzko1/mjh_app/blob/main/mah/src/main.tsx"
click node_webapp "https://github.com/dayzko1/mjh_app/blob/main/mah/src/App.tsx"
click node_webgameplay "https://github.com/dayzko1/mjh_app/blob/main/mah/src/components/Game.tsx"
click node_themeconfig "https://github.com/dayzko1/mjh_app/blob/main/mah/src/components/ConfigDialog.tsx"
click node_themes "https://github.com/dayzko1/mjh_app/blob/main/mah/src/themes/interface.ts"
click node_score "https://github.com/dayzko1/mjh_app/blob/main/mah/src/components/Score.tsx"
click node_webstate "https://github.com/dayzko1/mjh_app/blob/main/mah/src/utils.ts"
click node_adminapp "https://github.com/dayzko1/mjh_app/blob/main/admin/src/App.tsx"
click node_login "https://github.com/dayzko1/mjh_app/blob/main/admin/src/pages/Login/index.tsx"
click node_dashboard "https://github.com/dayzko1/mjh_app/blob/main/admin/src/pages/Dashboard/index.tsx"
click node_users "https://github.com/dayzko1/mjh_app/blob/main/admin/src/pages/UserManage/index.tsx"
click node_withdrawals "https://github.com/dayzko1/mjh_app/blob/main/admin/src/pages/WithdrawManage/index.tsx"
click node_admanage "https://github.com/dayzko1/mjh_app/blob/main/admin/src/pages/AdManage/index.tsx"
click node_gamemanage "https://github.com/dayzko1/mjh_app/blob/main/admin/src/pages/GameManage/index.tsx"
click node_invites "https://github.com/dayzko1/mjh_app/blob/main/admin/src/pages/InviteManage/index.tsx"
click node_configmanage "https://github.com/dayzko1/mjh_app/blob/main/admin/src/pages/ConfigManage/index.tsx"
click node_userfn "https://github.com/dayzko1/mjh_app/blob/main/backend/cloudfunctions/user/index.js"
click node_gamefn "https://github.com/dayzko1/mjh_app/blob/main/backend/cloudfunctions/game/index.js"
click node_adfn "https://github.com/dayzko1/mjh_app/blob/main/backend/cloudfunctions/ad/index.js"
click node_withdrawfn "https://github.com/dayzko1/mjh_app/blob/main/backend/cloudfunctions/withdraw/index.js"
click node_adminfn "https://github.com/dayzko1/mjh_app/blob/main/backend/cloudfunctions/admin/index.js"
click node_logger "https://github.com/dayzko1/mjh_app/blob/main/backend/cloudfunctions/shared/logger.js"
click node_dyservices "https://github.com/dayzko1/mjh_app/tree/main/backend/douyin-cloud"

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_miniapp,node_minigame,node_gamecore,node_minipages,node_miniapi toneBlue
class node_webentry,node_webapp,node_webgameplay,node_themeconfig,node_themes,node_score,node_webstate toneAmber
class node_adminapp,node_login,node_dashboard,node_users,node_withdrawals,node_admanage,node_gamemanage,node_invites,node_configmanage toneMint
class node_userfn,node_gamefn,node_adfn,node_withdrawfn,node_adminfn,node_logger,node_dyservices toneRose
class node_ads,node_sound,node_platform,node_webplatform,node_player,node_operator toneIndigo
```

## Components

### Mini-app Game

- [App Lifecycle](https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/app.js): `mah-miniapp/app.js`
- [Tile Game](https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/pages/game/game.js): `mah-miniapp/pages/game/game.js`
- [Game Engine](https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/game.js): `mah-miniapp/game.js`
- [Player Pages](https://github.com/dayzko1/mjh_app/tree/main/mah-miniapp/pages): `mah-miniapp/pages`
- [Cloud API](https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/services/api.js): `mah-miniapp/services/api.js`

### Web Themed Game

- [Web Game Entry](https://github.com/dayzko1/mjh_app/blob/main/mah/src/main.tsx): `mah/src/main.tsx`
- [Game Shell](https://github.com/dayzko1/mjh_app/blob/main/mah/src/App.tsx): `mah/src/App.tsx`
- [Match Gameplay](https://github.com/dayzko1/mjh_app/blob/main/mah/src/components/Game.tsx): `mah/src/components/Game.tsx`
- [Theme Builder](https://github.com/dayzko1/mjh_app/blob/main/mah/src/components/ConfigDialog.tsx): `mah/src/components/ConfigDialog.tsx`
- [Theme Definitions](https://github.com/dayzko1/mjh_app/blob/main/mah/src/themes/interface.ts): `mah/src/themes/interface.ts`
- [Score Display](https://github.com/dayzko1/mjh_app/blob/main/mah/src/components/Score.tsx): `mah/src/components/Score.tsx`
- [Browser Game State](https://github.com/dayzko1/mjh_app/blob/main/mah/src/utils.ts): `mah/src/utils.ts`

### Admin Console

- [Admin Router](https://github.com/dayzko1/mjh_app/blob/main/admin/src/App.tsx): `admin/src/App.tsx`
- [Admin Login](https://github.com/dayzko1/mjh_app/blob/main/admin/src/pages/Login/index.tsx): `admin/src/pages/Login/index.tsx`
- [Dashboard](https://github.com/dayzko1/mjh_app/blob/main/admin/src/pages/Dashboard/index.tsx): `admin/src/pages/Dashboard/index.tsx`
- [User Management](https://github.com/dayzko1/mjh_app/blob/main/admin/src/pages/UserManage/index.tsx): `admin/src/pages/UserManage/index.tsx`
- [Withdrawal Management](https://github.com/dayzko1/mjh_app/blob/main/admin/src/pages/WithdrawManage/index.tsx): `admin/src/pages/WithdrawManage/index.tsx`
- [Ad Management](https://github.com/dayzko1/mjh_app/blob/main/admin/src/pages/AdManage/index.tsx): `admin/src/pages/AdManage/index.tsx`
- [Game Management](https://github.com/dayzko1/mjh_app/blob/main/admin/src/pages/GameManage/index.tsx): `admin/src/pages/GameManage/index.tsx`
- [Invite Management](https://github.com/dayzko1/mjh_app/blob/main/admin/src/pages/InviteManage/index.tsx): `admin/src/pages/InviteManage/index.tsx`
- [Configuration](https://github.com/dayzko1/mjh_app/blob/main/admin/src/pages/ConfigManage/index.tsx): `admin/src/pages/ConfigManage/index.tsx`

### Cloud Services

- [User Service](https://github.com/dayzko1/mjh_app/blob/main/backend/cloudfunctions/user/index.js): `backend/cloudfunctions/user/index.js`
- [Game Service](https://github.com/dayzko1/mjh_app/blob/main/backend/cloudfunctions/game/index.js): `backend/cloudfunctions/game/index.js`
- [Ad Service](https://github.com/dayzko1/mjh_app/blob/main/backend/cloudfunctions/ad/index.js): `backend/cloudfunctions/ad/index.js`
- [Withdrawal Service](https://github.com/dayzko1/mjh_app/blob/main/backend/cloudfunctions/withdraw/index.js): `backend/cloudfunctions/withdraw/index.js`
- [Admin Service](https://github.com/dayzko1/mjh_app/blob/main/backend/cloudfunctions/admin/index.js): `backend/cloudfunctions/admin/index.js`
- [Cloud Logger](https://github.com/dayzko1/mjh_app/blob/main/backend/cloudfunctions/shared/logger.js): `backend/cloudfunctions/shared/logger.js`
- [Douyin Services](https://github.com/dayzko1/mjh_app/tree/main/backend/douyin-cloud): `backend/douyin-cloud`

### Platform Runtime

- [Ad Rewards](https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/utils/ad.js): `mah-miniapp/utils/ad.js`
- [Audio](https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/utils/sound.js): `mah-miniapp/utils/sound.js`
- [Platform Adapter](https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/utils/platform.js): `mah-miniapp/utils/platform.js`
- [Web Adapter](https://github.com/dayzko1/mjh_app/blob/main/mah-miniapp/web/platform-web.js): `mah-miniapp/web/platform-web.js`

### Other components

- **Player**
- **Operator**

## Connections

- Player → App Lifecycle: launches (evidence: `mah-miniapp/app.js`)
- App Lifecycle → Ad Rewards: initializes (evidence: `mah-miniapp/app.js`)
- App Lifecycle → Audio: initializes (evidence: `mah-miniapp/app.js`)
- App Lifecycle → Cloud API: logs in through (evidence: `mah-miniapp/app.js`)
- Player → Tile Game: plays (evidence: `mah-miniapp/pages/game/game.js`)
- Tile Game → Cloud API: saves progress (evidence: `mah-miniapp/pages/game/game.js`)
- Tile Game → Ad Rewards: shows rewards (evidence: `mah-miniapp/pages/game/game.js`)
- Tile Game → Audio: plays audio (evidence: `mah-miniapp/pages/game/game.js`)
- Game Engine → Platform Adapter: uses (evidence: `mah-miniapp/game.js`)
- Cloud API → Platform Adapter: calls through (evidence: `mah-miniapp/services/api.js`)
- Ad Rewards → Platform Adapter: creates ads through (evidence: `mah-miniapp/utils/ad.js`)
- Audio → Platform Adapter: creates audio through (evidence: `mah-miniapp/utils/sound.js`)
- Web Adapter → Platform Adapter: adapts for web (evidence: `mah-miniapp/web/platform-web.js`)
- Cloud API → User Service: routes user actions (evidence: `mah-miniapp/services/api.js`)
- Cloud API → Game Service: routes game actions (evidence: `mah-miniapp/services/api.js`)
- Cloud API → Ad Service: routes ad actions (evidence: `mah-miniapp/services/api.js`)
- Cloud API → Withdrawal Service: routes withdrawal actions (evidence: `mah-miniapp/services/api.js`)
- Operator → Admin Router: uses (evidence: `admin/src/App.tsx`)
- Admin Router → Admin Login: routes to (evidence: `admin/src/App.tsx`)
- Admin Router → Dashboard: routes to (evidence: `admin/src/App.tsx`)
- Admin Router → User Management: routes to (evidence: `admin/src/App.tsx`)
- Admin Router → Withdrawal Management: routes to (evidence: `admin/src/App.tsx`)
- Admin Router → Ad Management: routes to (evidence: `admin/src/App.tsx`)
- Admin Router → Game Management: routes to (evidence: `admin/src/App.tsx`)
- Admin Router → Invite Management: routes to (evidence: `admin/src/App.tsx`)
- Admin Router → Configuration: routes to (evidence: `admin/src/App.tsx`)
- Admin Service → Cloud Logger: uses (evidence: `backend/cloudfunctions/admin/index.js`)
- Game Service → Cloud Logger: uses (evidence: `backend/cloudfunctions/game/index.js`)
- User Service → Cloud Logger: uses (evidence: `backend/cloudfunctions/user/index.js`)
- Web Game Entry → Game Shell: renders (evidence: `mah/src/main.tsx`)
- Web Game Entry → Theme Definitions: loads theme (evidence: `mah/src/main.tsx`)
- Game Shell → Match Gameplay: renders (evidence: `mah/src/App.tsx`)
- Game Shell → Theme Builder: opens (evidence: `mah/src/App.tsx`)
- Game Shell → Theme Definitions: accepts theme (evidence: `mah/src/App.tsx`)
- Game Shell → Browser Game State: reads and resets (evidence: `mah/src/App.tsx`)
- Match Gameplay → Score Display: renders (evidence: `mah/src/components/Game.tsx`)
- Match Gameplay → Browser Game State: stores progress (evidence: `mah/src/components/Game.tsx`)
