How fabian-hiller/valibot works
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.