# z-js-framework/z-js architecture

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

- Interactive diagram: https://gitdiagram.com/z-js-framework/z-js
- Repository: https://github.com/z-js-framework/z-js

## Overview

##### Main Components Identification

The system consists of several core modules:
- Rendering Engine
- Routing System
- State Management
- Component System
- Hooks System
- Fetch Module
- Forms Module
- Utilities

**┌─────────────────────────────────────────────────────┐**
- Core Utilities                      │
- (utilities.js - Basic helper functions)          │
- ┘

**┌─────────────────────────────────────────────────────┐**
- Rendering Engine                       │
- ┌─────────────┐  ┌──────────┐  ┌───────────────┐  │
- HTML      │  │   CSS    │  │  Morphdom     │  │
- Templating │  │  in JS   │  │  Integration  │  │
- ┘  └──────────┘  └───────────────┘  │
- ┘

**┌─────────────────────────────────────────────────────┐**
- State Management                       │
- ┌─────────────┐  ┌──────────┐  ┌───────────────┐  │
- Component  │  │  Global  │  │ State Radio   │  │
- State    │  │  Store   │  │  Integration  │  │
- ┘  └──────────┘  └───────────────┘  │
- ┘

**┌─────────────────────────────────────────────────────┐**
- Feature Modules                      │
- ┌─────────────┐  ┌──────────┐  ┌───────────────┐  │
- Router    │  │  Hooks   │  │    Forms      │  │
- ┘  └──────────┘  └───────────────┘  │
- ┘

**┌─────────────────────────────────────────────────────┐**
- Z-Fetch API                        │
- (HTTP Methods, Configuration, Error Handling)    │
- ┘

- Blue: Data flow
- Green: State updates
- Red: Error propagation
- Orange: Event handling

##### Important Notes

- Component relationships
- State flow patterns
- Event propagation
- Error handling paths
- Integration points with external libraries (like Morphdom)

##### Implementation Details

- Rectangles: Core modules
- Rounded rectangles: Features
- Hexagons: Integration points
- Circles: State stores
- Diamonds: Decision points in data flow

- Simplicity in design
- Direct DOM manipulation
- Template literal-based components
- Built-in state management
- Efficient routing system
- Integrated fetch capabilities

This system design will help developers understand how Z.Js Framework's components work together to create a cohesive frontend development experience while maintaining its "low mental overhead" philosophy.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph API
        ZFetch["Z-Fetch API"]:::api
        ZFetchCore["Core Fetch"]:::api
        ZFetchImpl["Z-Fetch Implementation"]:::api
        
        ZFetch --> ZFetchCore
        ZFetchCore --> ZFetchImpl
    end

    subgraph Features
        Router["Router"]:::feature
        Hooks["Hooks System"]:::feature
        Forms["Forms Module"]:::feature
        Suspense["Suspense Hook"]:::feature
        
        Hooks --> Suspense
    end

    subgraph StateManagement
        GlobalStore["Global Store"]:::state
        StateRadio["State Radio Integration"]:::state
        StoreCore["Store Core"]:::state
        
        GlobalStore --> StoreCore
        StateRadio --> StoreCore
    end

    subgraph RenderingEngine
        HTMLTemp["HTML Templating"]:::render
        CSSinJS["CSS in JS"]:::render
        Morphdom["Morphdom Integration"]:::render
        CoreRender["Core Rendering"]:::render
        
        HTMLTemp --> CoreRender
        CSSinJS --> CoreRender
        Morphdom --> CoreRender
    end

    subgraph Core
        Utils["Core Utilities"]:::core
    end

    %% Layer Connections
    ZFetch --> Router
    ZFetch --> Hooks
    Router --> GlobalStore
    Hooks --> GlobalStore
    Forms --> GlobalStore
    GlobalStore --> CoreRender
    StateRadio --> CoreRender
    CoreRender --> Utils

    %% Click Events
    click ZFetchCore "https://github.com/Z-Js-Framework/z-js/blob/main/src/fetch/index.js"
    click ZFetchImpl "https://github.com/Z-Js-Framework/z-js/tree/main/src/fetch/z-fetch/"
    click Router "https://github.com/Z-Js-Framework/z-js/blob/main/src/routing/router.js"
    click Hooks "https://github.com/Z-Js-Framework/z-js/blob/main/src/hooks/index.js"
    click Forms "https://github.com/Z-Js-Framework/z-js/blob/main/src/forms/forms.md"
    click Suspense "https://github.com/Z-Js-Framework/z-js/blob/main/src/hooks/useSuspense.js"
    click GlobalStore "https://github.com/Z-Js-Framework/z-js/blob/main/src/store/store.js"
    click StateRadio "https://github.com/Z-Js-Framework/z-js/blob/main/src/store/state-radio/lib/state-radio.js"
    click StoreCore "https://github.com/Z-Js-Framework/z-js/blob/main/src/store/index.js"
    click HTMLTemp "https://github.com/Z-Js-Framework/z-js/blob/main/src/rendering/html.js"
    click CSSinJS "https://github.com/Z-Js-Framework/z-js/blob/main/src/rendering/css.js"
    click Morphdom "https://github.com/Z-Js-Framework/z-js/blob/main/src/libs/morphdom-esm@v2.7.3.js"
    click CoreRender "https://github.com/Z-Js-Framework/z-js/blob/main/src/rendering/render-functions.js"
    click Utils "https://github.com/Z-Js-Framework/z-js/blob/main/src/utils/utilities.js"

    %% Styles
    classDef api fill:#f9f,stroke:#333,stroke-width:2px
    classDef feature fill:#aff,stroke:#333,stroke-width:2px
    classDef state fill:#ffa,stroke:#333,stroke-width:2px
    classDef render fill:#afa,stroke:#333,stroke-width:2px
    classDef core fill:#ddd,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        API[API Layer]:::api
        Feature[Feature Layer]:::feature
        State[State Layer]:::state
        Render[Rendering Layer]:::render
        CoreUtil[Core Layer]:::core
    end
```
