# plusnew/core architecture

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

- Interactive diagram: https://gitdiagram.com/plusnew/core
- Repository: https://github.com/plusnew/core

## Overview

##### Main Components Structure

a) Core Framework Components:
- Component System
- Store Management
- Context API
- Reconciliation Engine
- Instance Management

b) Helper Components Layer:
- Portal (PortalEntry/PortalExit)
- Async Component
- Try Component
- ElementLifecycle
- Idle Component

##### Key Architectural Flows

a) Rendering Pipeline:
**Component Definition → Instance Creation → Reconciliation → DOM Updates**

b) State Management Flow:
**Store → Reducer → State Update → Component Re-render**

##### Detailed Component Breakdown

a) Instance Management:
- Root Instance
- Component Instance
- Array Instance
- Host Instance
- Text Instance
- Fragment Instance
- Placeholder Instance
- Shallow Instance

b) Reconciliation System:
- Instance Reconciler
- Type-specific Reconcilers
- Element Type Checker

##### Implementation Details

Technical aspects:

- TypeScript integration
- Component Factory patterns
- Store/Reducer pattern
- Context API implementation
- Driver interface for DOM manipulation

##### Important Relationships to Highlight

- Component to Instance relationship
- Store to Component updates
- Context Provider/Consumer patterns
- Portal entry/exit connections
- Async component promise flow

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        L1[Core Components]:::core
        L2[Helper Components]:::helper
        L3[Instance Types]:::instance
        L4[Technical Implementation]:::tech
        L5[Data Flow]-- Flow -->L6
    end

    subgraph "Core Framework"
        CS["Component System"]:::core
        SM["Store Management"]:::core
        CA["Context API"]:::core
        RE["Reconciliation Engine"]:::core
        IM["Instance Management"]:::core
    end

    subgraph "Helper Components"
        Portal["Portal Entry/Exit"]:::helper
        Async["Async Component"]:::helper
        Try["Try Component"]:::helper
        EL["ElementLifecycle"]:::helper
        Idle["Idle Component"]:::helper
    end

    subgraph "Instance Types"
        RI["Root Instance"]:::instance
        CI["Component Instance"]:::instance
        AI["Array Instance"]:::instance
        HI["Host Instance"]:::instance
        TI["Text Instance"]:::instance
        FI["Fragment Instance"]:::instance
        PI["Placeholder Instance"]:::instance
        SI["Shallow Instance"]:::instance
    end

    subgraph "Technical Layer"
        ETC["Element Type Checker"]:::tech
        DI["Driver Interface"]:::tech
        CF["Component Factory"]:::tech
        OF["Observer Factory"]:::tech
        CAE["Core Abstract Elements"]:::tech
    end

    CS --> IM
    SM --> CS
    CA --> CS
    RE --> IM
    IM --> RE

    CS --> Portal
    CS --> Async
    CS --> Try
    CS --> EL
    CS --> Idle

    IM --> RI
    IM --> CI
    IM --> AI
    IM --> HI
    IM --> TI
    IM --> FI
    IM --> PI
    IM --> SI

    RE --> ETC
    CS --> CF
    CF --> OF
    CF --> CAE
    DI --> RE

    classDef core fill:#a8d1f0
    classDef helper fill:#90EE90
    classDef instance fill:#FFE5B4
    classDef tech fill:#E6E6FA
    
    click CS "https://github.com/plusnew/core/blob/master/src/components/factory.ts"
    click SM "https://github.com/plusnew/core/blob/master/src/util/store.ts"
    click CA "https://github.com/plusnew/core/blob/master/src/components/context.tsx"
    click RE "https://github.com/plusnew/core/blob/master/src/instances/reconciler.ts"
    click IM "https://github.com/plusnew/core/blob/master/src/instances/factory.ts"
    click Portal "https://github.com/plusnew/core/blob/master/src/components/portal.tsx"
    click Async "https://github.com/plusnew/core/blob/master/src/components/Async.tsx"
    click Try "https://github.com/plusnew/core/blob/master/src/components/Try.tsx"
    click RI "https://github.com/plusnew/core/blob/master/src/instances/types/Root/Instance.ts"
    click CI "https://github.com/plusnew/core/blob/master/src/instances/types/Component/Instance.ts"
    click AI "https://github.com/plusnew/core/blob/master/src/instances/types/Array/Instance.ts"
    click HI "https://github.com/plusnew/core/blob/master/src/instances/types/Host/Instance.ts"
    click TI "https://github.com/plusnew/core/blob/master/src/instances/types/Text/Instance.ts"
    click FI "https://github.com/plusnew/core/blob/master/src/instances/types/Fragment/Instance.ts"
    click PI "https://github.com/plusnew/core/blob/master/src/instances/types/Placeholder/Instance.ts"
    click SI "https://github.com/plusnew/core/blob/master/src/instances/types/Shallow/Instance.ts"
    click ETC "https://github.com/plusnew/core/blob/master/src/util/elementTypeChecker.ts"
    click DI "https://github.com/plusnew/core/blob/master/src/interfaces/driver.ts"
    click CF "https://github.com/plusnew/core/blob/master/src/components/factory.ts"
    click OF "https://github.com/plusnew/core/blob/master/src/components/observerFactory.ts"
    click CAE "https://github.com/plusnew/core/blob/master/src/PlusnewAbstractElement/index.ts"
```
