# ephf/just-jsx architecture

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

- Interactive diagram: https://gitdiagram.com/ephf/just-jsx
- Repository: https://github.com/ephf/just-jsx

## Overview

Just JSX compiles JSX syntax in browser scripts or through a command-line compiler. In the browser, a mutation observer detects scripts marked `jsx`, parses their contents, and marks them compiled; the runtime also provides JSX element creation and an asynchronous import helper. The CLI walks input files, parses JavaScript-family files and JSX script bodies in HTML, and writes results to an output directory. The README documents both browser use and directory/file compilation. The CLI’s required minified runtime file is not present in the supplied tree, so its linkage to the sampled runtime is shown as unverified.

Main entry points: [`src/jsx.js`](https://github.com/ephf/just-jsx/blob/main/src/jsx.js) (JSX parser), [`bin/jsxc.js`](https://github.com/ephf/just-jsx/blob/main/bin/jsxc.js) (Compiler CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser_runtime["Browser Runtime"]
  node_script_observer["Script observer<br/>[jsx.js]"]
end

subgraph group_cli_compiler["CLI Compiler"]
  node_cli["Compiler CLI<br/>[jsxc.js]"]
end

subgraph group_jsx_core["JSX Core"]
  node_jsx_parse["JSX parser<br/>[jsx.js]"]
  node_element_factory["Element factory<br/>[jsx.js]"]
  node_async_import["Async imports<br/>[jsx.js]"]
end

node_page_author(("Page author"))
node_browser(("Browser page"))
node_dom["Browser DOM"]
node_cli_user(("CLI user"))
node_filesystem["Input and output files"]
node_module_service["Module source"]

node_page_author -->|"marks scripts"| node_browser
node_browser -->|"loads runtime"| node_script_observer
node_script_observer -->|"parses scripts"| node_jsx_parse
node_script_observer -->|"observes and replaces"| node_dom
node_jsx_parse -->|"emits calls"| node_element_factory
node_element_factory -->|"creates elements"| node_dom
node_async_import -->|"fetches source"| node_module_service
node_async_import -->|"parses source"| node_jsx_parse
node_cli_user -->|"runs compiler"| node_cli
node_cli -->|"reads and writes"| node_filesystem
node_cli -.->|"parses content"| node_jsx_parse

click node_script_observer "https://github.com/ephf/just-jsx/blob/main/src/jsx.js"
click node_jsx_parse "https://github.com/ephf/just-jsx/blob/main/src/jsx.js"
click node_element_factory "https://github.com/ephf/just-jsx/blob/main/src/jsx.js"
click node_async_import "https://github.com/ephf/just-jsx/blob/main/src/jsx.js"
click node_cli "https://github.com/ephf/just-jsx/blob/main/bin/jsxc.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_script_observer,node_browser,node_dom,node_cli_user toneBlue
class node_cli toneAmber
class node_jsx_parse,node_element_factory,node_async_import toneMint
class node_page_author,node_filesystem,node_module_service toneIndigo
```

## Components

### Browser Runtime

- [Script observer](https://github.com/ephf/just-jsx/blob/main/src/jsx.js): `src/jsx.js`

### CLI Compiler

- [Compiler CLI](https://github.com/ephf/just-jsx/blob/main/bin/jsxc.js): `bin/jsxc.js`

### JSX Core

- [JSX parser](https://github.com/ephf/just-jsx/blob/main/src/jsx.js): `src/jsx.js`
- [Element factory](https://github.com/ephf/just-jsx/blob/main/src/jsx.js): `src/jsx.js`
- [Async imports](https://github.com/ephf/just-jsx/blob/main/src/jsx.js): `src/jsx.js`

### Other components

- **Page author**
- **Browser page**
- **Browser DOM**
- **CLI user**
- **Input and output files**
- **Module source**

## Connections

- Page author → Browser page: marks scripts (evidence: `README.md`)
- Browser page → Script observer: loads runtime (evidence: `README.md`)
- Script observer → JSX parser: parses scripts (evidence: `src/jsx.js`)
- Script observer → Browser DOM: observes and replaces (evidence: `src/jsx.js`)
- JSX parser → Element factory: emits calls (evidence: `src/jsx.js`)
- Element factory → Browser DOM: creates elements (evidence: `src/jsx.js`)
- Async imports → Module source: fetches source (evidence: `src/jsx.js`)
- Async imports → JSX parser: parses source (evidence: `src/jsx.js`)
- CLI user → Compiler CLI: runs compiler (evidence: `README.md`)
- Compiler CLI → Input and output files: reads and writes (evidence: `bin/jsxc.js`)
- Compiler CLI → JSX parser: parses content
