# stuburger/yafl architecture

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

- Interactive diagram: https://gitdiagram.com/stuburger/yafl
- Repository: https://github.com/stuburger/yafl

## Overview

##### Project type and purpose
- This is an open-source, monorepo-managed JavaScript/TypeScript library for building forms in React (“yafl”) plus a static documentation site (“docs”) built with Docusaurus.
- Key goals: publish a reusable UI library to npm/unpkg and provide an online documentation/demo site via GitHub Pages or a similar host.

##### File structure
- Top level: configuration files (.eslintrc, tsconfig.base.json, lerna.json), CI config (.travis.yml), package.json, LICENSE, README.
- packages/yafl: the core library (source in TSX, tests, Rollup config, tsconfig).
- packages/docs: a Docusaurus site (docs, blog, src pages, docusaurus.config.js, package.json).

##### Extract key architecture elements from README
- React-based form library with hook APIs (`useForm`, `useField`, etc.).
- Published artifacts: UMD + ES modules bundles, type definitions.
- Hosted demo/docs at https://stuburger.github.io/yafl/.
- CI via Travis CI, deployment to npm and GitHub Pages, bundle size badge via unpkg.

##### Main components
A. Monorepo root
- Lerna orchestrator
- Shared config: ESLint, Prettier, tsconfig.base.json
- CI pipeline (Travis CI)
B. Package “yafl” (Core Library)
- Source code (TSX under packages/yafl/src)
- Test suite (Jest under packages/yafl/__tests__)
- Rollup build (rollup.config.js → outputs UMD & ES modules)
- npm registry (publishes package.json → npm & unpkg)
C. Package “docs” (Documentation Site)
- Docusaurus source (packages/docs/docs, blog, src/pages)
- Build scripts (docusaurus.config.js)
- Static assets (packages/docs/static)
- Hosting (GitHub Pages or equivalent)
D. External services
- GitHub (repository hosting + Pages for docs)
- Travis CI (continual integration & deployment)
- npm registry / unpkg (library distribution)

##### Relationships and data flows
- Developers push code → GitHub
- GitHub triggers Travis CI
- Travis runs lint, tests (yafl), then build:
- Rollup compiles “yafl” → publish to npm/unpkg
- Docusaurus builds “docs” → deploy to GitHub Pages
- docs site imports the “yafl” package (locally during development or via npm in CI) to render live demos.

##### Architectural patterns & design principles
- Monorepo with Lerna for multi-package management
- Component library + static site generator (Docusaurus)
- CI-driven continuous deployment
- Separation of concerns: core API vs. documentation/presentation

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Monorepo Root
    subgraph "Monorepo Root"
        direction TB
        Lerna["Lerna Orchestrator"]:::internal
        ESLint["Shared ESLint Config"]:::internal
        Prettier["Shared Prettier Config"]:::internal
        TSConfig["Base TypeScript Config"]:::internal
        CIRoot["CI Pipeline (Travis CI)"]:::ci
    end

    %% Core Library Package
    subgraph "packages/yafl (Core Library)"
        direction TB
        YaflPkg["Package Manifest"]:::internal
        RollupCfg["Rollup Build Config"]:::internal
        SrcCode["Source Code (TSX)"]:::internal
        Tests["Test Suite (Jest)"]:::internal
    end

    %% Documentation Site Package
    subgraph "packages/docs (Documentation Site)"
        direction TB
        DocsPkg["Package Manifest"]:::internal
        DocusaurusCfg["Docusaurus Config"]:::internal
        Markdown["Markdown Content"]:::internal
        Blog["Blog Posts"]:::internal
        DemoPages["React Demo Pages & Components"]:::internal
        StaticAssets["Static Assets"]:::internal
    end

    %% External Services
    GitHub["GitHub (Repo Hosting)"]:::external
    TravisCI["Travis CI Service"]:::ci
    NpmUnpkg["npm / unpkg Registry"]:::external
    GHPages["GitHub Pages"]:::external

    %% Relationships
    GitHub -->|push event| TravisCI
    TravisCI -->|runs lint/test/build| CIRoot
    CIRoot -->|orchestrates packages| Lerna
    CIRoot -->|lint| ESLint
    CIRoot -->|format| Prettier
    CIRoot -->|type-check| TSConfig
    CIRoot -->|test yafl| Tests
    CIRoot -->|build yafl| RollupCfg
    CIRoot -->|build docs| DocusaurusCfg

    CIRoot -->|publish yafl| NpmUnpkg
    CIRoot -->|deploy docs| GHPages

    %% Package Links
    DocsPkg -->|depends on| YaflPkg
    DemoPages -->|import| SrcCode

    %% Click Events
    click Lerna "https://github.com/stuburger/yafl/blob/master/lerna.json"
    click ESLint "https://github.com/stuburger/yafl/blob/master/.eslintrc.js"
    click Prettier "https://github.com/stuburger/yafl/blob/master/.prettierrc"
    click TSConfig "https://github.com/stuburger/yafl/blob/master/tsconfig.base.json"
    click CIRoot "https://github.com/stuburger/yafl/blob/master/.travis.yml"

    click YaflPkg "https://github.com/stuburger/yafl/blob/master/packages/yafl/package.json"
    click RollupCfg "https://github.com/stuburger/yafl/blob/master/packages/yafl/rollup.config.js"
    click SrcCode "https://github.com/stuburger/yafl/tree/master/packages/yafl/src/"
    click Tests "https://github.com/stuburger/yafl/tree/master/packages/yafl/__tests__/"

    click DocsPkg "https://github.com/stuburger/yafl/blob/master/packages/docs/package.json"
    click DocusaurusCfg "https://github.com/stuburger/yafl/blob/master/packages/docs/docusaurus.config.js"
    click Markdown "https://github.com/stuburger/yafl/tree/master/packages/docs/docs/"
    click Blog "https://github.com/stuburger/yafl/tree/master/packages/docs/blog/"
    click DemoPages "https://github.com/stuburger/yafl/tree/master/packages/docs/src/"
    click StaticAssets "https://github.com/stuburger/yafl/tree/master/packages/docs/static/"

    %% Styles
    classDef internal fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef ci fill:#90EE90,stroke:#000,stroke-width:1px
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px
```
