# winglang/polycons architecture

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

- Interactive diagram: https://gitdiagram.com/winglang/polycons
- Repository: https://github.com/winglang/polycons

## Overview

##### Main Components

a) Core Framework Components:
- Polycons Registry System
- Polycon Factory Interface
- Polycon Base Implementation
- Type Resolution System

b) Integration Points:
- CDK Framework Integration (AWS CDK, cdktf, cdk8s)
- Construct Tree Management
- Factory Registration System

##### Specific Elements

**Rectangle: Core Components**
**Hexagon: External Systems**
**Diamond: Factory Components**
**Oval: Concrete Implementations**

##### Factory Registration Flow
**App (Root) -> Polycons.register() -> Factory Registry**

##### Polycon Resolution Flow
**Client Code -> Polycon Instance -> Factory Resolution -> Concrete Implementation**

##### Type System
**IPolyconFactory -> Concrete Factory -> Concrete Implementation**

##### Important Details to Capture

- Relationship between `IPolyconFactory` and concrete factories
- How type resolution works with the unique string identifiers
- Demonstrate the transformation from Polycon to concrete implementation
- How the construct tree is maintained

##### Implementation Flow

**1. Client creates Polycon**
**2. Polycon requests resolution from Registry**
**3. Registry delegates to Factory**
**4. Factory creates Concrete Implementation**
**5. Concrete Implementation is returned to Client**

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Title
    title[("Polycons Framework Architecture")]:::title
    
    subgraph Core["Core Layer"]
        Registry["Factory Registry"]:::core
        TypeSystem["Type Resolution System"]:::core
        TreeManager["Construct Tree Manager"]:::core
        
        Registry --> TypeSystem
        TypeSystem --> TreeManager
    end
    
    subgraph Factories["Factory Layer"]
        IFactory["IPolyconFactory Interface"]:::factory
        ConcreteFactory["Concrete Factory Implementation"]:::factory
        
        IFactory --> ConcreteFactory
    end
    
    subgraph Integration["Integration Layer"]
        AWSCDK["AWS CDK"]:::external
        CDKTF["CDK for Terraform"]:::external
        CDK8S["CDK for Kubernetes"]:::external
    end
    
    subgraph Implementation["Implementation Layer"]
        PolyconBase["Polycon Base Class"]:::impl
        ConcreteImpl["Concrete Implementation"]:::impl
        
        PolyconBase --> ConcreteImpl
    end
    
    %% Relationships
    Client(("Client Code")):::client
    Client -.-> Registry
    Registry --> IFactory
    IFactory --> ConcreteImpl
    ConcreteImpl --> AWSCDK
    ConcreteImpl --> CDKTF
    ConcreteImpl --> CDK8S
    
    %% Click Events
    click IFactory "https://github.com/winglang/polycons/blob/main/src/polycon-factory.ts"
    click Registry "https://github.com/winglang/polycons/blob/main/src/internal.ts"
    click ConcreteFactory "https://github.com/winglang/polycons/blob/main/test/polycon-factory.test.ts"
    
    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef factory fill:#e67e22,stroke:#d35400,color:white
    classDef external fill:#2ecc71,stroke:#27ae60,color:white
    classDef impl fill:#9b59b6,stroke:#8e44ad,color:white
    classDef client fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef title fill:none,stroke:none
    
    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Factory Components"]:::factory
        L3["External Systems"]:::external
        L4["Implementations"]:::impl
        L5["Client"]:::client
    end
```
