# victorgarciaesgi/regle architecture

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

- Interactive diagram: https://gitdiagram.com/victorgarciaesgi/regle
- Repository: https://github.com/victorgarciaesgi/regle

## Overview

##### Main Components Identification

The system consists of several key packages that should be represented as main components:
- Core Package (@regle/core)
- Rules Package (@regle/rules)
- Integration Packages (Nuxt, Zod, Valibot)
- Shared Utilities

**┌─ Application Layer ─────────────────────────────────┐**
- Vue 3 Components / Nuxt Applications               │
- ┬─────────────────────────────┘
- ↓
**┌─ Integration Layer ────────────────────────────────┐**
- ┌─────────────┐  ┌──────────┐  ┌───────────┐     │
- Nuxt Module │  │   Zod    │  │  Valibot  │     │
- ┘  └──────────┘  └───────────┘     │
- ┬─────────────────────────────┘
- ↓
**┌─ Core Layer ──────────────────────────────────────┐**
- ┌─────────────────────┐  ┌──────────────────┐    │
- Regle Core       │←─│  Validation Rules│    │
- useRegle         │  │  - Built-in Rules│    │
- createRule       │  │  - Rule Helpers  │    │
- Reactive System  │  └──────────────────┘    │
- ┘                          │
- ┬──────────────────────────┘
- ↓
**┌─ Shared Layer ────────────────────────────────────┐**
- Common Utilities and Type Definitions             │
- ┘

##### Component Relationships

- Data flow from application components to validation system
- Rule application flow
- Integration points with external systems
- Dependencies between packages

##### Key Features to Highlight

Create callouts or annotations for:
- TypeScript type inference system
- Model-based validation flow
- Collection validation handling
- External schema integration (Zod/Valibot)
- Rule composition and extension points

##### Implementation Details

Technical details such as:
- Reactive system integration with Vue 3
- Rule processing pipeline
- Error handling and propagation
- State management integration (Pinia support)

##### Additional Elements

Supplementary information:
- Package sizes and dependencies
- Integration points with frameworks
- Configuration options
- Performance considerations

##### Notes for Scale

How the system handles:
- Form complexity
- Validation rule combinations
- Async validation
- Collection validation
- Type safety across the system

- Type-first approach
- Extensibility
- Framework integration
- Performance optimization
- Developer experience

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Application Layer"
        App[Vue 3 Components / Nuxt Applications]:::app
    end

    subgraph "Integration Layer"
        NuxtMod[Nuxt Module]:::integration
        ZodInt[Zod Integration]:::integration
        ValibotInt[Valibot Integration]:::integration
    end

    subgraph "Core Layer"
        RegleCore[Regle Core]:::core
        ValidationRules[Validation Rules]:::rules
        
        subgraph "Core Components"
            UseRegle[useRegle]:::core
            CreateRule[createRule]:::core
            DefaultValidators[Default Validators]:::core
            RuleProcessors[Rule Processors]:::core
        end
        
        subgraph "Reactive System"
            FieldStatus[Field Status]:::reactive
            RuleStatus[Rule Status]:::reactive
        end
    end

    subgraph "Shared Layer"
        Utils[Common Utilities]:::shared
        Types[Type Definitions]:::shared
        IsEmpty[isEmpty Utility]:::shared
    end

    %% Relationships
    App --> NuxtMod & ZodInt & ValibotInt
    NuxtMod & ZodInt & ValibotInt --> RegleCore
    RegleCore --> ValidationRules
    RegleCore --> UseRegle & CreateRule & DefaultValidators
    UseRegle --> FieldStatus & RuleStatus
    CreateRule --> RuleProcessors
    ValidationRules & RegleCore --> Utils
    Utils --> Types & IsEmpty

    %% Click Events
    click NuxtMod "https://github.com/victorgarciaesgi/regle/blob/main/packages/nuxt/src/module.ts"
    click ZodInt "https://github.com/victorgarciaesgi/regle/blob/main/packages/zod/src/core/useZodRegle.ts"
    click ValibotInt "https://github.com/victorgarciaesgi/regle/blob/main/packages/valibot/src/core/useValibotRegle.ts"
    click UseRegle "https://github.com/victorgarciaesgi/regle/tree/main/packages/core/src/core/useRegle"
    click CreateRule "https://github.com/victorgarciaesgi/regle/tree/main/packages/core/src/core/createRule"
    click DefaultValidators "https://github.com/victorgarciaesgi/regle/blob/main/packages/core/src/core/defaultValidators.ts"
    click ValidationRules "https://github.com/victorgarciaesgi/regle/tree/main/packages/rules/src/rules"
    click Utils "https://github.com/victorgarciaesgi/regle/tree/main/packages/shared/utils"
    click Types "https://github.com/victorgarciaesgi/regle/tree/main/packages/core/src/types"
    click IsEmpty "https://github.com/victorgarciaesgi/regle/blob/main/packages/shared/utils/isEmpty.ts"
    click RuleProcessors "https://github.com/victorgarciaesgi/regle/blob/main/packages/core/src/core/createRule/defineRuleProcessors.ts"
    click FieldStatus "https://github.com/victorgarciaesgi/regle/blob/main/packages/core/src/core/useRegle/root/createReactiveFieldStatus.ts"
    click RuleStatus "https://github.com/victorgarciaesgi/regle/blob/main/packages/core/src/core/useRegle/root/createReactiveRuleStatus.ts"

    %% Styles
    classDef app fill:#9966FF,stroke:#333,stroke-width:2px
    classDef integration fill:#66CC66,stroke:#333,stroke-width:2px
    classDef core fill:#3399FF,stroke:#333,stroke-width:2px
    classDef rules fill:#FF9933,stroke:#333,stroke-width:2px
    classDef shared fill:#CCCCCC,stroke:#333,stroke-width:2px
    classDef reactive fill:#FF66CC,stroke:#333,stroke-width:2px
```
