# tofu-xx/setupin architecture

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

- Interactive diagram: https://gitdiagram.com/tofu-xx/setupin
- Repository: https://github.com/tofu-xx/setupin

## Overview

setupin is a browser-side runtime for writing Vue single-file-component syntax directly in HTML. The user places inline SFC blocks in a page; setupin watches for and collects them, compiles them through sfc2esm, then injects an import map, executable module, and compiled styles into the page. The README also advertises top-level await, SFC CSS features, and Options API support. The graph follows the sampled runtime wiring; those feature details are documented but their compiler internals are not sampled.

Main entry points: [`src/main.ts`](https://github.com/tofu-xx/setupin/blob/main/src/main.ts) (Runtime entry), [`src/utils/watchRoot.ts`](https://github.com/tofu-xx/setupin/blob/main/src/utils/watchRoot.ts) (Watch head), [`src/awaitClientCode.ts`](https://github.com/tofu-xx/setupin/blob/main/src/awaitClientCode.ts) (Collect SFC), [`src/utils/createDom.ts`](https://github.com/tofu-xx/setupin/blob/main/src/utils/createDom.ts) (DOM builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["SFC Capture"]
  node_await["Collect SFC<br/>[awaitClientCode.ts]"]
  node_watch["Watch head<br/>[watchRoot.ts]"]
end

subgraph group_runtime["Compile &amp; Inject"]
  node_main["Runtime entry<br/>[main.ts]"]
  node_compiler["sfc2esm compiler"]
  node_dom["DOM builder<br/>[createDom.ts]"]
end

node_author(("Page author"))
node_page["HTML with SFC"]
node_browser["Browser DOM"]
node_vue["Vue ESM CDN"]

node_author -->|"writes SFC"| node_page
node_await -->|"starts observing"| node_watch
node_watch -->|"observes head"| node_page
node_watch -->|"returns collected markup"| node_await
node_main -->|"collects source"| node_await
node_main -->|"compiles SFC"| node_compiler
node_main -->|"builds injected nodes"| node_dom
node_dom -->|"mounts nodes"| node_browser
node_main -->|"maps Vue import"| node_vue

click node_await "https://github.com/tofu-xx/setupin/blob/main/src/awaitClientCode.ts"
click node_watch "https://github.com/tofu-xx/setupin/blob/main/src/utils/watchRoot.ts"
click node_main "https://github.com/tofu-xx/setupin/blob/main/src/main.ts"
click node_dom "https://github.com/tofu-xx/setupin/blob/main/src/utils/createDom.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_await,node_watch,node_browser toneBlue
class node_main,node_compiler,node_dom toneAmber
class node_author,node_page,node_vue toneIndigo
```

## Components

### SFC Capture

- [Collect SFC](https://github.com/tofu-xx/setupin/blob/main/src/awaitClientCode.ts): `src/awaitClientCode.ts`
- [Watch head](https://github.com/tofu-xx/setupin/blob/main/src/utils/watchRoot.ts): `src/utils/watchRoot.ts`

### Compile & Inject

- [Runtime entry](https://github.com/tofu-xx/setupin/blob/main/src/main.ts): `src/main.ts`
- **sfc2esm compiler**
- [DOM builder](https://github.com/tofu-xx/setupin/blob/main/src/utils/createDom.ts): `src/utils/createDom.ts`

### Other components

- **Page author**
- **HTML with SFC**
- **Browser DOM**
- **Vue ESM CDN**

## Connections

- Page author → HTML with SFC: writes SFC
- Collect SFC → Watch head: starts observing
- Watch head → HTML with SFC: observes head
- Watch head → Collect SFC: returns collected markup
- Runtime entry → Collect SFC: collects source
- Runtime entry → sfc2esm compiler: compiles SFC
- Runtime entry → DOM builder: builds injected nodes
- DOM builder → Browser DOM: mounts nodes
- Runtime entry → Vue ESM CDN: maps Vue import
