# tanstack/form architecture

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

- Interactive diagram: https://gitdiagram.com/tanstack/form
- Repository: https://github.com/tanstack/form

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Core Layer:
- Form Core Engine (packages/form-core)
- Field API System
- Form API System
- Validation System

b) Framework Adapters:
- React Adapter
- Vue Adapter
- Angular Adapter
- Solid Adapter
- Lit Adapter

c) Schema Validator Adapters:
- Zod Adapter
- Yup Adapter
- Valibot Adapter

**┌─────────────────────────────────────────────┐**
- Framework Layer                │
- React  │  Vue  │  Angular │ Solid │  Lit  │
- ┤
- Adapter Layer                  │
- Framework Adapters  │  Schema Adapters   │
- ┤
- Core Layer                     │
- Form Core │ Field API │ Validation Core   │
- ┘

Following relationships:

##### Component Details

For each major component, include:
- Component name
- Key responsibilities
- Supported features (e.g., validation, field management)
- Integration points

##### Integration Points

Specific integration capabilities:
- Server-side validation support
- Framework-specific features
- Schema validator integration
- Form state management

##### Additional Elements

- Type system integration
- Server-side validation
- Framework-specific optimizations
- State management flow

- The modular architecture
- Framework independence of the core
- Type-safety throughout the system
- Validation integration flexibility
- State management patterns

Keep the abstraction level high enough to show the overall architecture while including sufficient detail to understand the component relationships and data flow.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef core fill:#e1f5fe,stroke:#01579b
    classDef framework fill:#e8f5e9,stroke:#1b5e20
    classDef validator fill:#fff3e0,stroke:#e65100
    classDef api fill:#f3e5f5,stroke:#4a148c
    
    %% Core Layer
    subgraph CoreLayer["Core Layer"]
        FormCore["Form Core Engine"]:::core
        FieldAPI["Field API System"]:::api
        FormAPI["Form API System"]:::api
        ValidationCore["Validation System"]:::core
    end

    %% Framework Adapters Layer
    subgraph AdapterLayer["Adapter Layer"]
        direction TB
        
        subgraph FrameworkAdapters["Framework Adapters"]
            ReactAdapter["React Adapter"]:::framework
            VueAdapter["Vue Adapter"]:::framework
            AngularAdapter["Angular Adapter"]:::framework
            SolidAdapter["Solid Adapter"]:::framework
            LitAdapter["Lit Adapter"]:::framework
        end

        subgraph SchemaAdapters["Schema Validator Adapters"]
            ZodAdapter["Zod Adapter"]:::validator
            YupAdapter["Yup Adapter"]:::validator
            ValibotAdapter["Valibot Adapter"]:::validator
        end
    end

    %% Framework Implementation Layer
    subgraph FrameworkLayer["Framework Layer"]
        ReactImpl["React Implementation"]:::framework
        VueImpl["Vue Implementation"]:::framework
        AngularImpl["Angular Implementation"]:::framework
        SolidImpl["Solid Implementation"]:::framework
        LitImpl["Lit Implementation"]:::framework
    end

    %% Relationships
    FormCore --> FieldAPI
    FormCore --> FormAPI
    FormCore --> ValidationCore

    %% Framework Adapter Relationships
    ReactAdapter <--> FormCore
    VueAdapter <--> FormCore
    AngularAdapter <--> FormCore
    SolidAdapter <--> FormCore
    LitAdapter <--> FormCore

    %% Schema Validator Relationships
    ZodAdapter --> ValidationCore
    YupAdapter --> ValidationCore
    ValibotAdapter --> ValidationCore

    %% Framework Implementation Relationships
    ReactImpl --> ReactAdapter
    VueImpl --> VueAdapter
    AngularImpl --> AngularAdapter
    SolidImpl --> SolidAdapter
    LitImpl --> LitAdapter

    %% Click Events
    click FormCore "https://github.com/TanStack/form/tree/main/packages/form-core"
    click FieldAPI "https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts"
    click FormAPI "https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts"
    click ValidationCore "https://github.com/TanStack/form/blob/main/packages/form-core/src/standardSchemaValidator.ts"
    
    click ReactAdapter "https://github.com/TanStack/form/tree/main/packages/react-form"
    click VueAdapter "https://github.com/TanStack/form/tree/main/packages/vue-form"
    click AngularAdapter "https://github.com/TanStack/form/tree/main/packages/angular-form"
    click SolidAdapter "https://github.com/TanStack/form/tree/main/packages/solid-form"
    click LitAdapter "https://github.com/TanStack/form/tree/main/packages/lit-form"
    
    click ZodAdapter "https://github.com/TanStack/form/tree/main/packages/zod-form-adapter"
    click YupAdapter "https://github.com/TanStack/form/tree/main/packages/yup-form-adapter"
    click ValibotAdapter "https://github.com/TanStack/form/tree/main/packages/valibot-form-adapter"
    
    click ReactImpl "https://github.com/TanStack/form/blob/main/packages/react-form/src/useForm.tsx"
    click VueImpl "https://github.com/TanStack/form/blob/main/packages/vue-form/src/useForm.tsx"
    click AngularImpl "https://github.com/TanStack/form/blob/main/packages/angular-form/src/inject-form.ts"
    click SolidImpl "https://github.com/TanStack/form/blob/main/packages/solid-form/src/createForm.tsx"
    click LitImpl "https://github.com/TanStack/form/blob/main/packages/lit-form/src/tanstack-form-controller.ts"
```
