# zerovolts/tapestry architecture

> Architecture diagram of the GitHub repository zerovolts/tapestry, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zerovolts/tapestry
- Repository: https://github.com/zerovolts/tapestry

## Overview

##### Pattern System (Top Layer)
- Sub-components for each pattern type:
- Circle
- Cluster
- Line
- Neighborhood
- Rectangle

##### Iterator Systems (Right Side)
- Create two main iterator components:
- Flood Iterator
- Selection Iterator
- Predicate input flow into the Flood Iterator

##### Coordinate System (Left Side)
- A "Coordinate System" component
- Relationship to both the VecGrid and Patterns

##### Implementation Details
- Blue: Core components (VecGrid)
- Green: Patterns
- Yellow: Iterators
- Gray: Utility components (Coordinate System)

##### Data Flow Representation
- Arrowheads to show direction of data flow

##### Component Relationships
- [Coordinate System] ←→ [VecGrid<T>] ←→ [Iterators]
- ↑                   ↑             ↑
- [Pattern System]──────────┘

##### Additional Elements
- Example usage flows for common operations
- Integration points with external systems

Key Considerations:

##### Pattern Integration
- Demonstrate how patterns feed into both the grid and iterators
- Extensibility of the pattern system

##### Iterator Flow
- How the flood and selection iterators interact with the grid
- Predicate input points

##### Documentation Notes
- Notes about generic type constraints
- Common use-case flows
- Reference the example applications (life, dungeon, ring, circle)

- The central role of VecGrid<T>
- The composability of patterns with iterators
- The flexibility of the coordinate system
- The clear separation of concerns between components

Remember to include a small example flow showing how a typical operation (like flood fill) would traverse the system, from coordinate input through pattern application to final iteration output.

This design should help developers understand both the high-level architecture and the practical usage patterns of the library.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core
        VG[VecGrid&lt;T&gt;]:::core
        Grid[Grid Implementation]:::core
    end

    subgraph "Pattern System"
        PS[Pattern Module]:::pattern
        Circle[Circle Pattern]:::pattern
        Cluster[Cluster Pattern]:::pattern
        Line[Line Pattern]:::pattern
        Neighborhood[Neighborhood Pattern]:::pattern
        Rectangle[Rectangle Pattern]:::pattern

        PS --> Circle
        PS --> Cluster
        PS --> Line
        PS --> Neighborhood
        PS --> Rectangle
    end

    subgraph "Iterator System"
        FI[Flood Iterator]:::iterator
        SI[Selection Iterator]:::iterator
    end

    subgraph "Coordinate System"
        CS[Coordinate System]:::coord
    end

    subgraph "Examples"
        CE[Circle Example]:::example
        DE[Dungeon Example]:::example
        LE[Life Example]:::example
        RE[Ring Example]:::example
    end

    CS <--> VG
    VG <--> Grid
    PS --> VG
    PS --> FI
    PS --> SI
    CS --> PS

    classDef core fill:#3498db,stroke:#2980b9,stroke-width:2px
    classDef pattern fill:#2ecc71,stroke:#27ae60,stroke-width:2px
    classDef iterator fill:#f1c40f,stroke:#f39c12,stroke-width:2px
    classDef coord fill:#95a5a6,stroke:#7f8c8d,stroke-width:2px
    classDef example fill:#e74c3c,stroke:#c0392b,stroke-width:2px

    click VG "https://github.com/zerovolts/tapestry/blob/main/src/vecgrid.rs"
    click Grid "https://github.com/zerovolts/tapestry/blob/main/src/grid.rs"
    click CS "https://github.com/zerovolts/tapestry/blob/main/src/coord.rs"
    click PS "https://github.com/zerovolts/tapestry/blob/main/src/patterns/mod.rs"
    click Circle "https://github.com/zerovolts/tapestry/blob/main/src/patterns/circle.rs"
    click Cluster "https://github.com/zerovolts/tapestry/blob/main/src/patterns/cluster.rs"
    click Line "https://github.com/zerovolts/tapestry/blob/main/src/patterns/line.rs"
    click Neighborhood "https://github.com/zerovolts/tapestry/blob/main/src/patterns/neighborhood.rs"
    click Rectangle "https://github.com/zerovolts/tapestry/blob/main/src/patterns/rect.rs"
    click CE "https://github.com/zerovolts/tapestry/blob/main/examples/circle.rs"
    click DE "https://github.com/zerovolts/tapestry/blob/main/examples/dungeon.rs"
    click LE "https://github.com/zerovolts/tapestry/blob/main/examples/life.rs"
    click RE "https://github.com/zerovolts/tapestry/blob/main/examples/ring.rs"

    subgraph Legend
        L1[Core Components]:::core
        L2[Pattern Components]:::pattern
        L3[Iterator Components]:::iterator
        L4[Coordinate System]:::coord
        L5[Example Applications]:::example
    end
```
