# conanzhangtech/mkstick architecture

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

- Interactive diagram: https://gitdiagram.com/conanzhangtech/mkstick
- Repository: https://github.com/conanzhangtech/mkstick

## Overview

mkstick is a browser-based tool for turning Windows or Linux ISO images into bootable FAT32 USB sticks. Users choose an installer or local ISO, the page reads the image and plans its files, then writes and verifies them on a selected drive. Linux images can be streamed through the Worker and checksum-checked; Windows links are refreshed by a scheduled job. The graph preserves the documented catalogue, mirror, and installer-format capabilities. Some UI handlers and Worker routes were not fully sampled, so those links rely on the README rather than inferred source calls.

Main entry points: [`public/lib/flash.js`](https://github.com/conanzhangtech/mkstick/blob/main/public/lib/flash.js) (Plan and write), [`src/index.js`](https://github.com/conanzhangtech/mkstick/blob/main/src/index.js) (API Worker), [`public/app.js`](https://github.com/conanzhangtech/mkstick/blob/main/public/app.js) (Page controller), [`public/lib/source.js`](https://github.com/conanzhangtech/mkstick/blob/main/public/lib/source.js) (Image sources)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser workflow"]
  node_page["Installer page<br/>[index.html]"]
  node_app["Page controller<br/>[app.js]"]
  node_drive[("USB drive")]
end

subgraph group_engine["Image engine"]
  node_source["Image sources<br/>[source.js]"]
  node_flash["Plan and write<br/>[flash.js]"]
  node_udf["UDF reader<br/>[udf.js]"]
  node_iso["ISO reader<br/>[iso9660.js]"]
  node_patch["Boot-menu patches<br/>[patches.js]"]
  node_wim["WIM splitter<br/>[wim.js]"]
end

subgraph group_worker["Worker services"]
  node_worker["API Worker<br/>[index.js]"]
  node_catalogue["Installer catalogue<br/>[index.js]"]
  node_mirror["Linux image mirror<br/>[index.js]"]
  node_linkapi["Windows link API<br/>[index.js]"]
  node_linkstore[("Link storage<br/>[index.js]")]
end

subgraph group_links["Windows link refresh"]
  node_job["Scheduled link fetch<br/>[fetch-links.mjs]"]
  node_mslink["Microsoft link client<br/>[mslink.js]"]
end

node_user(("User"))
node_publisher(("Linux publishers"))
node_microsoft(("Microsoft downloads"))

node_user -->|"opens"| node_page
node_page -->|"loads"| node_app
node_app -->|"opens image"| node_source
node_app -->|"builds plan"| node_flash
node_flash -->|"tries first"| node_udf
node_flash -->|"falls back"| node_iso
node_flash -->|"gets patch"| node_patch
node_flash -->|"plans split"| node_wim
node_flash -->|"streams extents"| node_source
node_flash -->|"writes and verifies"| node_drive
node_app -->|"requests catalogue"| node_worker
node_worker -->|"serves"| node_catalogue
node_app -->|"requests image ranges"| node_worker
node_worker -->|"routes mirror requests"| node_mirror
node_mirror -->|"passes through ranges"| node_publisher
node_source -->|"reads remote pieces"| node_worker
node_app -->|"requests Windows link"| node_linkapi
node_linkapi -->|"reads stored links"| node_linkstore
node_job -->|"fetches links"| node_mslink
node_mslink -->|"requests download links"| node_microsoft
node_job -->|"posts fresh links"| node_worker
node_worker -->|"stores links"| node_linkstore

click node_page "https://github.com/conanzhangtech/mkstick/blob/main/public/index.html"
click node_app "https://github.com/conanzhangtech/mkstick/blob/main/public/app.js"
click node_source "https://github.com/conanzhangtech/mkstick/blob/main/public/lib/source.js"
click node_flash "https://github.com/conanzhangtech/mkstick/blob/main/public/lib/flash.js"
click node_udf "https://github.com/conanzhangtech/mkstick/blob/main/public/lib/udf.js"
click node_iso "https://github.com/conanzhangtech/mkstick/blob/main/public/lib/iso9660.js"
click node_patch "https://github.com/conanzhangtech/mkstick/blob/main/public/lib/patches.js"
click node_wim "https://github.com/conanzhangtech/mkstick/blob/main/public/lib/wim.js"
click node_worker "https://github.com/conanzhangtech/mkstick/blob/main/src/index.js"
click node_catalogue "https://github.com/conanzhangtech/mkstick/blob/main/src/index.js"
click node_mirror "https://github.com/conanzhangtech/mkstick/blob/main/src/index.js"
click node_linkapi "https://github.com/conanzhangtech/mkstick/blob/main/src/index.js"
click node_linkstore "https://github.com/conanzhangtech/mkstick/blob/main/src/index.js"
click node_job "https://github.com/conanzhangtech/mkstick/blob/main/jobs/fetch-links.mjs"
click node_mslink "https://github.com/conanzhangtech/mkstick/blob/main/jobs/mslink.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_page,node_app,node_drive,node_user toneBlue
class node_source,node_flash,node_udf,node_iso,node_patch,node_wim toneAmber
class node_worker,node_catalogue,node_mirror,node_linkapi,node_linkstore toneMint
class node_job,node_mslink toneRose
class node_publisher,node_microsoft toneIndigo
```

## Components

### Browser workflow

- [Installer page](https://github.com/conanzhangtech/mkstick/blob/main/public/index.html): `public/index.html`
- [Page controller](https://github.com/conanzhangtech/mkstick/blob/main/public/app.js): `public/app.js`
- **USB drive**

### Image engine

- [Image sources](https://github.com/conanzhangtech/mkstick/blob/main/public/lib/source.js): `public/lib/source.js`
- [Plan and write](https://github.com/conanzhangtech/mkstick/blob/main/public/lib/flash.js): `public/lib/flash.js`
- [UDF reader](https://github.com/conanzhangtech/mkstick/blob/main/public/lib/udf.js): `public/lib/udf.js`
- [ISO reader](https://github.com/conanzhangtech/mkstick/blob/main/public/lib/iso9660.js): `public/lib/iso9660.js`
- [Boot-menu patches](https://github.com/conanzhangtech/mkstick/blob/main/public/lib/patches.js): `public/lib/patches.js`
- [WIM splitter](https://github.com/conanzhangtech/mkstick/blob/main/public/lib/wim.js): `public/lib/wim.js`

### Worker services

- [API Worker](https://github.com/conanzhangtech/mkstick/blob/main/src/index.js): `src/index.js`
- [Installer catalogue](https://github.com/conanzhangtech/mkstick/blob/main/src/index.js): `src/index.js`
- [Linux image mirror](https://github.com/conanzhangtech/mkstick/blob/main/src/index.js): `src/index.js`
- [Windows link API](https://github.com/conanzhangtech/mkstick/blob/main/src/index.js): `src/index.js`
- [Link storage](https://github.com/conanzhangtech/mkstick/blob/main/src/index.js): `src/index.js`

### Windows link refresh

- [Scheduled link fetch](https://github.com/conanzhangtech/mkstick/blob/main/jobs/fetch-links.mjs): `jobs/fetch-links.mjs`
- [Microsoft link client](https://github.com/conanzhangtech/mkstick/blob/main/jobs/mslink.js): `jobs/mslink.js`

### Other components

- **User**
- **Linux publishers**
- **Microsoft downloads**

## Connections

- User → Installer page: opens (evidence: `README.md`)
- Installer page → Page controller: loads (evidence: `README.md`)
- Page controller → Image sources: opens image (evidence: `public/app.js`)
- Page controller → Plan and write: builds plan (evidence: `public/app.js`)
- Plan and write → UDF reader: tries first (evidence: `public/lib/flash.js`)
- Plan and write → ISO reader: falls back (evidence: `public/lib/flash.js`)
- Plan and write → Boot-menu patches: gets patch (evidence: `public/lib/flash.js`)
- Plan and write → WIM splitter: plans split (evidence: `public/lib/flash.js`)
- Plan and write → Image sources: streams extents (evidence: `public/lib/flash.js`)
- Plan and write → USB drive: writes and verifies (evidence: `README.md`)
- Page controller → API Worker: requests catalogue (evidence: `README.md`)
- API Worker → Installer catalogue: serves (evidence: `src/index.js`)
- Page controller → API Worker: requests image ranges (evidence: `README.md`)
- API Worker → Linux image mirror: routes mirror requests (evidence: `src/index.js`)
- Linux image mirror → Linux publishers: passes through ranges (evidence: `README.md`)
- Image sources → API Worker: reads remote pieces (evidence: `README.md`)
- Page controller → Windows link API: requests Windows link (evidence: `README.md`)
- Windows link API → Link storage: reads stored links (evidence: `src/index.js`)
- Scheduled link fetch → Microsoft link client: fetches links (evidence: `jobs/fetch-links.mjs`)
- Microsoft link client → Microsoft downloads: requests download links (evidence: `jobs/mslink.js`)
- Scheduled link fetch → API Worker: posts fresh links (evidence: `jobs/fetch-links.mjs`)
- API Worker → Link storage: stores links (evidence: `src/index.js`)
