# max-woolf/xyflow architecture

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

- Interactive diagram: https://gitdiagram.com/max-woolf/xyflow
- Repository: https://github.com/max-woolf/xyflow

## Overview

##### Project type and purpose
- It’s an open-source monorepo housing three npm packages plus a legacy v11 branch:
- @xyflow/system (shared core logic & utilities)
- @xyflow/react (React-specific wrapper & hooks)
- @xyflow/svelte (Svelte-specific wrapper & actions)
- (v11 branch: older reactflow)
- Also includes example apps (React, Svelte, Astro), E2E tests (Playwright), CI/CD on GitHub Actions, and shared tooling (ESLint, Rollup, tsconfig).

##### File structure
- Top-level: packages/, examples/, tests/, tooling/, .github/workflows/, pnpm-workspace.yaml
- packages/system: core algorithms (edges, nodes, drag, pan/zoom), shared types, styles
- packages/react: React components, hooks, contexts, store, container logic
- packages/svelte: Svelte components, actions, store, plugins
- examples/*: Minimal demo apps showing how to consume the libraries
- tests/playwright: Cross-framework end-to-end tests
- tooling/*: Shared ESLint, Rollup, PostCSS, and TypeScript configurations
- CI workflows: build, lint, test, release

##### README insights
- Describes the four packages and their relationships
- Mentions changesets for versioning & release
- Emphasis on usage, installation, and community support

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Monorepo Orchestration"
        PNPM["pnpm-workspace.yaml"]:::monorepo
    end

    subgraph "Shared Tooling"
        ESLINT["Shared ESLint Config"]:::tooling
        ROLLUP["Shared Rollup Config"]:::tooling
        POSTCSS["Shared PostCSS Config"]:::tooling
        TSC["Shared TypeScript Configs"]:::tooling
    end

    PNPM -->|orchestrates| ESLINT
    PNPM -->|orchestrates| ROLLUP
    PNPM -->|orchestrates| POSTCSS
    PNPM -->|orchestrates| TSC

    subgraph "Core Package"
        CORE["@xyflow/system"]:::core
    end

    ESLINT -->|applies to| CORE
    ROLLUP -->|applies to| CORE
    POSTCSS -->|applies to| CORE
    TSC -->|applies to| CORE
    PNPM -->|manages| CORE

    subgraph "Adapter Packages"
        REACT["@xyflow/react"]:::react
        SVELTE["@xyflow/svelte"]:::svelte
    end

    CORE -->|provides logic for| REACT
    CORE -->|provides logic for| SVELTE
    ESLINT -->|applies to| REACT
    ROLLUP -->|applies to| REACT
    TSC -->|applies to| REACT
    ESLINT -->|applies to| SVELTE
    ROLLUP -->|applies to| SVELTE
    TSC -->|applies to| SVELTE
    PNPM -->|manages| REACT
    PNPM -->|manages| SVELTE

    subgraph "Example Applications"
        REACT_EX["React Example App"]:::example
        SVELTE_EX["Svelte Example App"]:::example
        ASTRO_EX["Astro Example App"]:::example
    end

    REACT -->|consumed by| REACT_EX
    SVELTE -->|consumed by| SVELTE_EX
    REACT -->|consumed by| ASTRO_EX
    PNPM -->|manages| REACT_EX
    PNPM -->|manages| SVELTE_EX
    PNPM -->|manages| ASTRO_EX

    subgraph "E2E Testing"
        TESTS["Cross-framework E2E Tests (Playwright)"]:::example
    end

    REACT_EX -->|tested by| TESTS
    SVELTE_EX -->|tested by| TESTS
    ASTRO_EX -->|tested by| TESTS
    PNPM -->|manages| TESTS

    subgraph "CI/CD Pipeline"
        CI["CI/CD Workflows (GitHub Actions)"]:::ci
    end

    CORE -->|built by| CI
    REACT -->|built by| CI
    SVELTE -->|built by| CI
    REACT_EX -->|deployed/tested by| CI
    SVELTE_EX -->|deployed/tested by| CI
    ASTRO_EX -->|deployed/tested by| CI
    TESTS -->|executed by| CI

    subgraph "Package Distribution"
        NPM["NPM Registry"]:::registry
    end

    CI -->|published to| NPM

    click CORE "https://github.com/max-woolf/xyflow/tree/main/packages/system"
    click REACT "https://github.com/max-woolf/xyflow/tree/main/packages/react"
    click SVELTE "https://github.com/max-woolf/xyflow/tree/main/packages/svelte"
    click ASTRO_EX "https://github.com/max-woolf/xyflow/tree/main/examples/astro-xyflow"
    click REACT_EX "https://github.com/max-woolf/xyflow/tree/main/examples/react"
    click SVELTE_EX "https://github.com/max-woolf/xyflow/tree/main/examples/svelte"
    click TESTS "https://github.com/max-woolf/xyflow/tree/main/tests/playwright"
    click CI "https://github.com/max-woolf/xyflow/tree/main/.github/workflows"
    click PNPM "https://github.com/max-woolf/xyflow/blob/main/pnpm-workspace.yaml"
    click ESLINT "https://github.com/max-woolf/xyflow/tree/main/tooling/eslint-config"
    click ROLLUP "https://github.com/max-woolf/xyflow/tree/main/tooling/rollup-config"
    click POSTCSS "https://github.com/max-woolf/xyflow/tree/main/tooling/postcss-config"
    click TSC "https://github.com/max-woolf/xyflow/tree/main/tooling/tsconfig"

    classDef core fill:#D0E8FF,stroke:#1E90FF,color:#000
    classDef react fill:#E0F8E0,stroke:#3CB371,color:#000
    classDef svelte fill:#FFE8C0,stroke:#FFA500,color:#000
    classDef example fill:#F0F0F0,stroke:#A0A0A0,color:#000
    classDef ci fill:#F4E8FF,stroke:#9370DB,color:#000
    classDef registry fill:#FFF0F0,stroke:#FF69B4,color:#000
    classDef tooling fill:#FFF8DC,stroke:#DAA520,color:#000
    classDef monorepo fill:#F5F5F5,stroke:#808080,color:#000
```
