# kgshear/crogen architecture

> Architecture diagram of the GitHub repository kgshear/crogen, 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/kgshear/crogen
- Repository: https://github.com/kgshear/crogen

## Overview

#### Purpose and Entry Point
Crogen is a desktop crochet-pattern authoring tool. Users build rows of stitch types in a Tkinter UI, see a corresponding Blender-based 3D crochet model, and generate written instructions. The application starts from `src/main.py`.

#### Application Structure
The code follows an MVC-like split:
- Controllers coordinate user actions and transitions: `src/controllers/Controller.py`, `src/controllers/CreationController.py`, `src/controllers/DetailController.py`, `src/controllers/PatternController.py`.
- Domain/model logic represents the crochet design and stitches: `src/models/CrochetModel.py`, `src/models/CrochetStitch.py`.
- Tkinter-facing views and generated UI screens live under `src/ui/`, including `src/ui/View.py` and `src/ui/Crogen.py`.

#### Creation Workflow
Pattern construction is centered on the creation screen. The creation controller accepts operations such as adding a quantity/type of stitch, creating rows, clearing, and undoing/redoing edits, then updates the model and view. Relevant boundaries are `src/controllers/CreationController.py`, `src/models/CrochetModel.py`, and `src/ui/Creation/build/CreationView.py`.

#### Crochet Domain State
`CrochetModel` is the likely authoritative in-memory representation of the pattern: ordered rows plus their stitch contents and edit history. `CrochetStitch` encapsulates stitch identity/behavior used by both written-pattern generation and model assembly. Core paths: `src/models/CrochetModel.py` and `src/models/CrochetStitch.py`.

#### 3D Model Integration
Blender is a material runtime dependency and supplies reusable stitch geometry. Stitch-specific `.blend` assets provide the visual primitives used to assemble/update the 3D representation, including `src/models/assets/single-crochet.blend`, `src/models/assets/double-crochet.blend`, and `src/models/assets/chain-stitch.blend`. The model layer forms the boundary between abstract crochet rows/stitches and Blender scene/assets.

#### Pattern Output and Detail Views
The pattern controller converts current crochet state into a human-readable written pattern, while the detail controller/view supports inspection or presentation of generated results. Main components are `src/controllers/PatternController.py`, `src/controllers/DetailController.py`, `src/ui/Pattern/build/PatternView.py`, and `src/ui/Detail/build/DetailView.py`.

#### UI Runtime and Navigation
Tkinter is the desktop UI runtime. `src/ui/Crogen.py` and `src/ui/View.py` likely establish the root application/window and common view behavior; generated screen modules render individual stages. Controllers mediate UI callbacks rather than exposing model operations directly to views. No server, database, or remote external service is indicated.

Main entry points: [`src/models/CrochetModel.py`](https://github.com/kgshear/crogen/blob/main/src/models/CrochetModel.py) (Crochet model), [`src/ui/View.py`](https://github.com/kgshear/crogen/blob/main/src/ui/View.py) (Base view), [`src/controllers/Controller.py`](https://github.com/kgshear/crogen/blob/main/src/controllers/Controller.py) (Navigation controller), [`src/controllers/PatternController.py`](https://github.com/kgshear/crogen/blob/main/src/controllers/PatternController.py) (Pattern controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Tkinter UI"]
  node_app_shell["App shell<br/>Tkinter runtime<br/>[Crogen.py]"]
  node_base_view["Base view<br/>UI abstraction<br/>[View.py]"]
  node_creation_view["Creation screen<br/>Tkinter view<br/>[CreationView.py]"]
  node_pattern_view["Pattern screen<br/>Tkinter view<br/>[PatternView.py]"]
  node_detail_view["Detail screen<br/>Tkinter view<br/>[DetailView.py]"]
end

subgraph group_controllers["Controllers"]
  node_root_controller["Navigation controller<br/>[Controller.py]"]
  node_creation_controller["Creation controller"]
  node_pattern_controller["Pattern controller"]
  node_detail_controller["Detail controller"]
end

subgraph group_domain["Crochet Domain"]
  node_crochet_model[("Crochet model<br/>in-memory pattern state<br/>[CrochetModel.py]")]
  node_crochet_stitch["Crochet stitch<br/>domain entity<br/>[CrochetStitch.py]"]
end

subgraph group_blender["3D Integration"]
  node_blender_scene["Blender assembly<br/>3D model boundary<br/>[CrochetModel.py]"]
  node_single_asset["Single crochet asset<br/>Blender geometry"]
  node_double_asset["Double crochet asset<br/>Blender geometry"]
  node_chain_asset["Chain stitch asset<br/>Blender geometry<br/>[chain-stitch.blend]"]
end

node_entry["Application entry<br/>Python entry point<br/>[main.py]"]

node_entry -->|"starts"| node_app_shell
node_app_shell -->|"uses"| node_base_view
node_app_shell -->|"initializes"| node_root_controller
node_base_view -.->|"shared behavior"| node_creation_view
node_base_view -.->|"shared behavior"| node_pattern_view
node_base_view -.->|"shared behavior"| node_detail_view
node_root_controller -->|"routes to"| node_creation_controller
node_root_controller -->|"routes to"| node_pattern_controller
node_root_controller -->|"routes to"| node_detail_controller
node_creation_view -->|"edit callbacks"| node_creation_controller
node_creation_controller -->|"edits state"| node_crochet_model
node_crochet_model -->|"contains"| node_crochet_stitch
node_crochet_model -->|"assembles 3D model"| node_blender_scene
node_blender_scene -->|"loads"| node_single_asset
node_blender_scene -->|"loads"| node_double_asset
node_blender_scene -->|"loads"| node_chain_asset
node_pattern_controller -->|"reads state"| node_crochet_model
node_pattern_controller -->|"formats stitches"| node_crochet_stitch
node_pattern_controller -->|"updates output"| node_pattern_view
node_detail_controller -->|"reads state"| node_crochet_model
node_detail_controller -->|"updates"| node_detail_view

click node_entry "https://github.com/kgshear/crogen/blob/main/src/main.py"
click node_app_shell "https://github.com/kgshear/crogen/blob/main/src/ui/Crogen.py"
click node_base_view "https://github.com/kgshear/crogen/blob/main/src/ui/View.py"
click node_creation_view "https://github.com/kgshear/crogen/blob/main/src/ui/Creation/build/CreationView.py"
click node_pattern_view "https://github.com/kgshear/crogen/blob/main/src/ui/Pattern/build/PatternView.py"
click node_detail_view "https://github.com/kgshear/crogen/blob/main/src/ui/Detail/build/DetailView.py"
click node_root_controller "https://github.com/kgshear/crogen/blob/main/src/controllers/Controller.py"
click node_creation_controller "https://github.com/kgshear/crogen/blob/main/src/controllers/CreationController.py"
click node_pattern_controller "https://github.com/kgshear/crogen/blob/main/src/controllers/PatternController.py"
click node_detail_controller "https://github.com/kgshear/crogen/blob/main/src/controllers/DetailController.py"
click node_crochet_model "https://github.com/kgshear/crogen/blob/main/src/models/CrochetModel.py"
click node_crochet_stitch "https://github.com/kgshear/crogen/blob/main/src/models/CrochetStitch.py"
click node_blender_scene "https://github.com/kgshear/crogen/blob/main/src/models/CrochetModel.py"
click node_single_asset "https://github.com/kgshear/crogen/blob/main/src/models/assets/single-crochet.blend"
click node_double_asset "https://github.com/kgshear/crogen/blob/main/src/models/assets/double-crochet.blend"
click node_chain_asset "https://github.com/kgshear/crogen/blob/main/src/models/assets/chain-stitch.blend"

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_shell,node_base_view,node_creation_view,node_pattern_view,node_detail_view toneBlue
class node_root_controller,node_creation_controller,node_pattern_controller,node_detail_controller toneAmber
class node_crochet_model,node_crochet_stitch toneMint
class node_blender_scene,node_single_asset,node_double_asset,node_chain_asset toneRose
class node_entry toneNeutral
```

## Components

### Tkinter UI

Desktop shell and workflow screens.

- [App shell](https://github.com/kgshear/crogen/blob/main/src/ui/Crogen.py): Tkinter runtime · Establishes the desktop application window. · `src/ui/Crogen.py`
- [Base view](https://github.com/kgshear/crogen/blob/main/src/ui/View.py): UI abstraction · Provides common view behavior. · `src/ui/View.py`
- [Creation screen](https://github.com/kgshear/crogen/blob/main/src/ui/Creation/build/CreationView.py): Tkinter view · Captures row and stitch editing actions. · `src/ui/Creation/build/CreationView.py`
- [Pattern screen](https://github.com/kgshear/crogen/blob/main/src/ui/Pattern/build/PatternView.py): Tkinter view · Renders written pattern output. · `src/ui/Pattern/build/PatternView.py`
- [Detail screen](https://github.com/kgshear/crogen/blob/main/src/ui/Detail/build/DetailView.py): Tkinter view · Presents generated pattern details. · `src/ui/Detail/build/DetailView.py`

### Controllers

Coordinate UI actions and workflow transitions.

- [Navigation controller](https://github.com/kgshear/crogen/blob/main/src/controllers/Controller.py): controller · Coordinates application-level transitions. · `src/controllers/Controller.py`
- [Creation controller](https://github.com/kgshear/crogen/blob/main/src/controllers/CreationController.py): controller · Applies add, row, clear, undo, and redo operations. · `src/controllers/CreationController.py`
- [Pattern controller](https://github.com/kgshear/crogen/blob/main/src/controllers/PatternController.py): controller · Converts crochet state into written instructions. · `src/controllers/PatternController.py`
- [Detail controller](https://github.com/kgshear/crogen/blob/main/src/controllers/DetailController.py): controller · Coordinates detail presentation. · `src/controllers/DetailController.py`

### Crochet Domain

Authoritative pattern state and stitch semantics.

- [Crochet model](https://github.com/kgshear/crogen/blob/main/src/models/CrochetModel.py): in-memory pattern state · Owns ordered rows, stitches, and edit history. · `src/models/CrochetModel.py`
- [Crochet stitch](https://github.com/kgshear/crogen/blob/main/src/models/CrochetStitch.py): domain entity · Defines stitch identity and behavior. · `src/models/CrochetStitch.py`

### 3D Integration

Blender-backed stitch geometry and scene assembly.

- [Blender assembly](https://github.com/kgshear/crogen/blob/main/src/models/CrochetModel.py): 3D model boundary · Maps crochet rows and stitches into the 3D representation. · `src/models/CrochetModel.py`
- [Single crochet asset](https://github.com/kgshear/crogen/blob/main/src/models/assets/single-crochet.blend): Blender geometry · `src/models/assets/single-crochet.blend`
- [Double crochet asset](https://github.com/kgshear/crogen/blob/main/src/models/assets/double-crochet.blend): Blender geometry · `src/models/assets/double-crochet.blend`
- [Chain stitch asset](https://github.com/kgshear/crogen/blob/main/src/models/assets/chain-stitch.blend): Blender geometry · `src/models/assets/chain-stitch.blend`

### Other components

- [Application entry](https://github.com/kgshear/crogen/blob/main/src/main.py): Python entry point · `src/main.py`

## Connections

- Application entry → App shell: starts
- App shell → Base view: uses
- App shell → Navigation controller: initializes
- Base view → Creation screen: shared behavior
- Base view → Pattern screen: shared behavior
- Base view → Detail screen: shared behavior
- Navigation controller → Creation controller: routes to
- Navigation controller → Pattern controller: routes to
- Navigation controller → Detail controller: routes to
- Creation screen → Creation controller: edit callbacks
- Creation controller → Crochet model: edits state
- Crochet model → Crochet stitch: contains
- Crochet model → Blender assembly: assembles 3D model
- Blender assembly → Single crochet asset: loads
- Blender assembly → Double crochet asset: loads
- Blender assembly → Chain stitch asset: loads
- Pattern controller → Crochet model: reads state
- Pattern controller → Crochet stitch: formats stitches
- Pattern controller → Pattern screen: updates output
- Detail controller → Crochet model: reads state
- Detail controller → Detail screen: updates
