# thisisthedarshan/rastrio architecture

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

- Interactive diagram: https://gitdiagram.com/thisisthedarshan/rastrio
- Repository: https://github.com/thisisthedarshan/rastrio

## Overview

RastrIO is an offline-first thermal-document authoring and printing application. The sampled runtime path is Markdown editing through compilation and logical layout to a shared logical preview. The README also documents a printer-specific path from portable documents and printer profiles through PreparedPrint to physical preview and ESC/POS output. Several of those later-stage modules have no source files in the supplied tree, so their nodes use supported module-directory paths and their links rely on the README; they are intended capabilities, not verified implementations.

Main entry points: [`shared/src/commonMain/kotlin/com/circuitnext/rastrio/App.kt`](https://github.com/thisisthedarshan/rastrio/blob/main/shared/src/commonMain/kotlin/com/circuitnext/rastrio/App.kt) (Compose workspace), [`core/printer`](https://github.com/thisisthedarshan/rastrio/tree/main/core/printer) (Physical preparation), [`core/document/src/commonMain/kotlin/com/circuitnext/rastrio/core/document/DocumentModel.kt`](https://github.com/thisisthedarshan/rastrio/blob/main/core/document/src/commonMain/kotlin/com/circuitnext/rastrio/core/document/DocumentModel.kt) (Thermal document), [`shared/src/commonMain/kotlin/com/circuitnext/rastrio/presentation/MarkdownAuthoringSession.kt`](https://github.com/thisisthedarshan/rastrio/blob/main/shared/src/commonMain/kotlin/com/circuitnext/rastrio/presentation/MarkdownAuthoringSession.kt) (Markdown session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Authoring UI"]
  node_app["Compose workspace<br/>[App.kt]"]
  node_session["Markdown session"]
  node_shared_preview["Preview screen"]
end

subgraph group_documents["Document formats"]
  node_markdown["Markdown compiler"]
  node_thermal_doc["Thermal document<br/>[DocumentModel.kt]"]
  node_td_archive["TD archive<br/>[TdArchive.kt]"]
  node_td_json["TD JSON<br/>[TdJson.kt]"]
  node_strict_json["Strict JSON<br/>[StrictJson.kt]"]
  node_templates["Document templates"]
end

subgraph group_logical["Logical preparation"]
  node_layout_engine["Logical layout"]
  node_structured_flow["Structured flow"]
  node_logical_document["Logical document<br/>[LogicalDocument.kt]"]
  node_text_measurement["Text measurement<br/>[TextMeasurement.kt]"]
  node_logical_geometry["Logical geometry<br/>[LogicalGeometry.kt]"]
  node_logical_preview["Logical preview<br/>[LogicalPreview.kt]"]
end

subgraph group_printing["Printer output"]
  node_printer_profile["Printer profiles"]
  node_prepared_print["Physical preparation"]
  node_raster["Raster processing"]
  node_physical_preview["Physical preview"]
  node_escpos["ESC/POS encoding"]
end

subgraph group_hosts["Platform hosts"]
  node_android_host["Android host<br/>[MainActivity.kt]"]
  node_desktop_host["Desktop host<br/>[main.kt]"]
  node_web_host["Web host<br/>[main.kt]"]
  node_transport["Platform transport"]
end

node_user(("Document author"))
node_printer(("Thermal printer"))

node_user -->|"edits in"| node_app
node_app -->|"delegates edits"| node_session
node_session -->|"compiles source"| node_markdown
node_session -->|"lays out result"| node_layout_engine
node_markdown -.->|"produces document"| node_thermal_doc
node_layout_engine -->|"accepts document"| node_thermal_doc
node_layout_engine -->|"delegates layout"| node_structured_flow
node_structured_flow -->|"builds layout"| node_logical_document
node_structured_flow -->|"measures text"| node_text_measurement
node_logical_document -->|"uses geometry"| node_logical_geometry
node_logical_document -->|"projects to preview"| node_logical_preview
node_session -->|"publishes preview"| node_logical_preview
node_app -.->|"shows preview"| node_shared_preview
node_shared_preview -->|"renders model"| node_logical_preview
node_thermal_doc -.->|"serializes document"| node_td_archive
node_td_archive -->|"uses JSON codec"| node_td_json
node_td_json -->|"uses strict parser"| node_strict_json
node_templates -.->|"produces document"| node_thermal_doc
node_thermal_doc -.->|"prepares for printer"| node_prepared_print
node_printer_profile -.->|"configures preparation"| node_prepared_print
node_prepared_print -.->|"drives preview"| node_physical_preview
node_prepared_print -.->|"encodes output"| node_escpos
node_prepared_print -.->|"uses raster fallback"| node_raster
node_escpos -.->|"sends commands"| node_transport
node_transport -.->|"prints output"| node_printer
node_android_host -.->|"hosts UI"| node_app
node_desktop_host -.->|"hosts UI"| node_app
node_web_host -.->|"hosts UI"| node_app

click node_app "https://github.com/thisisthedarshan/rastrio/blob/main/shared/src/commonMain/kotlin/com/circuitnext/rastrio/App.kt"
click node_session "https://github.com/thisisthedarshan/rastrio/blob/main/shared/src/commonMain/kotlin/com/circuitnext/rastrio/presentation/MarkdownAuthoringSession.kt"
click node_markdown "https://github.com/thisisthedarshan/rastrio/blob/main/core/markdown/src/commonMain/kotlin/com/circuitnext/rastrio/core/markdown/MarkdownCompiler.kt"
click node_thermal_doc "https://github.com/thisisthedarshan/rastrio/blob/main/core/document/src/commonMain/kotlin/com/circuitnext/rastrio/core/document/DocumentModel.kt"
click node_td_archive "https://github.com/thisisthedarshan/rastrio/blob/main/core/document/src/commonMain/kotlin/com/circuitnext/rastrio/core/document/TdArchive.kt"
click node_td_json "https://github.com/thisisthedarshan/rastrio/blob/main/core/document/src/commonMain/kotlin/com/circuitnext/rastrio/core/document/TdJson.kt"
click node_strict_json "https://github.com/thisisthedarshan/rastrio/blob/main/core/document/src/commonMain/kotlin/com/circuitnext/rastrio/core/document/StrictJson.kt"
click node_layout_engine "https://github.com/thisisthedarshan/rastrio/blob/main/core/layout/src/commonMain/kotlin/com/circuitnext/rastrio/core/layout/LogicalLayoutEngine.kt"
click node_structured_flow "https://github.com/thisisthedarshan/rastrio/blob/main/core/layout/src/commonMain/kotlin/com/circuitnext/rastrio/core/layout/StructuredBlockFlow.kt"
click node_logical_document "https://github.com/thisisthedarshan/rastrio/blob/main/core/layout/src/commonMain/kotlin/com/circuitnext/rastrio/core/layout/LogicalDocument.kt"
click node_text_measurement "https://github.com/thisisthedarshan/rastrio/blob/main/core/text/src/commonMain/kotlin/com/circuitnext/rastrio/core/text/TextMeasurement.kt"
click node_logical_geometry "https://github.com/thisisthedarshan/rastrio/blob/main/core/text/src/commonMain/kotlin/com/circuitnext/rastrio/core/text/LogicalGeometry.kt"
click node_logical_preview "https://github.com/thisisthedarshan/rastrio/blob/main/core/preview/src/commonMain/kotlin/com/circuitnext/rastrio/core/preview/LogicalPreview.kt"
click node_printer_profile "https://github.com/thisisthedarshan/rastrio/tree/main/core/profile"
click node_prepared_print "https://github.com/thisisthedarshan/rastrio/tree/main/core/printer"
click node_raster "https://github.com/thisisthedarshan/rastrio/tree/main/core/raster"
click node_physical_preview "https://github.com/thisisthedarshan/rastrio/tree/main/core/preview"
click node_escpos "https://github.com/thisisthedarshan/rastrio/tree/main/core/escpos"
click node_templates "https://github.com/thisisthedarshan/rastrio/tree/main/core/templates"
click node_shared_preview "https://github.com/thisisthedarshan/rastrio/blob/main/shared/src/commonMain/kotlin/com/circuitnext/rastrio/LogicalPreviewScreen.kt"
click node_android_host "https://github.com/thisisthedarshan/rastrio/blob/main/androidApp/src/main/kotlin/com/circuitnext/rastrio/MainActivity.kt"
click node_desktop_host "https://github.com/thisisthedarshan/rastrio/blob/main/desktopApp/src/main/kotlin/com/circuitnext/rastrio/main.kt"
click node_web_host "https://github.com/thisisthedarshan/rastrio/blob/main/webApp/src/webMain/kotlin/com/circuitnext/rastrio/main.kt"
click node_transport "https://github.com/thisisthedarshan/rastrio/tree/main/androidApp"

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_app,node_session,node_shared_preview toneBlue
class node_markdown,node_thermal_doc,node_td_archive,node_td_json,node_strict_json,node_templates toneAmber
class node_layout_engine,node_structured_flow,node_logical_document,node_text_measurement,node_logical_geometry,node_logical_preview toneMint
class node_printer_profile,node_prepared_print,node_raster,node_physical_preview,node_escpos toneRose
class node_android_host,node_desktop_host,node_web_host,node_transport,node_user,node_printer toneIndigo
```

## Components

### Authoring UI

- [Compose workspace](https://github.com/thisisthedarshan/rastrio/blob/main/shared/src/commonMain/kotlin/com/circuitnext/rastrio/App.kt): `shared/src/commonMain/kotlin/com/circuitnext/rastrio/App.kt`
- [Markdown session](https://github.com/thisisthedarshan/rastrio/blob/main/shared/src/commonMain/kotlin/com/circuitnext/rastrio/presentation/MarkdownAuthoringSession.kt): `shared/src/commonMain/kotlin/com/circuitnext/rastrio/presentation/MarkdownAuthoringSession.kt`
- [Preview screen](https://github.com/thisisthedarshan/rastrio/blob/main/shared/src/commonMain/kotlin/com/circuitnext/rastrio/LogicalPreviewScreen.kt): `shared/src/commonMain/kotlin/com/circuitnext/rastrio/LogicalPreviewScreen.kt`

### Document formats

- [Markdown compiler](https://github.com/thisisthedarshan/rastrio/blob/main/core/markdown/src/commonMain/kotlin/com/circuitnext/rastrio/core/markdown/MarkdownCompiler.kt): `core/markdown/src/commonMain/kotlin/com/circuitnext/rastrio/core/markdown/MarkdownCompiler.kt`
- [Thermal document](https://github.com/thisisthedarshan/rastrio/blob/main/core/document/src/commonMain/kotlin/com/circuitnext/rastrio/core/document/DocumentModel.kt): `core/document/src/commonMain/kotlin/com/circuitnext/rastrio/core/document/DocumentModel.kt`
- [TD archive](https://github.com/thisisthedarshan/rastrio/blob/main/core/document/src/commonMain/kotlin/com/circuitnext/rastrio/core/document/TdArchive.kt): `core/document/src/commonMain/kotlin/com/circuitnext/rastrio/core/document/TdArchive.kt`
- [TD JSON](https://github.com/thisisthedarshan/rastrio/blob/main/core/document/src/commonMain/kotlin/com/circuitnext/rastrio/core/document/TdJson.kt): `core/document/src/commonMain/kotlin/com/circuitnext/rastrio/core/document/TdJson.kt`
- [Strict JSON](https://github.com/thisisthedarshan/rastrio/blob/main/core/document/src/commonMain/kotlin/com/circuitnext/rastrio/core/document/StrictJson.kt): `core/document/src/commonMain/kotlin/com/circuitnext/rastrio/core/document/StrictJson.kt`
- [Document templates](https://github.com/thisisthedarshan/rastrio/tree/main/core/templates): `core/templates`

### Logical preparation

- [Logical layout](https://github.com/thisisthedarshan/rastrio/blob/main/core/layout/src/commonMain/kotlin/com/circuitnext/rastrio/core/layout/LogicalLayoutEngine.kt): `core/layout/src/commonMain/kotlin/com/circuitnext/rastrio/core/layout/LogicalLayoutEngine.kt`
- [Structured flow](https://github.com/thisisthedarshan/rastrio/blob/main/core/layout/src/commonMain/kotlin/com/circuitnext/rastrio/core/layout/StructuredBlockFlow.kt): `core/layout/src/commonMain/kotlin/com/circuitnext/rastrio/core/layout/StructuredBlockFlow.kt`
- [Logical document](https://github.com/thisisthedarshan/rastrio/blob/main/core/layout/src/commonMain/kotlin/com/circuitnext/rastrio/core/layout/LogicalDocument.kt): `core/layout/src/commonMain/kotlin/com/circuitnext/rastrio/core/layout/LogicalDocument.kt`
- [Text measurement](https://github.com/thisisthedarshan/rastrio/blob/main/core/text/src/commonMain/kotlin/com/circuitnext/rastrio/core/text/TextMeasurement.kt): `core/text/src/commonMain/kotlin/com/circuitnext/rastrio/core/text/TextMeasurement.kt`
- [Logical geometry](https://github.com/thisisthedarshan/rastrio/blob/main/core/text/src/commonMain/kotlin/com/circuitnext/rastrio/core/text/LogicalGeometry.kt): `core/text/src/commonMain/kotlin/com/circuitnext/rastrio/core/text/LogicalGeometry.kt`
- [Logical preview](https://github.com/thisisthedarshan/rastrio/blob/main/core/preview/src/commonMain/kotlin/com/circuitnext/rastrio/core/preview/LogicalPreview.kt): `core/preview/src/commonMain/kotlin/com/circuitnext/rastrio/core/preview/LogicalPreview.kt`

### Printer output

- [Printer profiles](https://github.com/thisisthedarshan/rastrio/tree/main/core/profile): `core/profile`
- [Physical preparation](https://github.com/thisisthedarshan/rastrio/tree/main/core/printer): `core/printer`
- [Raster processing](https://github.com/thisisthedarshan/rastrio/tree/main/core/raster): `core/raster`
- [Physical preview](https://github.com/thisisthedarshan/rastrio/tree/main/core/preview): `core/preview`
- [ESC/POS encoding](https://github.com/thisisthedarshan/rastrio/tree/main/core/escpos): `core/escpos`

### Platform hosts

- [Android host](https://github.com/thisisthedarshan/rastrio/blob/main/androidApp/src/main/kotlin/com/circuitnext/rastrio/MainActivity.kt): `androidApp/src/main/kotlin/com/circuitnext/rastrio/MainActivity.kt`
- [Desktop host](https://github.com/thisisthedarshan/rastrio/blob/main/desktopApp/src/main/kotlin/com/circuitnext/rastrio/main.kt): `desktopApp/src/main/kotlin/com/circuitnext/rastrio/main.kt`
- [Web host](https://github.com/thisisthedarshan/rastrio/blob/main/webApp/src/webMain/kotlin/com/circuitnext/rastrio/main.kt): `webApp/src/webMain/kotlin/com/circuitnext/rastrio/main.kt`
- [Platform transport](https://github.com/thisisthedarshan/rastrio/tree/main/androidApp): `androidApp`

### Other components

- **Document author**
- **Thermal printer**

## Connections

- Document author → Compose workspace: edits in (evidence: `shared/src/commonMain/kotlin/com/circuitnext/rastrio/App.kt`)
- Compose workspace → Markdown session: delegates edits (evidence: `shared/src/commonMain/kotlin/com/circuitnext/rastrio/App.kt`)
- Markdown session → Markdown compiler: compiles source (evidence: `shared/src/commonMain/kotlin/com/circuitnext/rastrio/presentation/MarkdownAuthoringSession.kt`)
- Markdown session → Logical layout: lays out result (evidence: `shared/src/commonMain/kotlin/com/circuitnext/rastrio/presentation/MarkdownAuthoringSession.kt`)
- Markdown compiler → Thermal document: produces document (evidence: `README.md`)
- Logical layout → Thermal document: accepts document (evidence: `core/layout/src/commonMain/kotlin/com/circuitnext/rastrio/core/layout/LogicalLayoutEngine.kt`)
- Logical layout → Structured flow: delegates layout (evidence: `core/layout/src/commonMain/kotlin/com/circuitnext/rastrio/core/layout/LogicalLayoutEngine.kt`)
- Structured flow → Logical document: builds layout (evidence: `core/layout/src/commonMain/kotlin/com/circuitnext/rastrio/core/layout/StructuredBlockFlow.kt`)
- Structured flow → Text measurement: measures text (evidence: `core/layout/src/commonMain/kotlin/com/circuitnext/rastrio/core/layout/StructuredBlockFlow.kt`)
- Logical document → Logical geometry: uses geometry (evidence: `core/layout/src/commonMain/kotlin/com/circuitnext/rastrio/core/layout/LogicalDocument.kt`)
- Logical document → Logical preview: projects to preview (evidence: `core/preview/src/commonMain/kotlin/com/circuitnext/rastrio/core/preview/LogicalPreview.kt`)
- Markdown session → Logical preview: publishes preview (evidence: `shared/src/commonMain/kotlin/com/circuitnext/rastrio/presentation/MarkdownAuthoringSession.kt`)
- Compose workspace → Preview screen: shows preview (evidence: `README.md`)
- Preview screen → Logical preview: renders model (evidence: `shared/src/commonMain/kotlin/com/circuitnext/rastrio/LogicalPreviewScreen.kt`)
- Thermal document → TD archive: serializes document (evidence: `README.md`)
- TD archive → TD JSON: uses JSON codec (evidence: `core/document/src/commonMain/kotlin/com/circuitnext/rastrio/core/document/TdArchive.kt`)
- TD JSON → Strict JSON: uses strict parser (evidence: `core/document/src/commonMain/kotlin/com/circuitnext/rastrio/core/document/TdJson.kt`)
- Document templates → Thermal document: produces document (evidence: `README.md`)
- Thermal document → Physical preparation: prepares for printer (evidence: `README.md`)
- Printer profiles → Physical preparation: configures preparation (evidence: `README.md`)
- Physical preparation → Physical preview: drives preview (evidence: `README.md`)
- Physical preparation → ESC/POS encoding: encodes output (evidence: `README.md`)
- Physical preparation → Raster processing: uses raster fallback (evidence: `README.md`)
- ESC/POS encoding → Platform transport: sends commands (evidence: `README.md`)
- Platform transport → Thermal printer: prints output (evidence: `README.md`)
- Android host → Compose workspace: hosts UI (evidence: `README.md`)
- Desktop host → Compose workspace: hosts UI (evidence: `README.md`)
- Web host → Compose workspace: hosts UI (evidence: `README.md`)
