# duckweed-yhb/moon-hive architecture

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

- Interactive diagram: https://gitdiagram.com/duckweed-yhb/moon-hive
- Repository: https://github.com/duckweed-yhb/moon-hive

## Overview

MoonHive is a local MoonBit package-verification CLI: users inspect one or survey many candidates, fetched or copied into isolated workspaces, then receive actionable compatibility diagnoses and reports. The graph includes documented doctor and local-dashboard capabilities as well as the main verification path. README architecture and sampled platform C FFI support the layer boundaries; feature-to-feature wiring and report details are not fully sampled, so uncertain links are omitted.

Main entry points: [`verify/check/check.mbt`](https://github.com/duckweed-yhb/moon-hive/blob/main/verify/check/check.mbt) (Toolchain checks), [`cmd/moonhive/main.mbt`](https://github.com/duckweed-yhb/moon-hive/blob/main/cmd/moonhive/main.mbt) (CLI dispatch), [`features/inspect/inspect.mbt`](https://github.com/duckweed-yhb/moon-hive/blob/main/features/inspect/inspect.mbt) (Inspect candidate), [`report/model/model.mbt`](https://github.com/duckweed-yhb/moon-hive/blob/main/report/model/model.mbt) (Report model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Commands"]
  node_cli["CLI dispatch<br/>[main.mbt]"]
  node_inspect["Inspect candidate<br/>[inspect.mbt]"]
  node_survey["Survey packages<br/>[survey.mbt]"]
  node_doctor["Environment check<br/>[doctor.mbt]"]
  node_serve["Dashboard server<br/>[serve.mbt]"]
end

subgraph group_verify["Verification"]
  node_gitsource["Git acquisition<br/>[source.mbt]"]
  node_workspace["Isolated workspace<br/>[workspace.mbt]"]
  node_check["Toolchain checks<br/>[check.mbt]"]
  node_diagnose["Result diagnosis<br/>[diagnose.mbt]"]
  node_result["Verification results<br/>[model.mbt]"]
end

subgraph group_platform["Platform adapters"]
  node_proc["Process execution<br/>[proc.mbt]"]
  node_fs["Filesystem access<br/>[fs.mbt]"]
  node_time["Time utilities<br/>[time.mbt]"]
  node_http["Local HTTP<br/>[http.mbt]"]
  node_errors["Error contract<br/>[error.mbt]"]
end

subgraph group_reporting["Reports and dashboard"]
  node_model["Report model<br/>[model.mbt]"]
  node_json["JSON output<br/>[json.mbt]"]
  node_markdown["Markdown output"]
  node_site["HTML report<br/>[site.mbt]"]
end

node_user(("CLI user"))
node_candidate["Package source"]
node_registry{{"Moon registry"}}
node_browser(("Browser"))
node_reportdir[("Report directory")]

node_user -->|"runs command"| node_cli
node_cli -->|"dispatches"| node_inspect
node_cli -->|"dispatches"| node_survey
node_cli -->|"dispatches"| node_doctor
node_cli -->|"dispatches"| node_serve
node_inspect -->|"acquires repository"| node_gitsource
node_candidate -->|"cloned source"| node_gitsource
node_inspect -->|"stages candidate"| node_workspace
node_gitsource -->|"provides source"| node_workspace
node_registry -.->|"fetched package"| node_workspace
node_inspect -->|"runs verification"| node_check
node_survey -->|"runs verification"| node_check
node_check -->|"checks in"| node_workspace
node_check -->|"runs Moon commands"| node_proc
node_check -->|"classifies evidence"| node_diagnose
node_diagnose -->|"produces conclusion"| node_result
node_check -->|"measures duration"| node_time
node_workspace -->|"manages files"| node_fs
node_gitsource -->|"runs git"| node_proc
node_doctor -->|"checks tools"| node_proc
node_inspect -->|"prepares report data"| node_model
node_survey -->|"prepares report data"| node_model
node_model -->|"formats JSON"| node_json
node_model -->|"renders HTML"| node_site
node_model -->|"renders Markdown"| node_markdown
node_json -->|"writes report"| node_reportdir
node_site -->|"writes report"| node_reportdir
node_markdown -->|"writes report"| node_reportdir
node_serve -->|"starts listener"| node_http
node_serve -->|"serves reports"| node_reportdir
node_browser -->|"requests pages"| node_http
node_http -->|"returns files"| node_browser

click node_cli "https://github.com/duckweed-yhb/moon-hive/blob/main/cmd/moonhive/main.mbt"
click node_inspect "https://github.com/duckweed-yhb/moon-hive/blob/main/features/inspect/inspect.mbt"
click node_survey "https://github.com/duckweed-yhb/moon-hive/blob/main/features/survey/survey.mbt"
click node_doctor "https://github.com/duckweed-yhb/moon-hive/blob/main/features/doctor/doctor.mbt"
click node_serve "https://github.com/duckweed-yhb/moon-hive/blob/main/features/serve/serve.mbt"
click node_gitsource "https://github.com/duckweed-yhb/moon-hive/blob/main/verify/gitsource/source.mbt"
click node_workspace "https://github.com/duckweed-yhb/moon-hive/blob/main/verify/workspace/workspace.mbt"
click node_check "https://github.com/duckweed-yhb/moon-hive/blob/main/verify/check/check.mbt"
click node_diagnose "https://github.com/duckweed-yhb/moon-hive/blob/main/verify/diagnose/diagnose.mbt"
click node_result "https://github.com/duckweed-yhb/moon-hive/blob/main/report/model/model.mbt"
click node_proc "https://github.com/duckweed-yhb/moon-hive/blob/main/platform/proc/proc.mbt"
click node_fs "https://github.com/duckweed-yhb/moon-hive/blob/main/platform/fs/fs.mbt"
click node_time "https://github.com/duckweed-yhb/moon-hive/blob/main/platform/time/time.mbt"
click node_http "https://github.com/duckweed-yhb/moon-hive/blob/main/platform/http/http.mbt"
click node_errors "https://github.com/duckweed-yhb/moon-hive/blob/main/core/error/error.mbt"
click node_model "https://github.com/duckweed-yhb/moon-hive/blob/main/report/model/model.mbt"
click node_json "https://github.com/duckweed-yhb/moon-hive/blob/main/report/json/json.mbt"
click node_markdown "https://github.com/duckweed-yhb/moon-hive/tree/main/report"
click node_site "https://github.com/duckweed-yhb/moon-hive/blob/main/report/site/site.mbt"

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_cli,node_inspect,node_survey,node_doctor,node_serve,node_user,node_browser toneBlue
class node_gitsource,node_workspace,node_check,node_diagnose,node_result,node_reportdir toneAmber
class node_proc,node_fs,node_time,node_http,node_errors toneMint
class node_model,node_json,node_markdown,node_site toneRose
class node_candidate,node_registry toneIndigo
```

## Components

### Commands

- [CLI dispatch](https://github.com/duckweed-yhb/moon-hive/blob/main/cmd/moonhive/main.mbt): `cmd/moonhive/main.mbt`
- [Inspect candidate](https://github.com/duckweed-yhb/moon-hive/blob/main/features/inspect/inspect.mbt): `features/inspect/inspect.mbt`
- [Survey packages](https://github.com/duckweed-yhb/moon-hive/blob/main/features/survey/survey.mbt): `features/survey/survey.mbt`
- [Environment check](https://github.com/duckweed-yhb/moon-hive/blob/main/features/doctor/doctor.mbt): `features/doctor/doctor.mbt`
- [Dashboard server](https://github.com/duckweed-yhb/moon-hive/blob/main/features/serve/serve.mbt): `features/serve/serve.mbt`

### Verification

- [Git acquisition](https://github.com/duckweed-yhb/moon-hive/blob/main/verify/gitsource/source.mbt): `verify/gitsource/source.mbt`
- [Isolated workspace](https://github.com/duckweed-yhb/moon-hive/blob/main/verify/workspace/workspace.mbt): `verify/workspace/workspace.mbt`
- [Toolchain checks](https://github.com/duckweed-yhb/moon-hive/blob/main/verify/check/check.mbt): `verify/check/check.mbt`
- [Result diagnosis](https://github.com/duckweed-yhb/moon-hive/blob/main/verify/diagnose/diagnose.mbt): `verify/diagnose/diagnose.mbt`
- [Verification results](https://github.com/duckweed-yhb/moon-hive/blob/main/report/model/model.mbt): `report/model/model.mbt`

### Platform adapters

- [Process execution](https://github.com/duckweed-yhb/moon-hive/blob/main/platform/proc/proc.mbt): `platform/proc/proc.mbt`
- [Filesystem access](https://github.com/duckweed-yhb/moon-hive/blob/main/platform/fs/fs.mbt): `platform/fs/fs.mbt`
- [Time utilities](https://github.com/duckweed-yhb/moon-hive/blob/main/platform/time/time.mbt): `platform/time/time.mbt`
- [Local HTTP](https://github.com/duckweed-yhb/moon-hive/blob/main/platform/http/http.mbt): `platform/http/http.mbt`
- [Error contract](https://github.com/duckweed-yhb/moon-hive/blob/main/core/error/error.mbt): `core/error/error.mbt`

### Reports and dashboard

- [Report model](https://github.com/duckweed-yhb/moon-hive/blob/main/report/model/model.mbt): `report/model/model.mbt`
- [JSON output](https://github.com/duckweed-yhb/moon-hive/blob/main/report/json/json.mbt): `report/json/json.mbt`
- [Markdown output](https://github.com/duckweed-yhb/moon-hive/tree/main/report): `report`
- [HTML report](https://github.com/duckweed-yhb/moon-hive/blob/main/report/site/site.mbt): `report/site/site.mbt`

### Other components

- **CLI user**
- **Package source**
- **Moon registry**
- **Browser**
- **Report directory**

## Connections

- CLI user → CLI dispatch: runs command
- CLI dispatch → Inspect candidate: dispatches
- CLI dispatch → Survey packages: dispatches
- CLI dispatch → Environment check: dispatches
- CLI dispatch → Dashboard server: dispatches
- Inspect candidate → Git acquisition: acquires repository
- Package source → Git acquisition: cloned source
- Inspect candidate → Isolated workspace: stages candidate
- Git acquisition → Isolated workspace: provides source
- Moon registry → Isolated workspace: fetched package
- Inspect candidate → Toolchain checks: runs verification
- Survey packages → Toolchain checks: runs verification
- Toolchain checks → Isolated workspace: checks in
- Toolchain checks → Process execution: runs Moon commands
- Toolchain checks → Result diagnosis: classifies evidence
- Result diagnosis → Verification results: produces conclusion
- Toolchain checks → Time utilities: measures duration
- Isolated workspace → Filesystem access: manages files
- Git acquisition → Process execution: runs git
- Environment check → Process execution: checks tools
- Inspect candidate → Report model: prepares report data
- Survey packages → Report model: prepares report data
- Report model → JSON output: formats JSON
- Report model → HTML report: renders HTML
- Report model → Markdown output: renders Markdown
- JSON output → Report directory: writes report
- HTML report → Report directory: writes report
- Markdown output → Report directory: writes report
- Dashboard server → Local HTTP: starts listener
- Dashboard server → Report directory: serves reports
- Browser → Local HTTP: requests pages
- Local HTTP → Browser: returns files
