# artalar/reatom architecture

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

- Interactive diagram: https://gitdiagram.com/artalar/reatom
- Repository: https://github.com/artalar/reatom

## Overview

##### Main components
- Central Core Modules: At the heart of the system are the core state primitives. Note packages such as “packages/core”, “packages/core-v1”, “packages/core-v2”, and “packages/primitives”. These modules provide the basic “atom”, “action”, and “ctx” functionality.
- Extended Ecosystem Packages: Surrounding the core are packages that extend its functionality. Examples include:
– Async management (packages/async)
– Effects (packages/effects)
– Hooks (packages/hooks), Forms (packages/form, packages/form-web), Logger (packages/logger)
– Integration layers (packages/npm-react, packages/npm-vue, packages/npm-solid-js, packages/npm-svelte, etc.)
– Other utilities like persist, lens, url, and web-fetch.
- Developer Tools: The “packages/devtools” module gives insights into state changes, debugging, and visualizations.
- CI/CD and Build Infrastructure: Look at the .github directory (with GitHub workflows for linting, testing, releasing, etc.), husky (for commit-message hooks), and turbo.json, which indicate mono repo management and automated publishing.
- Documentation and Examples: The “docs” and “examples” folders provide user guidance and demonstrations. The “docs” folder even includes an Astro-based site that shows how to use various packages and offers an interactive developer experience.

##### Relationships and data flow
- Ecosystem packages extend or decorate the core functionality using middleware techniques (for caching, debouncing, aborting requests, etc.) as explained in the advanced example from the README.
- The extended packages (e.g., async, hooks, devtools) are built on top of the core, so model them as layered components above the core.
- Dependency from the integration/layer packages (like npm-react) back into the core but also branching out to external UI frameworks (for example, React, Vue, SolidJS) as usage points.
- CI/CD and tooling parts interact with the entire codebase to ensure code quality, while the documentation and examples both serve as an external user-facing layer that explains how to integrate with the system.

##### Architectural patterns and design principles
- Use a layered approach: Base Layer (core primitives), Middle Layer (extended functionality such as async, effects, logger, hooks), and Integration/Consumer Layer (framework adapters and examples).
- Dependency inversion is used implicitly since the integration (e.g., React adapters) and even testing (using the testing package) are “plugged in” on top of the universal core.

##### Relevant technologies and frameworks
- That the project uses TypeScript (based on tsconfig files throughout), a robust testing scheme (using vitest, jest in some test files), and modern build/CD tools (turbo, GitHub workflows, ESLint, Prettier configurations).
- That the documentation is built with Astro and that there are multiple front-end examples using Vite, Next.js, and plain React.

- Use clear labels: Each node (for example “Core (v1, v2)”, “Async”, “Devtools”, “Hooks”, “Logger”, “UI Adapters”) should be clearly named.

##### Don’t overcomplicate

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Layer
    subgraph "Core Layer"
        coreCore["Core (packages/core)"]:::core
        coreV1["Core v1 (packages/core-v1)"]:::core
        coreV2["Core v2 (packages/core-v2)"]:::core
        corePrimitives["Primitives (packages/primitives)"]:::core
    end

    %% Ecosystem Packages Layer
    subgraph "Ecosystem Packages"
        async["Async (packages/async)"]:::ecosystem
        effects["Effects (packages/effects)"]:::ecosystem
        hooks["Hooks (packages/hooks)"]:::ecosystem
        subgraph "Forms"
            form["Form (packages/form)"]:::ecosystem
            formWeb["Form-Web (packages/form-web)"]:::ecosystem
        end
        logger["Logger (packages/logger)"]:::ecosystem
        subgraph "Other Utilities"
            persist["Persist (packages/persist)"]:::ecosystem
            persistWeb["Persist-Web Storage (packages/persist-web-storage)"]:::ecosystem
            lens["Lens (packages/lens)"]:::ecosystem
            url["URL (packages/url)"]:::ecosystem
            webFetch["Web Fetch (packages/web-fetch)"]:::ecosystem
        end
        subgraph "UI Adapters"
            reactIntegration["React Integration (packages/npm-react)"]:::integration
            vueIntegration["Vue Integration (packages/npm-vue)"]:::integration
            solidJSIntegration["SolidJS Integration (packages/npm-solid-js)"]:::integration
            svelteIntegration["Svelte Integration (packages/npm-svelte)"]:::integration
        end
    end

    %% Developer Tools
    devtools["Devtools (packages/devtools)"]:::tools

    %% Documentation and Examples
    docs["Docs (docs)"]:::docs
    examples["Examples (examples)"]:::docs

    %% CI/CD and Build Infrastructure
    subgraph "CI/CD Infrastructure"
        githubCI["GitHub Workflows (.github)"]:::ci
        huskyCI["Husky Hooks (.husky)"]:::ci
        monoRepoCI["Mono Repo Config (turbo.json & release-please-manifest.json)"]:::ci
    end

    %% External UI Frameworks
    subgraph "External Frameworks"
        reactFramework["React Framework"]:::integration
        vueFramework["Vue Framework"]:::integration
        solidJSFramework["SolidJS Framework"]:::integration
        svelteFramework["Svelte Framework"]:::integration
    end

    %% Relationships: Core to Ecosystem Packages
    coreCore -->|"provides"| async
    coreCore -->|"provides"| effects
    coreCore -->|"provides"| hooks
    coreCore -->|"provides"| form
    coreCore -->|"provides"| formWeb
    coreCore -->|"provides"| logger
    coreCore -->|"provides"| persist
    coreCore -->|"provides"| lens
    coreCore -->|"provides"| url
    coreCore -->|"provides"| webFetch

    %% Relationships: Core to UI Adapters and Tools
    coreCore -->|"integrated_with"| reactIntegration
    coreCore -->|"integrated_with"| vueIntegration
    coreCore -->|"integrated_with"| solidJSIntegration
    coreCore -->|"integrated_with"| svelteIntegration
    coreCore -->|"observed_by"| devtools

    %% Relationships: Core to Documentation
    coreCore -->|"demonstrated_in"| docs
    coreCore -->|"demonstrated_in"| examples

    %% Relationships: UI Adapters to External Frameworks
    reactIntegration -->|"hooks_into"| reactFramework
    vueIntegration -->|"hooks_into"| vueFramework
    solidJSIntegration -->|"hooks_into"| solidJSFramework
    svelteIntegration -->|"hooks_into"| svelteFramework

    %% Relationships: CI/CD interacting with core (monitoring the entire codebase)
    githubCI ---|"monitors"| coreCore
    huskyCI ---|"enforces"| coreCore
    monoRepoCI ---|"manages"| coreCore

    %% Click Events for Core Modules
    click coreCore "https://github.com/artalar/reatom/tree/v3/packages/core"
    click coreV1 "https://github.com/artalar/reatom/tree/v3/packages/core-v1"
    click coreV2 "https://github.com/artalar/reatom/tree/v3/packages/core-v2"
    click corePrimitives "https://github.com/artalar/reatom/tree/v3/packages/primitives"

    %% Click Events for Ecosystem Packages
    click async "https://github.com/artalar/reatom/tree/v3/packages/async"
    click effects "https://github.com/artalar/reatom/tree/v3/packages/effects"
    click hooks "https://github.com/artalar/reatom/tree/v3/packages/hooks"
    click form "https://github.com/artalar/reatom/tree/v3/packages/form"
    click formWeb "https://github.com/artalar/reatom/tree/v3/packages/form-web"
    click logger "https://github.com/artalar/reatom/tree/v3/packages/logger"

    %% Click Events for Other Utilities
    click persist "https://github.com/artalar/reatom/tree/v3/packages/persist"
    click persistWeb "https://github.com/artalar/reatom/tree/v3/packages/persist-web-storage"
    click lens "https://github.com/artalar/reatom/tree/v3/packages/lens"
    click url "https://github.com/artalar/reatom/tree/v3/packages/url"
    click webFetch "https://github.com/artalar/reatom/tree/v3/packages/web-fetch"

    %% Click Events for UI Adapters
    click reactIntegration "https://github.com/artalar/reatom/tree/v3/packages/npm-react"
    click vueIntegration "https://github.com/artalar/reatom/tree/v3/packages/npm-vue"
    click solidJSIntegration "https://github.com/artalar/reatom/tree/v3/packages/npm-solid-js"
    click svelteIntegration "https://github.com/artalar/reatom/tree/v3/packages/npm-svelte"

    %% Click Event for Developer Tools
    click devtools "https://github.com/artalar/reatom/tree/v3/packages/devtools"

    %% Click Events for CI/CD Infrastructure
    click githubCI "https://github.com/artalar/reatom/blob/v3/.github"
    click huskyCI "https://github.com/artalar/reatom/blob/v3/.husky"
    click monoRepoCI "https://github.com/artalar/reatom/blob/v3/turbo.json"

    %% Click Events for Documentation and Examples
    click docs "https://github.com/artalar/reatom/tree/v3/docs"
    click examples "https://github.com/artalar/reatom/tree/v3/examples"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef ecosystem fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef integration fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef tools fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef ci fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef docs fill:#FFDEAD,stroke:#000,stroke-width:2px;
```
