# codesplinta/busser architecture

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

- Interactive diagram: https://gitdiagram.com/codesplinta/busser
- Repository: https://github.com/codesplinta/busser

## Overview

##### Main Components Overview

a) Core Event System
- Event Bus (Central messaging system)
- Event Emitters
- Event Subscribers

b) State Management Layer
- Storage Handlers (Browser Storage, URL State)
- State Primitives (List, Count, Property, Composite)
- Signals Integration

c) Hook Categories
- Core Hooks (useBus, useOn)
- State Hooks (useList, useCount, etc.)
- Utility Hooks (useOutsideClick, useControlKeysPress, etc.)

##### Key Relationships

- Event flow between components using the event bus
- State updates and their propagation
- Integration points with external storage (Browser Storage, URL)
- Signal-based reactivity paths

##### Architectural Patterns

- Cascade Broadcasts pattern
- Shadow Events system
- Publisher/Subscriber model
- State primitive transformations

##### Implementation Details

Technical aspects:
**[Event Bus Core]**
**↓**
**[State Primitives] → [Signal Variants]**
**↓**
**[Storage Adapters] → [Browser Storage/URL]**
**↓**
**[Utility Hooks]**

##### Component Relationships

Key interactions:
**useBus() ←→ Event Bus Core**
**useList()/useCount() ←→ State Primitives**
**useBrowserStorage() ←→ Storage Adapters**
**useControlKeysPress() ←→ Utility Layer**

##### Data Flow

Following flows:
**Component A → Event Bus → Component B**
**State Update → Signal → UI Update**
**Browser Storage → State → Component**

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        L1[Core Event System]:::core
        L2[State Management]:::state
        L3[Storage Components]:::storage
        L4[Utility Components]:::utility
        L5[Data Fetching]:::fetcher
        L6[Routing Components]:::routing
    end

    subgraph "Core Event System"
        EventBus["Event Bus Core"]:::core
        EventEmitters["Event Emitters"]:::core
        EventSubscribers["Event Subscribers"]:::core
        
        EventBus --> EventEmitters
        EventBus --> EventSubscribers
    end

    subgraph "State Management Layer"
        StatePrimitives["State Primitives"]:::state
        SignalIntegration["Signal Integration"]:::state
        
        subgraph "State Types"
            List["List State"]:::state
            Count["Count State"]:::state
            Composite["Composite State"]:::state
            Shared["Shared State"]:::state
        end
        
        StatePrimitives --> List
        StatePrimitives --> Count
        StatePrimitives --> Composite
        StatePrimitives --> Shared
        StatePrimitives <--> SignalIntegration
    end

    subgraph "Storage Layer"
        StorageHandlers["Storage Handlers"]:::storage
        BrowserStorage["Browser Storage"]:::storage
        URLState["URL State"]:::storage
        
        StorageHandlers --> BrowserStorage
        StorageHandlers --> URLState
    end

    subgraph "Hook Categories"
        CoreHooks["Core Hooks"]:::core
        StateHooks["State Hooks"]:::state
        UtilityHooks["Utility Hooks"]:::utility
        RoutingHooks["Routing Hooks"]:::routing
        
        CoreHooks --> |useBus/useOn| EventBus
        StateHooks --> StatePrimitives
        UtilityHooks --> EventBus
    end

    subgraph "Data Layer"
        DataFetcher["Data Fetcher"]:::fetcher
        CommonUtils["Common Utilities"]:::utility
        TypeDefs["Type Definitions"]:::utility
    end

    EventBus --> StatePrimitives
    StorageHandlers --> StatePrimitives
    DataFetcher --> EventBus

    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef state fill:#4CAF50,stroke:#2E7D32,color:white
    classDef storage fill:#FF9800,stroke:#EF6C00,color:white
    classDef utility fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef fetcher fill:#F44336,stroke:#C62828,color:white
    classDef routing fill:#795548,stroke:#4E342E,color:white

    click EventBus "https://github.com/codesplinta/busser/blob/main/src/eventbus/core.jsx"
    click CoreHooks "https://github.com/codesplinta/busser/blob/main/src/test/useBus.spec.jsx"
    click List "https://github.com/codesplinta/busser/blob/main/src/test/useList.spec.jsx"
    click Count "https://github.com/codesplinta/busser/blob/main/src/test/useCount.spec.jsx"
    click Composite "https://github.com/codesplinta/busser/blob/main/src/test/useComposite.spec.jsx"
    click Shared "https://github.com/codesplinta/busser/blob/main/src/test/useSharedState.spec.jsx"
    click BrowserStorage "https://github.com/codesplinta/busser/blob/main/src/test/useBrowserStorage.spec.jsx"
    click URLState "https://github.com/codesplinta/busser/blob/main/src/test/useSearchParamsState.spec.jsx"
    click SignalIntegration "https://github.com/codesplinta/busser/blob/main/src/test/useSignalsState.spec.jsx"
    click UtilityHooks "https://github.com/codesplinta/busser/blob/main/src/test/useOutsideClick.spec.jsx"
    click RoutingHooks "https://github.com/codesplinta/busser/blob/main/src/test/useRoutingMonitor.spec.jsx"
    click DataFetcher "https://github.com/codesplinta/busser/blob/main/src/fetcher/core.jsx"
    click CommonUtils "https://github.com/codesplinta/busser/blob/main/src/common/index.js"
    click TypeDefs "https://github.com/codesplinta/busser/blob/main/types/index.d.ts"
```
