# kendmaclean/pharo12 architecture

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

- Interactive diagram: https://gitdiagram.com/kendmaclean/pharo12
- Repository: https://github.com/kendmaclean/pharo12

## Overview

##### Project type and purpose
- This is a collection of Pharo v12 Smalltalk example programs and samples. There is no separate “frontend” and “backend”—each `.st` file is a self-contained sample that you load into the Pharo image to demonstrate core language features, UI patterns (Spec, Morphic), and simple CRUD/domain logic.

##### File structure
- Top-level files:
- README.md – describes the repo as a set of Pharo 12 code examples
- MyChickenFarm.st
- MySalesApp.st
- MyTaskManager.st
- SimpleInventoryApp.st
- SpecCRUD-Example-UI.st
- SpecCRUD-Example-UI-Composition.st
- No nested directories: each `.st` script is an independent sample.
- Key technology indicators: Spec (Pharo’s UI framework), possibly Morphic underneath.

##### README for additional insights
- The README simply declares “pharo 12 smalltalk code examples/sample programs.”

##### Main components
a. Pharo VM + Pharo Image (runtime & Smalltalk environment)
b. Shared UI frameworks:
– Spec framework
– Morphic graphics (implicitly underneath Spec)
c. Individual sample applications (each loaded as a separate script/class package):
– MyChickenFarm (domain logic: farm, animals, events)
– MySalesApp (domain logic: products, orders)
– MyTaskManager (domain logic: tasks, scheduling)
– SimpleInventoryApp (domain logic: inventory, stock)
– SpecCRUD-Example-UI (basic CRUD UI with Spec)
– SpecCRUD-Example-UI-Composition (composed UI demo with Spec)
d. (Optionally) External resources the samples might load (images, smalltalk libraries)

##### Relationships and interactions
- All sample applications “plug into” the central Pharo Image at runtime.
- Each sample invokes the Spec framework to render its UI.
- Data flow is in-memory: sample’s domain objects → Spec widgets → user events → domain operations.
- Under the hood, Spec maps to Morphic for actual rendering.

##### Architectural patterns and design principles
- Each sample follows a simple Model-View approach: domain classes vs. UI classes built with Spec presenters.
- UI Composition uses the Composition pattern in Spec (seen in SpecCRUD-Example-UI-Composition).
- Decoupling of domain logic (model classes) from UI (Spec presenters).

##### Relevant technologies / libraries
- Pharo v12 VM & Image
- Spec (primary UI framework in Pharo)
- Morphic (Spec’s underlying graphics engine)
- Native Smalltalk class libraries for collections, streams, etc.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Sample Applications
    subgraph "Sample Applications"
        direction TB
        MCF["MyChickenFarm\n(Domain & UI)"]:::sample
        MSA["MySalesApp\n(Domain & UI)"]:::sample
        MTM["MyTaskManager\n(Domain & UI)"]:::sample
        SIA["SimpleInventoryApp\n(Domain & UI)"]:::sample
        SCU["SpecCRUD-Example-UI\n(Basic CRUD UI)"]:::sample
        SCC["SpecCRUD-Example-UI-Composition\n(Composed UI Demo)"]:::sample
    end

    %% Runtime
    Pharo["Pharo v12 VM & Image"]:::runtime

    %% Frameworks
    SpecFW["Spec Framework\n(Presentation & Widgets)"]:::framework
    Morphic["Morphic Engine"]:::framework

    %% Connections from samples to runtime and UI framework
    MCF -->|"load script"| Pharo
    MSA -->|"load script"| Pharo
    MTM -->|"load script"| Pharo
    SIA -->|"load script"| Pharo
    SCU -->|"load script"| Pharo
    SCC -->|"load script"| Pharo

    MCF -->|"render UI"| SpecFW
    MSA -->|"render UI"| SpecFW
    MTM -->|"render UI"| SpecFW
    SIA -->|"render UI"| SpecFW
    SCU -->|"render UI"| SpecFW
    SCC -->|"render UI"| SpecFW

    %% Spec to Morphic rendering
    SpecFW -->|"map to Morphic"| Morphic

    %% Click events for sample scripts
    click MCF "https://github.com/kendmaclean/pharo12/blob/main/MyChickenFarm.st"
    click MSA "https://github.com/kendmaclean/pharo12/blob/main/MySalesApp.st"
    click MTM "https://github.com/kendmaclean/pharo12/blob/main/MyTaskManager.st"
    click SIA "https://github.com/kendmaclean/pharo12/blob/main/SimpleInventoryApp.st"
    click SCU "https://github.com/kendmaclean/pharo12/blob/main/SpecCRUD-Example-UI.st"
    click SCC "https://github.com/kendmaclean/pharo12/blob/main/SpecCRUD-Example-UI-Composition.st"

    %% Styles
    classDef sample fill:#fff2cc,stroke:#d0a000,stroke-width:1px;
    classDef framework fill:#cfe2f3,stroke:#2e75b6,stroke-width:1px;
    classDef runtime fill:#d9ead3,stroke:#6aa84f,stroke-width:1px;
```
