# martiserra99/formity architecture

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

## Overview

##### Project Type and Purpose
- This is a monorepo that contains a form-building library meant to help developers create advanced multi-step forms. The README makes it clear that there are two main packages: the React components (@formity/react) and a system/core package (@formity/system) that likely includes the underlying logic, type definitions, and utilities.
- There is also an “apps/react” folder which serves as a demo or standalone application for testing and showcasing the form capabilities, including integration tests with Cypress.

##### File Structure
- Top-level directories and files like .github, changeset, turbo.json, and configuration files indicate that the repository has robust CI/CD and build tooling.
- The “packages” directory splits into two major packages – one for React and one for the form system. The structure under these directories is organized with source code, types, and utilities which point to a library style design.
- The “apps/react” directory shows a typical React application structure (with cypress, src, public, etc.) that is likely used to demonstrate the usage of the library components.
- Notice the presence of configuration files for Cypress, ESLint, Vite, Tailwind, etc., indicating that the project emphasizes modern front-end development patterns.

##### Main Components to Highlight
a. The Formity Mono Repo as the overarching project container.
b. The two core packages:
- @formity/react – contains UI components and integrations with common React patterns (e.g., react-hook-form, multi-step logic components, routing/navigation for forms).
- @formity/system – contains the underlying core logic, type definitions (schema, outputs, state, etc.), and various utilities that manage the form’s internal data flow and structure.
c. The Example/Demo Application:
- The “apps/react” directory represents a consumer application that integrates these packages to render and test actual multi-step forms.
d. CI/CD and DevOps:
- The .github workflows, changeset configuration, and turbo.json indicate automation for testing, linting, building, and versioning.

##### Relationships and Interactions
- A clear dependency where the demo application (apps/react) consumes the @formity/react package.
- That the @formity/react package may “wrap” or leverage functionalities and type definitions from the @formity/system package (e.g., to dynamically generate form flows and manage state).
- The CI/CD pipelines (shown in the .github directory) ensure that tests (like the Cypress tests in apps/react) and builds run seamlessly to keep both packages in sync.
- Additionally, external integrations (like Cypress for end-to-end testing, Rollup or Vite for bundling) should be noted.

- “@formity/react Package” – include notes on key directories like src/components, multi-step handling, and integration with react-hook-form.
- “@formity/system Package” – detail its structure revolving around type definitions (schema, state, output, etc.) and utility functions.
- “Demo Application (apps/react)” – highlight how it interacts with the React package to render forms and run tests.
- Data flow from the demo app to the React package as it consumes UI components.
- Dependencies from the React package to the System package for core logic and type consistency.

## Diagram (Mermaid)

```mermaid
graph TD
    %% CI/CD & Automation Layer
    subgraph "CI/CD & Automation"
        G("GitHub Workflows"):::ci
        CH("Changeset Config"):::ci
        T("Turbo Config"):::ci
    end

    %% Overall Repository
    B("Formity Mono Repo"):::repo

    %% Libraries Layer
    subgraph "Libraries"
        R("@formity/react Package"):::library
        S("@formity/system Package"):::library
        R -->|"depends_on"| S
    end

    %% Demo Application Layer
    D("Demo Application (React App)"):::app

    %% Relationships
    G -->|"build/test"| B
    CH -->|"build/test"| B
    T -->|"build/test"| B
    B -->|"contains"| R
    B -->|"contains"| S
    B -->|"contains"| D
    D -->|"consumes"| R

    %% Styles
    classDef repo fill:#ffebcd,stroke:#8b4513,stroke-width:2px;
    classDef library fill:#d0f0c0,stroke:#228b22,stroke-width:2px;
    classDef app fill:#add8e6,stroke:#00008b,stroke-width:2px;
    classDef ci fill:#f4cccc,stroke:#cc0000,stroke-width:2px;

    %% Click Events
    click R "https://github.com/martiserra99/formity/tree/main/packages/react"
    click S "https://github.com/martiserra99/formity/tree/main/packages/system"
    click D "https://github.com/martiserra99/formity/tree/main/apps/react"
    click G "https://github.com/martiserra99/formity/blob/main/.github"
    click CH "https://github.com/martiserra99/formity/blob/main/.changeset"
    click T "https://github.com/martiserra99/formity/blob/main/turbo.json"
```
