# contextgeneric/cgp architecture

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

- Interactive diagram: https://gitdiagram.com/contextgeneric/cgp
- Repository: https://github.com/contextgeneric/cgp

## Overview

##### Main Components

a) Core Layer:
- `cgp-core` at the center as it contains essential CGP constructs
- It directly to `cgp-component` which defines core traits and macros

b) Feature Layers (arranged in concentric circles or layers):
##### Primary Features
- `cgp-component` (core component system)
- `cgp-error` (error handling system)
- `cgp-field` (data-generic programming)
- `cgp-type` (type system utilities)

##### Secondary Features
- `cgp-async` (async capabilities)
- `cgp-run` (async runners)
- `cgp-inner` (composition tools)
- `cgp-sync` (synchronization utilities)

c) Macro Implementation Layer:
- Macro-related crates:
- `cgp-component-macro`
- `cgp-field-macro`
- `cgp-async-macro`
- Their relationship to their respective main features

**┌─ Meta Crates ─────────────┐**
- cgp                       │
- cgp-core                  │
- cgp-extra                 │
- ┬────────────┘
- ↓
**┌─ Core Layer ─────────────┐**
- cgp-component        │
- ┬───────────────┘
- ↓
**┌─ Feature Layers ─────────┐**
- ┌─ Primary ────┐        │
- cgp-error    │        │
- cgp-field    │        │
- cgp-type     │        │
- ┘        │
- ┌─ Secondary ──┐        │
- cgp-async    │        │
- cgp-run      │        │
- cgp-inner    │        │
- ┘        │
- ┘

##### Additional Details

- Version compatibility information (Rust 1.81+)
- Macro relationships with their implementation crates
- Async/sync boundaries
- Public APIs and internal implementation details

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef meta fill:#b3d1ff,stroke:#333
    classDef core fill:#90EE90,stroke:#333
    classDef primary fill:#FFB366,stroke:#333
    classDef secondary fill:#FFEB99,stroke:#333
    classDef macro fill:#DDA0DD,stroke:#333
    classDef error fill:#FF9999,stroke:#333

    %% Meta Layer
    subgraph MetaLayer["Meta Crates"]
        CGP["CGP"]
        CGPCore["CGP Core"]
        CGPExtra["CGP Extra"]
    end

    %% Core Layer
    subgraph CoreLayer["Core Layer"]
        CGPComponent["CGP Component"]
    end

    %% Primary Features
    subgraph PrimaryFeatures["Primary Features"]
        CGPError["CGP Error"]
        CGPField["CGP Field"]
        CGPType["CGP Type"]
    end

    %% Secondary Features
    subgraph SecondaryFeatures["Secondary Features"]
        CGPAsync["CGP Async"]
        CGPRun["CGP Run"]
        CGPInner["CGP Inner"]
        CGPSync["CGP Sync"]
    end

    %% Macro Layer
    subgraph MacroLayer["Macro Implementations"]
        ComponentMacro["Component Macro"]
        FieldMacro["Field Macro"]
        AsyncMacro["Async Macro"]
        ComponentMacroLib["Component Macro Lib"]
        FieldMacroLib["Field Macro Lib"]
    end

    %% Error Extensions
    subgraph ErrorExt["Error Extensions"]
        ErrorStd["Standard Error"]
        ErrorEyre["Eyre Error"]
    end

    %% Relationships
    CGP --> CGPCore
    CGP --> CGPExtra
    CGPCore --> CGPComponent
    CGPComponent --> CGPError
    CGPComponent --> CGPField
    CGPComponent --> CGPType
    CGPField --> CGPAsync
    CGPField --> CGPRun
    CGPField --> CGPInner
    CGPField --> CGPSync
    CGPComponent -.-> ComponentMacro
    CGPField -.-> FieldMacro
    CGPAsync -.-> AsyncMacro
    ComponentMacro --> ComponentMacroLib
    FieldMacro --> FieldMacroLib
    CGPError --> ErrorStd
    CGPError --> ErrorEyre

    %% Click Events
    click CGP "https://github.com/contextgeneric/cgp/tree/main/crates/cgp"
    click CGPCore "https://github.com/contextgeneric/cgp/tree/main/crates/cgp-core"
    click CGPExtra "https://github.com/contextgeneric/cgp/tree/main/crates/cgp-extra"
    click CGPComponent "https://github.com/contextgeneric/cgp/tree/main/crates/cgp-component"
    click CGPError "https://github.com/contextgeneric/cgp/tree/main/crates/cgp-error"
    click CGPField "https://github.com/contextgeneric/cgp/tree/main/crates/cgp-field"
    click CGPType "https://github.com/contextgeneric/cgp/tree/main/crates/cgp-type"
    click CGPAsync "https://github.com/contextgeneric/cgp/tree/main/crates/cgp-async"
    click CGPRun "https://github.com/contextgeneric/cgp/tree/main/crates/cgp-run"
    click CGPInner "https://github.com/contextgeneric/cgp/tree/main/crates/cgp-inner"
    click CGPSync "https://github.com/contextgeneric/cgp/tree/main/crates/cgp-sync"
    click ComponentMacro "https://github.com/contextgeneric/cgp/tree/main/crates/cgp-component-macro"
    click FieldMacro "https://github.com/contextgeneric/cgp/tree/main/crates/cgp-field-macro"
    click AsyncMacro "https://github.com/contextgeneric/cgp/tree/main/crates/cgp-async-macro"
    click ComponentMacroLib "https://github.com/contextgeneric/cgp/tree/main/crates/cgp-component-macro-lib"
    click FieldMacroLib "https://github.com/contextgeneric/cgp/tree/main/crates/cgp-field-macro-lib"
    click ErrorStd "https://github.com/contextgeneric/cgp/tree/main/crates/cgp-error-std"
    click ErrorEyre "https://github.com/contextgeneric/cgp/tree/main/crates/cgp-error-eyre"

    %% Style Applications
    class CGP,CGPCore,CGPExtra meta
    class CGPComponent core
    class CGPError,CGPField,CGPType primary
    class CGPAsync,CGPRun,CGPInner,CGPSync secondary
    class ComponentMacro,FieldMacro,AsyncMacro,ComponentMacroLib,FieldMacroLib macro
    class ErrorStd,ErrorEyre error
```
