# attilamihaly/morphir-elm architecture

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

- Interactive diagram: https://gitdiagram.com/attilamihaly/morphir-elm
- Repository: https://github.com/attilamihaly/morphir-elm

## Overview

Morphir-Elm turns Elm business logic into technology-neutral Morphir IR, then supports code generation, IR browsing and project tooling. The main documented flow is project author → make → IR JSON → gen; develop consumes that IR for a web UI. The repository also exposes TypeScript IR/SDK APIs, an embeddable frontend, MCP tools, and editor decorations. Several CLI and generator implementations were not sampled, so those capability links rely on README statements rather than inspected call paths.

Main entry points: [`cli2/cli.ts`](https://github.com/attilamihaly/morphir-elm/blob/main/cli2/cli.ts) (Morphir commands), [`cli/cli.js`](https://github.com/attilamihaly/morphir-elm/blob/main/cli/cli.js) (Elm translation), [`morphir-ts/src/sdk/dict.ts`](https://github.com/attilamihaly/morphir-elm/blob/main/morphir-ts/src/sdk/dict.ts) (Dictionary operations), [`cli2/morphir-mcp.ts`](https://github.com/attilamihaly/morphir-elm/blob/main/cli2/morphir-mcp.ts) (MCP server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflows"]
  node_commands["Morphir commands<br/>[cli.ts]"]
  node_legacycli["Elm CLI<br/>[cli.js]"]
  node_mcp["MCP server<br/>[morphir-mcp.ts]"]
end

subgraph group_ir["IR processing"]
  node_make["Elm translation<br/>[cli.js]"]
  node_dependency["IR dependencies<br/>[dependencies.ts]"]
  node_irjson[("Morphir IR")]
  node_generation["Code generation"]
  node_typescriptgen["TypeScript generation"]
end

subgraph group_view["IR visualization"]
  node_develop["Develop server"]
  node_treeview["IR tree view<br/>[index.ts]"]
  node_insight["IR insight UI<br/>[insight.js]"]
end

subgraph group_api["SDK and APIs"]
  node_cadl["Cadl frontend<br/>[morphir.ts]"]
  node_irapi["IR TypeScript API<br/>[ir.ts]"]
  node_sdk["TypeScript SDK<br/>[maybe.ts]"]
  node_sdklist["List operations<br/>[list.ts]"]
  node_sdkdict["Dictionary operations<br/>[dict.ts]"]
end

subgraph group_edit["Project editing"]
  node_decorations["Editor decorations"]
  node_editor["Editor integration<br/>[editor.ts]"]
end

node_author(("Project author"))
node_elmproject["Elm project"]

node_author -->|"writes logic"| node_elmproject
node_author -->|"runs commands"| node_commands
node_commands -.->|"invokes make"| node_make
node_legacycli -->|"translates sources"| node_make
node_elmproject -->|"reads sources"| node_make
node_make -->|"produces IR"| node_irjson
node_commands -.->|"runs gen"| node_generation
node_irjson -->|"generates target code"| node_generation
node_commands -.->|"runs generation"| node_typescriptgen
node_commands -->|"loads dependencies"| node_dependency
node_dependency -->|"resolves IR inputs"| node_irjson
node_commands -->|"starts develop"| node_develop
node_develop -->|"browses IR"| node_irjson
node_irjson -->|"fetches IR"| node_treeview
node_author -->|"connects client"| node_mcp
node_mcp -->|"edits project"| node_elmproject
node_irjson -.->|"visualizes IR"| node_insight
node_editor -->|"loads decorations"| node_decorations
node_decorations -->|"reads config and IR"| node_elmproject
node_author -->|"embeds frontend"| node_cadl
node_author -->|"uses IR API"| node_irapi
node_author -->|"uses SDK"| node_sdk
node_sdkdict -->|"uses list operations"| node_sdklist
node_sdkdict -.->|"uses backing structure"| node_sdk

click node_commands "https://github.com/attilamihaly/morphir-elm/blob/main/cli2/cli.ts"
click node_legacycli "https://github.com/attilamihaly/morphir-elm/blob/main/cli/cli.js"
click node_mcp "https://github.com/attilamihaly/morphir-elm/blob/main/cli2/morphir-mcp.ts"
click node_make "https://github.com/attilamihaly/morphir-elm/blob/main/cli/cli.js"
click node_dependency "https://github.com/attilamihaly/morphir-elm/blob/main/cli2/dependencies.ts"
click node_generation "https://github.com/attilamihaly/morphir-elm/blob/main/cli2/morphir-scala-gen.ts"
click node_typescriptgen "https://github.com/attilamihaly/morphir-elm/blob/main/cli2/morphir-typescript-gen.ts"
click node_develop "https://github.com/attilamihaly/morphir-elm/blob/main/cli/morphir-elm-develop.js"
click node_treeview "https://github.com/attilamihaly/morphir-elm/blob/main/cli/treeview/src/index.ts"
click node_insight "https://github.com/attilamihaly/morphir-elm/blob/main/server/web/insight.js"
click node_decorations "https://github.com/attilamihaly/morphir-elm/blob/main/morphir-decoration-extension/src/decoration-manager.ts"
click node_editor "https://github.com/attilamihaly/morphir-elm/blob/main/morphir-decoration-extension/src/editor.ts"
click node_cadl "https://github.com/attilamihaly/morphir-elm/blob/main/cadl-Frontend/src/morphir.ts"
click node_irapi "https://github.com/attilamihaly/morphir-elm/blob/main/morphir-ts/src/exports/ir.ts"
click node_sdk "https://github.com/attilamihaly/morphir-elm/blob/main/morphir-ts/src/sdk/maybe.ts"
click node_sdklist "https://github.com/attilamihaly/morphir-elm/blob/main/morphir-ts/src/sdk/list.ts"
click node_sdkdict "https://github.com/attilamihaly/morphir-elm/blob/main/morphir-ts/src/sdk/dict.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_commands,node_legacycli,node_mcp toneBlue
class node_make,node_dependency,node_irjson,node_generation,node_typescriptgen toneAmber
class node_develop,node_treeview,node_insight toneMint
class node_cadl,node_irapi,node_sdk,node_sdklist,node_sdkdict toneRose
class node_decorations,node_editor,node_author,node_elmproject toneIndigo
```

## Components

### CLI workflows

- [Morphir commands](https://github.com/attilamihaly/morphir-elm/blob/main/cli2/cli.ts): `cli2/cli.ts`
- [Elm CLI](https://github.com/attilamihaly/morphir-elm/blob/main/cli/cli.js): `cli/cli.js`
- [MCP server](https://github.com/attilamihaly/morphir-elm/blob/main/cli2/morphir-mcp.ts): `cli2/morphir-mcp.ts`

### IR processing

- [Elm translation](https://github.com/attilamihaly/morphir-elm/blob/main/cli/cli.js): `cli/cli.js`
- [IR dependencies](https://github.com/attilamihaly/morphir-elm/blob/main/cli2/dependencies.ts): `cli2/dependencies.ts`
- **Morphir IR**
- [Code generation](https://github.com/attilamihaly/morphir-elm/blob/main/cli2/morphir-scala-gen.ts): `cli2/morphir-scala-gen.ts`
- [TypeScript generation](https://github.com/attilamihaly/morphir-elm/blob/main/cli2/morphir-typescript-gen.ts): `cli2/morphir-typescript-gen.ts`

### IR visualization

- [Develop server](https://github.com/attilamihaly/morphir-elm/blob/main/cli/morphir-elm-develop.js): `cli/morphir-elm-develop.js`
- [IR tree view](https://github.com/attilamihaly/morphir-elm/blob/main/cli/treeview/src/index.ts): `cli/treeview/src/index.ts`
- [IR insight UI](https://github.com/attilamihaly/morphir-elm/blob/main/server/web/insight.js): `server/web/insight.js`

### SDK and APIs

- [Cadl frontend](https://github.com/attilamihaly/morphir-elm/blob/main/cadl-Frontend/src/morphir.ts): `cadl-Frontend/src/morphir.ts`
- [IR TypeScript API](https://github.com/attilamihaly/morphir-elm/blob/main/morphir-ts/src/exports/ir.ts): `morphir-ts/src/exports/ir.ts`
- [TypeScript SDK](https://github.com/attilamihaly/morphir-elm/blob/main/morphir-ts/src/sdk/maybe.ts): `morphir-ts/src/sdk/maybe.ts`
- [List operations](https://github.com/attilamihaly/morphir-elm/blob/main/morphir-ts/src/sdk/list.ts): `morphir-ts/src/sdk/list.ts`
- [Dictionary operations](https://github.com/attilamihaly/morphir-elm/blob/main/morphir-ts/src/sdk/dict.ts): `morphir-ts/src/sdk/dict.ts`

### Project editing

- [Editor decorations](https://github.com/attilamihaly/morphir-elm/blob/main/morphir-decoration-extension/src/decoration-manager.ts): `morphir-decoration-extension/src/decoration-manager.ts`
- [Editor integration](https://github.com/attilamihaly/morphir-elm/blob/main/morphir-decoration-extension/src/editor.ts): `morphir-decoration-extension/src/editor.ts`

### Other components

- **Project author**
- **Elm project**

## Connections

- Project author → Elm project: writes logic
- Project author → Morphir commands: runs commands
- Morphir commands → Elm translation: invokes make
- Elm CLI → Elm translation: translates sources (evidence: `cli/cli.js`)
- Elm project → Elm translation: reads sources (evidence: `cli/cli.js`)
- Elm translation → Morphir IR: produces IR
- Morphir commands → Code generation: runs gen
- Morphir IR → Code generation: generates target code
- Morphir commands → TypeScript generation: runs generation
- Morphir commands → IR dependencies: loads dependencies (evidence: `cli2/cli.ts`)
- IR dependencies → Morphir IR: resolves IR inputs (evidence: `cli2/dependencies.ts`)
- Morphir commands → Develop server: starts develop
- Develop server → Morphir IR: browses IR
- Morphir IR → IR tree view: fetches IR (evidence: `cli/treeview/src/index.ts`)
- Project author → MCP server: connects client
- MCP server → Elm project: edits project
- Morphir IR → IR insight UI: visualizes IR
- Editor integration → Editor decorations: loads decorations (evidence: `morphir-decoration-extension/src/editor.ts`)
- Editor decorations → Elm project: reads config and IR (evidence: `morphir-decoration-extension/src/decoration-manager.ts`)
- Project author → Cadl frontend: embeds frontend
- Project author → IR TypeScript API: uses IR API
- Project author → TypeScript SDK: uses SDK
- Dictionary operations → List operations: uses list operations (evidence: `morphir-ts/src/sdk/dict.ts`)
- Dictionary operations → TypeScript SDK: uses backing structure
