# nntfb777/99okcode-admin architecture

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

- Interactive diagram: https://gitdiagram.com/nntfb777/99okcode-admin
- Repository: https://github.com/nntfb777/99okcode-admin

## Overview

This is a browser-based admin console for a multi-site gift-code service. An administrator signs in; the client stores the returned session, and shared auth logic checks access and the active site. From there, dashboard, code, link, account, and history screens call the backend to retrieve or change data and render results. The excerpts show these client-side responsibilities and API interactions; backend internals and HTML wiring are not shown, so the backend is represented as one external service.

Main entry points: [`js/auth.js`](https://github.com/nntfb777/99okcode-admin/blob/main/js/auth.js) (Session and site auth), [`js/lich-su.js`](https://github.com/nntfb777/99okcode-admin/blob/main/js/lich-su.js) (Usage history), [`js/login.js`](https://github.com/nntfb777/99okcode-admin/blob/main/js/login.js) (Sign-in), [`js/index.js`](https://github.com/nntfb777/99okcode-admin/blob/main/js/index.js) (Stats dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access"]
  node_login["Sign-in<br/>[login.js]"]
  node_auth["Session and site auth<br/>[auth.js]"]
end

subgraph group_overview["Dashboard"]
  node_dashboard["Stats dashboard<br/>[index.js]"]
end

subgraph group_operations["Admin operations"]
  node_codes["Code management<br/>[quan-ly-ma.js]"]
  node_links["Link configuration<br/>[quan-ly-link.js]"]
  node_accounts["Admin accounts"]
  node_history["Usage history<br/>[lich-su.js]"]
end

subgraph group_platform["External services"]
  node_storage[("Browser storage")]
  node_backend{{"Admin API"}}
  node_xlsx["SheetJS"]
end

node_admin(("Administrator"))

node_admin -->|"submits credentials"| node_login
node_login -->|"authenticates"| node_backend
node_login -->|"stores session"| node_storage
node_auth -->|"checks session"| node_storage
node_codes -->|"gets active site"| node_auth
node_links -->|"gets active site"| node_auth
node_history -->|"gets active site"| node_auth
node_dashboard -->|"gets active site"| node_auth
node_dashboard -->|"loads stats"| node_backend
node_codes -->|"manages codes"| node_backend
node_links -->|"manages links"| node_backend
node_accounts -->|"manages accounts"| node_backend
node_accounts -->|"logs out"| node_auth
node_history -->|"loads and deletes"| node_backend
node_history -->|"exports workbook"| node_xlsx

click node_login "https://github.com/nntfb777/99okcode-admin/blob/main/js/login.js"
click node_auth "https://github.com/nntfb777/99okcode-admin/blob/main/js/auth.js"
click node_dashboard "https://github.com/nntfb777/99okcode-admin/blob/main/js/index.js"
click node_codes "https://github.com/nntfb777/99okcode-admin/blob/main/js/quan-ly-ma.js"
click node_links "https://github.com/nntfb777/99okcode-admin/blob/main/js/quan-ly-link.js"
click node_accounts "https://github.com/nntfb777/99okcode-admin/blob/main/js/quan-ly-tai-khoan.js"
click node_history "https://github.com/nntfb777/99okcode-admin/blob/main/js/lich-su.js"

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_login,node_auth toneBlue
class node_dashboard toneAmber
class node_codes,node_links,node_accounts,node_history toneMint
class node_storage,node_backend,node_xlsx toneRose
class node_admin toneIndigo
```

## Components

### Access

- [Sign-in](https://github.com/nntfb777/99okcode-admin/blob/main/js/login.js): `js/login.js`
- [Session and site auth](https://github.com/nntfb777/99okcode-admin/blob/main/js/auth.js): `js/auth.js`

### Dashboard

- [Stats dashboard](https://github.com/nntfb777/99okcode-admin/blob/main/js/index.js): `js/index.js`

### Admin operations

- [Code management](https://github.com/nntfb777/99okcode-admin/blob/main/js/quan-ly-ma.js): `js/quan-ly-ma.js`
- [Link configuration](https://github.com/nntfb777/99okcode-admin/blob/main/js/quan-ly-link.js): `js/quan-ly-link.js`
- [Admin accounts](https://github.com/nntfb777/99okcode-admin/blob/main/js/quan-ly-tai-khoan.js): `js/quan-ly-tai-khoan.js`
- [Usage history](https://github.com/nntfb777/99okcode-admin/blob/main/js/lich-su.js): `js/lich-su.js`

### External services

- **Browser storage**
- **Admin API**
- **SheetJS**

### Other components

- **Administrator**

## Connections

- Administrator → Sign-in: submits credentials (evidence: `js/login.js`)
- Sign-in → Admin API: authenticates (evidence: `js/login.js`)
- Sign-in → Browser storage: stores session (evidence: `js/login.js`)
- Session and site auth → Browser storage: checks session (evidence: `js/auth.js`)
- Code management → Session and site auth: gets active site (evidence: `js/quan-ly-ma.js`)
- Link configuration → Session and site auth: gets active site (evidence: `js/quan-ly-link.js`)
- Usage history → Session and site auth: gets active site (evidence: `js/lich-su.js`)
- Stats dashboard → Session and site auth: gets active site (evidence: `js/index.js`)
- Stats dashboard → Admin API: loads stats (evidence: `js/index.js`)
- Code management → Admin API: manages codes (evidence: `js/quan-ly-ma.js`)
- Link configuration → Admin API: manages links (evidence: `js/quan-ly-link.js`)
- Admin accounts → Admin API: manages accounts (evidence: `js/quan-ly-tai-khoan.js`)
- Admin accounts → Session and site auth: logs out (evidence: `js/quan-ly-tai-khoan.js`)
- Usage history → Admin API: loads and deletes (evidence: `js/lich-su.js`)
- Usage history → SheetJS: exports workbook (evidence: `js/lich-su.js`)
