# semmu/fluent-json-validator architecture

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

- Interactive diagram: https://gitdiagram.com/semmu/fluent-json-validator
- Repository: https://github.com/semmu/fluent-json-validator

## Overview

##### Main Components

a) Core Validation Engine
- Represented by 'is.js' which contains the main validation logic

b) Validator Types (show as branches from the core):
- Primitive Validators (String, Number, Boolean)
- Complex Validators (Object, ArrayOf)
- Special Validators (OneOf, Optional)
- Custom Validators (Which - for functional validation)

c) Testing Framework
- As a separate component connected to the core
- Represents 'tests.js'

##### Component Relationships

- Builder Pattern Flow: Show how validators can be chained
- Validation Flow: Input JSON → Validator → Validation Result
- Composition Flow: Show how validators can be nested/composed

##### Specific Implementation Details

- Public API Interface
- Internal Validation Units
- Builder Pattern Implementation
- Composition Mechanism

##### Important Elements to Highlight

- Zero Dependencies: Show this as a notable feature
- Fluent Interface: Illustrate the builder pattern flow
- Composition Capability: Show how validators can be nested
- Validation Flow: Demonstrate both formal and functional validation paths

##### Documentation Integration

Connection to:
- API Documentation (docs folder)
- Test Cases
- Usage Examples

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        L1[Core Component]:::core
        L2[Validator Type]:::validator
        L3((Decision Point)):::decision
        L4[(Data Structure)]:::data
        L5[Test Component]:::test
        L6[Documentation]:::doc
    end

    subgraph "Public API Layer"
        API[Public API Interface]:::core
        click API "https://github.com/Semmu/fluent-json-validator/blob/master/docs/index.html"
    end

    subgraph "Core Layer"
        Core[Core Validation Engine]:::core
        click Core "https://github.com/Semmu/fluent-json-validator/blob/master/is.js"
        ValUnit[Validation Unit]:::core
        click ValUnit "https://github.com/Semmu/fluent-json-validator/blob/master/docs/is.__validationUnit.html"
    end

    subgraph "Validator Types"
        direction TB
        Primitive[Primitive Validators]:::validator
        Complex[Complex Validators]:::validator
        Special[Special Validators]:::validator
        Custom[Custom Validators]:::validator

        subgraph "Primitive"
            String[String]:::validator
            Number[Number]:::validator
            Boolean[Boolean]:::validator
        end

        subgraph "Complex"
            Object[Object]:::validator
            ArrayOf[ArrayOf]:::validator
        end

        subgraph "Special"
            OneOf[OneOf]:::validator
            Optional[Optional]:::validator
        end

        subgraph "Custom"
            Which[Which]:::validator
        end
    end

    subgraph "Testing & Documentation"
        Tests[Testing Framework]:::test
        click Tests "https://github.com/Semmu/fluent-json-validator/blob/master/tests.js"
        APIDoc[API Documentation]:::doc
        click APIDoc "https://github.com/Semmu/fluent-json-validator/blob/master/docs/is.html"
        SourceDoc[Source Documentation]:::doc
        click SourceDoc "https://github.com/Semmu/fluent-json-validator/blob/master/docs/is.js.html"
    end

    Input[(Input JSON)]:::data
    Output[(Validation Result)]:::data
    Decision((Validation)):::decision

    API --> Core
    Core --> ValUnit
    ValUnit --> Primitive
    ValUnit --> Complex
    ValUnit --> Special
    ValUnit --> Custom

    Input --> Decision
    Decision --> Core
    Core --> Output

    Tests -.-> Core
    APIDoc -.-> API
    SourceDoc -.-> Core

    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef validator fill:#2ecc71,stroke:#27ae60,color:white
    classDef decision fill:#e74c3c,stroke:#c0392b,color:white
    classDef data fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef test fill:#f39c12,stroke:#d35400,color:white
    classDef doc fill:#9b59b6,stroke:#8e44ad,color:white
```
