Dependencies
moon update
make serve| Method | Path | Description |
|---|---|---|
| GET | /api/graphs | List all saved graphs |
| POST | /api/graphs | Create a graph ({"name": "..."}) |
| GET | /api/graphs/:id | Get a graph with all nodes and connections |
| DELETE | /api/graphs/:id | Delete a graph |
| POST | /api/graphs/:id/nodes | Create a node ({"kind": "MathAdd"}) |
| POST | /api/graphs/:gid/nodes/:nid | Update node position or config |
| DELETE | /api/graphs/:gid/nodes/:nid | Delete a node |
| POST | /api/graphs/:id/connections | Create a connection (from/to node and port IDs) |
| DELETE | /api/graphs/:gid/connections/:cid | Delete a connection |
| POST | /api/graphs/:id/evaluate | Evaluate the graph and return all node outputs |
shared/ # Isomorphic code (both js and native)
types.mbt # Node, Connection, Graph, Value, EvalResult structs
ports.mbt # NodeKind enum, input/output port definitions, categories
graph.mbt # Topological sort, graph evaluation, node evaluation
validation.mbt # Connection validation, graph name validation, limits
routes.mbt # API path constants and builders
backend/
main.mbt # Mocket HTTP server, HTML shell, REST API routes
db.mbt # SQLite3 schema, CRUD operations, demo seed data
frontend/
main.mbt # Rabbita app bootstrap
app/
types.mbt # Model, Msg, Page types for MVU state
update.mbt # Message handling, HTTP commands, state transitions
view.mbt # Top-level view dispatch (list vs editor)
view_editor.mbt # Editor canvas: SVG connections, node grid, toolbar
view_node.mbt # Individual node rendering with ports and values
view_connections.mbt # SVG connection lines and active wire preview
view_palette.mbt # Node palette grouped by category
layout.mbt # Auto-layout computation (topological layering)
public/ # Build output for frontend JS
moon.mod.json # Module config and dependencies
Makefile # Build and run commandsgraph LR
subgraph Browser
FE["Frontend (JS)<br/>Rabbita MVU"]
end
subgraph Server
BE["Backend (Native)<br/>Mocket HTTP"]
DB[(SQLite<br/>nodegraph.db)]
end
subgraph "shared/ (js + native)"
S["Types, Ports,<br/>Evaluation, Validation,<br/>Routes"]
end
FE <-->|"REST API<br/>JSON"| BE
BE <--> DB
S -.->|compiled to js| FE
S -.->|compiled to native| BEgraph TD
UA["User Action<br/>(drag node, draw wire,<br/>edit config, click palette)"] --> Msg
Msg --> Update["Model::update()<br/>returns (Model, Cmd)"]
Update --> Model
Update --> Cmd
Model --> View["view()<br/>SVG canvas + HTML controls"]
View --> HTML["Virtual DOM"]
HTML --> UA
Cmd -->|"@http.get, post, delete"| API["REST API<br/>POST /nodes, /connections<br/>POST /evaluate<br/>DELETE /nodes/:id"]
API -->|"JSON response"| RMsg["Response Msg<br/>(NodeAdded, ConnectionAdded,<br/>GotEvalResult, ...)"]
RMsg --> Msggraph TD
G["Graph<br/>(nodes + connections)"] --> TS["Topological Sort<br/>(Kahn's algorithm)"]
TS --> CYC{"Cycle<br/>detected?"}
CYC -->|"Yes"| PARTIAL["Mark has_cycle = true<br/>evaluate acyclic subset"]
CYC -->|"No"| ORDER["Ordered node IDs"]
PARTIAL --> ORDER
ORDER --> LOOP["For each node in order"]
LOOP --> GATHER["Gather input values<br/>from upstream outputs<br/>via connections"]
GATHER --> EVAL["evaluate_node(kind, inputs, config)"]
EVAL --> OK{"Ok?"}
OK -->|"Ok(values)"| STORE["Store outputs<br/>for downstream nodes"]
OK -->|"Err(msg)"| ERR["Record error +<br/>propagate VError<br/>to all output ports"]
STORE --> NEXT["Next node"]
ERR --> NEXT
NEXT --> LOOP
STORE --> RESULT["EvalResult<br/>{ node_outputs, errors,<br/>eval_order, has_cycle }"]
ERR --> RESULTerDiagram
Graph ||--o{ Node : contains
Graph ||--o{ Connection : contains
Node ||--o{ PortDef : "has inputs"
Node ||--o{ PortDef : "has outputs"
Connection }o--|| Node : "from (output)"
Connection }o--|| Node : "to (input)"
Graph {
int id PK
string name
}
Node {
int id PK
NodeKind kind
int x
int y
string label
string config
}
Connection {
int id PK
int from_node_id FK
int from_port
int to_node_id FK
int to_port
}
PortDef {
string name
PortType port_type
}
NodeKind {
enum MathAdd
enum MathSubtract
enum StringConcat
enum LogicAnd
enum ColorRGB
enum ConstNumber
enum DisplayText
enum ___21_kinds_total
}
PortType {
enum TNumber
enum TString
enum TBool
enum TColor
}Install
Download zipDependencies