# fabian-hiller/valibot architecture

> Architecture diagram of the GitHub repository fabian-hiller/valibot, 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/fabian-hiller/valibot
- Repository: https://github.com/fabian-hiller/valibot

## Overview

##### Main components
a. Core Library (“library” folder):
- Contains the main functionality (action definitions, schema validators, methods, types, storages, utility functions, and tests).
- Organized into subdirectories for “actions” (which define validations and transformations), “schemas” (the core validation definitions for various data types), “methods” (helper utilities for processing data or configurations), “storages” (for managing global or schema-level messages and configuration), and “types” (TypeScript definitions shared across the project).
b. Codemod Tools (“codemod” folder):
- Provides migration scripts and tests (for example, migrating to a new version v0.31.0) which likely use or interface with the core library.
c. Plugins/Extensions (“packages” folder):
- Contains additional packages such as “i18n” (for internationalization support) and “to-json-schema” (for converting library definitions into JSON Schema). These are extensions that build on top of or interact with the core library.
d. Documentation Website (“website” folder):
- Houses the code for a full-featured documentation website, including API route definitions, components, MDX pages, and build/deployment configurations (using Vite, Tailwind, etc.).
e. Infrastructure & CI/CD:
- Directories and files such as .github, workflows (ci.yml, publish.yml), pnpm configurations, and linting/formatting files support the build, testing, deployment, and code quality aspects.

##### Relationships and interactions
- The Core Library is the “heart” of the system. Its components (actions, schemas, methods, etc.) are used directly by the codemod tools and the extension packages.
- The Codemod tools provide migration scripts that interact with library APIs and use configurations from the “grit” folder.
- The Plugins (i18n, to-json-schema) wrap or interface with the core library and offer additional functionality like locales or schema conversion.
- The Documentation Website pulls content from the library’s API (as evidenced by the numerous pages under “website/src/routes/api/…” that document the actions, schemas, and types) to provide an interactive reference and guides.
- The CI/CD pipelines (GitHub Actions, configuration files, etc.) tie all components together by automatically testing, building, and deploying the library, codemod, plugins, and website.

##### Architectural patterns & design principles
- Modularity: Each high-level component (core library, codemod, packages, website) is self-contained but shares common interfaces (via Typescript types and inter-package dependencies).
- Separation of concerns: The validation logic, migration tooling, and documentation are clearly separated into distinct folders.
- Monorepo management: The overall file structure (and tools like pnpm-workspace.yaml) point to a monorepo setup—a design that favors inter-component reusability and centralized dependency management.
- Extensive unit and integration testing: With tests included in nearly every subdirectory (for actions, schemas, methods, etc.), the design emphasizes correctness and maintainability.

##### Technologies and frameworks to note
- TypeScript is the primary language used (as shown by .ts and .tsx file extensions).
- Build tools such as TSup, Vite, and Tsup configurations for the library and website.
- GitHub Actions for CI/CD (with custom workflows in the .github directory).
- ESLint, Prettier, and other code-quality and formatting configurations.
- Documentation components likely use MDX and React (components are in .tsx files) with a modern frontend build pipeline.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Library Subgraph
    subgraph "Core Library (Validation Engine)"
        direction TB
        A["Core Library"]:::library
        A1["Actions"]:::component
        A2["Schemas"]:::component
        A3["Methods"]:::component
        A4["Storages"]:::component
        A5["Types"]:::component
        A6["Utils"]:::component
    end

    %% Other Main Components
    B["Codemod Tools (Migration Scripts)"]:::codemod
    subgraph "Plugins/Extensions"
        direction TB
        C["i18n Plugin"]:::plugin
        D["to-json-schema Extension"]:::plugin
    end
    E["Documentation Website"]:::website
    subgraph "Infrastructure & CI/CD"
        direction TB
        F["GitHub Actions & Workflows"]:::infrastructure
        G["Monorepo & Package Management"]:::infrastructure
    end

    %% Relationships
    B -->|"uses"| A
    C -->|"extends"| A
    D -->|"extends"| A
    E -->|"consumes"| A
    F -->|"deploys"| A
    F -->|"deploys"| B
    F -->|"deploys"| C
    F -->|"deploys"| D
    F -->|"deploys"| E
    G -->|"manages"| A
    G -->|"manages"| B
    G -->|"manages"| C
    G -->|"manages"| D
    G -->|"manages"| E

    %% Click Events for Core Library and Its Submodules
    click A "https://github.com/fabian-hiller/valibot/tree/main/library/"
    click A1 "https://github.com/fabian-hiller/valibot/tree/main/library/src/actions"
    click A2 "https://github.com/fabian-hiller/valibot/tree/main/library/src/schemas"
    click A3 "https://github.com/fabian-hiller/valibot/tree/main/library/src/methods"
    click A4 "https://github.com/fabian-hiller/valibot/tree/main/library/src/storages"
    click A5 "https://github.com/fabian-hiller/valibot/tree/main/library/src/types"
    click A6 "https://github.com/fabian-hiller/valibot/tree/main/library/src/utils"

    %% Click Events for Other Components
    click B "https://github.com/fabian-hiller/valibot/tree/main/codemod/"
    click C "https://github.com/fabian-hiller/valibot/tree/main/packages/i18n"
    click D "https://github.com/fabian-hiller/valibot/tree/main/packages/to-json-schema"
    click E "https://github.com/fabian-hiller/valibot/tree/main/website/"
    click F "https://github.com/fabian-hiller/valibot/tree/main/.github/"
    click G "https://github.com/fabian-hiller/valibot/blob/main/pnpm-workspace.yaml"

    %% Styles and Colors
    classDef library fill:#ffe6e6,stroke:#ff0000,stroke-width:2px;
    classDef codemod fill:#e6ffe6,stroke:#00aa00,stroke-width:2px;
    classDef plugin fill:#e6e6ff,stroke:#0000ff,stroke-width:2px;
    classDef website fill:#ffffe6,stroke:#aaaa00,stroke-width:2px;
    classDef infrastructure fill:#e6ffff,stroke:#00aaaa,stroke-width:2px;
    classDef component fill:#f0f0f0,stroke:#333,stroke-width:1px;
```
