# stitchworkssoftware/crochetcharts architecture

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

- Interactive diagram: https://gitdiagram.com/stitchworkssoftware/crochetcharts
- Repository: https://github.com/stitchworkssoftware/crochetcharts

## Overview

#### Purpose and Entry Points
Crochet Charts is a native desktop application for creating and editing crochet chart patterns. It is a Qt 4.8/C++ application, built through CMake. Process startup is `src/main.cpp`, which initializes the application layer in `src/application.cpp` and presents the primary window in `src/mainwindow.cpp`.

#### Application Shell and Document Tabs
`MainWindow` owns the desktop UI: menus, docks, toolbars, and document lifecycle. Individual open patterns are represented by tab-oriented editor objects, likely coordinated through a shared tab contract:
- `src/mainwindow.cpp`
- `src/crochettab.cpp`
- `src/tabinterface.h`

The UI is Qt Widgets-based, with Designer forms such as `src/mainwindow.ui`, `src/optionsbar.ui`, and dock/dialog `.ui` files compiled into the application.

#### Chart Editing Model and Rendering
The core chart is modeled as cells, stitches, layers, and grouped scene items. The editor renders and interacts with this model through a graphics scene/view boundary:
- `src/cell.cpp`
- `src/scene.cpp`
- `src/chartview.cpp`

`src/chartLayer.cpp`, `src/stitch.cpp`, and `src/itemgroup.cpp` define chart composition and item-level behavior. Editing-oriented operations are centralized in `src/ChartItemTools.cpp`; selection and alignment support are provided by `src/selectionband.cpp` and `src/aligndock.cpp`.

#### Stitch and Palette Domain
Stitch definitions and collections are distinct from the chart canvas, enabling reusable stitch palettes/libraries and replacement operations:
- `src/stitchset.cpp`
- `src/stitchlibrary.cpp`
- `src/stitchreplacerui.cpp`

The application exposes UI for browsing and editing stitch libraries via `src/stitchlibraryui.cpp` and custom delegates. Colors are managed through color widgets and replacement logic such as `src/colorlistwidget.cpp` and `src/colorreplacer.cpp`.

#### Commands, Undo, and Editor State
Mutating chart operations use command/undo infrastructure rather than direct irreversible changes. Chart-specific commands and cross-document undo grouping are separated:
- `src/crochetchartcommands.cpp`
- `src/undogroup.cpp`
- `src/indicatorundo.cpp`

Persistent application preferences are handled by `src/settings.cpp`, while document-facing properties are represented by `src/propertiesdata.cpp` and edited through property docks.

#### File Compatibility and Export
Pattern persistence is versioned behind a factory boundary. The file factory selects format-specific implementations, isolating legacy/current serialization:
- `src/filefactory.cpp`
- `src/file_v1.cpp`
- `src/file_v2.cpp`

Export is a separate UI/workflow rooted in `src/exportui.cpp`; chart imagery is represented by `src/ChartImage.cpp`. This boundary is the likely integration point for producing non-editable chart output.

#### Build, Packaging, and External Dependencies
CMake is the primary build system (`CMakeLists.txt`, `src/CMakeLists.txt`). Runtime dependencies are Qt 4.8 and Hunspell, the latter discovered through `cmake/modules/FindHunSpell.cmake`. Documentation generation uses DocBook, XSLT processing, and Apache FOP under `docs/`.

Platform packaging/signing is supported for Windows (MinGW, NSIS, signtool), macOS (Xcode/signing), and Linux through `resources/installers.cmake` and packaging assets in `resources/`. Developer scripts in `bin/build`, `bin/run`, and `bin/tests` provide the normal compile/run/test entry points.

Main entry points: [`src/mainwindow.cpp`](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/mainwindow.cpp) (Main window), [`src/cell.cpp`](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/cell.cpp) (Chart composition), [`src/crochettab.cpp`](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/crochettab.cpp) (Document tabs), [`src/application.cpp`](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/application.cpp) (Application layer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Desktop application"]
  node_main(("Process startup<br/>C++ entry point<br/>[main.cpp]"))
  node_application["Application layer<br/>Qt application<br/>[application.cpp]"]
  node_mainwindow["Main window<br/>Qt Widgets shell<br/>[mainwindow.cpp]"]
  node_tabs["Document tabs<br/>tab editors<br/>[crochettab.cpp]"]
  node_tabcontract["Tab contract<br/>interface<br/>[tabinterface.h]"]
end

subgraph group_editor["Chart editor"]
  node_chartview["Chart view<br/>graphics view<br/>[chartview.cpp]"]
  node_scene["Chart scene<br/>graphics scene<br/>[scene.cpp]"]
  node_chartmodel["Chart composition<br/>cells, layers, stitches<br/>[cell.cpp]"]
  node_edittools["Editing tools<br/>chart operations<br/>[ChartItemTools.cpp]"]
  node_commands["Chart commands<br/>undo commands"]
  node_undogroup["Undo coordination<br/>cross-document undo<br/>[undogroup.cpp]"]
end

subgraph group_domain["Reusable domains"]
  node_stitchlibrary[("Stitch libraries<br/>stitch collections<br/>[stitchlibrary.cpp]")]
  node_stitchui["Stitch library UI<br/>library browser"]
  node_settings[("Application settings<br/>preferences<br/>[settings.cpp]")]
end

subgraph group_io["Persistence and output"]
  node_filefactory{{"File format factory<br/>versioned serializer<br/>[filefactory.cpp]"}}
  node_filev2["Current file format<br/>pattern serializer<br/>[file_v2.cpp]"]
  node_export["Export workflow<br/>output UI<br/>[exportui.cpp]"]
end

subgraph group_delivery["Build and delivery"]
  node_build["CMake build<br/>build system<br/>[CMakeLists.txt]"]
  node_packaging["Platform packaging<br/>install and signing<br/>[installers.cmake]"]
end

node_main -->|"initializes"| node_application
node_application -->|"presents"| node_mainwindow
node_mainwindow -->|"manages"| node_tabs
node_tabs -->|"implements"| node_tabcontract
node_tabs -->|"hosts editor"| node_chartview
node_chartview -->|"renders and interacts with"| node_scene
node_scene -->|"contains items for"| node_chartmodel
node_edittools -->|"mutates"| node_chartmodel
node_edittools -->|"creates"| node_commands
node_commands -->|"participates in"| node_undogroup
node_mainwindow -->|"reads and updates"| node_settings
node_stitchui -->|"browses and edits"| node_stitchlibrary
node_chartmodel -->|"uses stitch definitions"| node_stitchlibrary
node_mainwindow -->|"opens and saves patterns through"| node_filefactory
node_filefactory -->|"selects current format"| node_filev2
node_mainwindow -->|"launches"| node_export
node_export -->|"exports chart imagery from"| node_chartmodel
node_build -.->|"builds"| node_application
node_packaging -.->|"packages build output"| node_build

click node_main "https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/main.cpp"
click node_application "https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/application.cpp"
click node_mainwindow "https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/mainwindow.cpp"
click node_tabs "https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/crochettab.cpp"
click node_tabcontract "https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/tabinterface.h"
click node_chartview "https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/chartview.cpp"
click node_scene "https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/scene.cpp"
click node_chartmodel "https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/cell.cpp"
click node_edittools "https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/ChartItemTools.cpp"
click node_commands "https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/crochetchartcommands.cpp"
click node_undogroup "https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/undogroup.cpp"
click node_stitchlibrary "https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/stitchlibrary.cpp"
click node_stitchui "https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/stitchlibraryui.cpp"
click node_settings "https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/settings.cpp"
click node_filefactory "https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/filefactory.cpp"
click node_filev2 "https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/file_v2.cpp"
click node_export "https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/exportui.cpp"
click node_build "https://github.com/stitchworkssoftware/crochetcharts/blob/master/CMakeLists.txt"
click node_packaging "https://github.com/stitchworkssoftware/crochetcharts/blob/master/resources/installers.cmake"

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_main,node_application,node_mainwindow,node_tabs,node_tabcontract toneBlue
class node_chartview,node_scene,node_chartmodel,node_edittools,node_commands,node_undogroup toneAmber
class node_stitchlibrary,node_stitchui,node_settings toneMint
class node_filefactory,node_filev2,node_export toneRose
class node_build,node_packaging toneIndigo
```

## Components

### Desktop application

- [Process startup](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/main.cpp): C++ entry point · `src/main.cpp`
- [Application layer](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/application.cpp): Qt application · `src/application.cpp`
- [Main window](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/mainwindow.cpp): Qt Widgets shell · Owns menus, docks, toolbars, and document lifecycle. · `src/mainwindow.cpp`
- [Document tabs](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/crochettab.cpp): tab editors · Open patterns share a tab-oriented editor contract. · `src/crochettab.cpp`
- [Tab contract](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/tabinterface.h): interface · `src/tabinterface.h`

### Chart editor

- [Chart view](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/chartview.cpp): graphics view · Interactive rendering boundary for the chart scene. · `src/chartview.cpp`
- [Chart scene](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/scene.cpp): graphics scene · `src/scene.cpp`
- [Chart composition](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/cell.cpp): cells, layers, stitches · The editable chart is composed from cells, layers, stitches, and item groups. · `src/cell.cpp`
- [Editing tools](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/ChartItemTools.cpp): chart operations · Centralizes editing operations, selection, and alignment support. · `src/ChartItemTools.cpp`
- [Chart commands](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/crochetchartcommands.cpp): undo commands · `src/crochetchartcommands.cpp`
- [Undo coordination](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/undogroup.cpp): cross-document undo · `src/undogroup.cpp`

### Reusable domains

- [Stitch libraries](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/stitchlibrary.cpp): stitch collections · Reusable stitch palettes and replacement operations. · `src/stitchlibrary.cpp`
- [Stitch library UI](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/stitchlibraryui.cpp): library browser · `src/stitchlibraryui.cpp`
- [Application settings](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/settings.cpp): preferences · `src/settings.cpp`

### Persistence and output

- [File format factory](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/filefactory.cpp): versioned serializer · Selects isolated legacy or current pattern serializers. · `src/filefactory.cpp`
- [Current file format](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/file_v2.cpp): pattern serializer · `src/file_v2.cpp`
- [Export workflow](https://github.com/stitchworkssoftware/crochetcharts/blob/master/src/exportui.cpp): output UI · Produces non-editable chart output from chart imagery. · `src/exportui.cpp`

### Build and delivery

- [CMake build](https://github.com/stitchworkssoftware/crochetcharts/blob/master/CMakeLists.txt): build system · Builds the Qt application and discovers Hunspell. · `CMakeLists.txt`
- [Platform packaging](https://github.com/stitchworkssoftware/crochetcharts/blob/master/resources/installers.cmake): install and signing · Supports Windows, macOS, and Linux packaging. · `resources/installers.cmake`

## Connections

- Process startup → Application layer: initializes
- Application layer → Main window: presents
- Main window → Document tabs: manages
- Document tabs → Tab contract: implements
- Document tabs → Chart view: hosts editor
- Chart view → Chart scene: renders and interacts with
- Chart scene → Chart composition: contains items for
- Editing tools → Chart composition: mutates
- Editing tools → Chart commands: creates
- Chart commands → Undo coordination: participates in
- Main window → Application settings: reads and updates
- Stitch library UI → Stitch libraries: browses and edits
- Chart composition → Stitch libraries: uses stitch definitions
- Main window → File format factory: opens and saves patterns through
- File format factory → Current file format: selects current format
- Main window → Export workflow: launches
- Export workflow → Chart composition: exports chart imagery from
- CMake build → Application layer: builds
- Platform packaging → CMake build: packages build output
