# aiji42/zod-i18n architecture

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

- Interactive diagram: https://gitdiagram.com/aiji42/zod-i18n
- Repository: https://github.com/aiji42/zod-i18n

## Overview

##### Project Type and Purpose
- This is a library package that provides localization for Zod’s error messages.
- It integrates with i18next to allow dynamic translation of error messages.
- It offers both a ready-to-use error map (zodI18nMap) and a customizable version (makeZodI18nMap) for developers.
- There are example integrations provided (e.g., an example using next-i18next), and tests ensure the correctness of the translations.

##### File Structure Insights
- The top-level structure includes configuration files (.github workflows, commit hooks, etc.), indicating CI/CD and development tooling.
- The examples folder (e.g., with-next-i18next) demonstrates how to integrate the library in a Next.js context.
- The packages folder (specifically packages/core) contains the primary codebase, including:
- Source code in src (the main implementation exposing the error map functions)
- Locales directories, housing JSON files for each supported language.
- Tests (integrations and unit tests using vitest) to validate behavior across locales.
- There are build (e.g., tsup.config.ts) and TypeScript configuration files indicating standard practices for bundling and type-checking.

##### Specific Elements
- Consumer Application (or external application)
- Library Core Module (including API exposure via zodI18nMap and makeZodI18nMap)
- Localization Files (grouped by language/locale)
- Test Suite / CI System (indicating automated tests and workflows)
- Configuration / Build Tools (e.g., tsup, TypeScript, GitHub workflows)
- From Consumer Application to Library Core (indicating usage of the API).
- Between Library Core and Localization Files (indicating how the language-specific JSON files are utilized).
- From Configuration/CI systems to Library Core and Tests (representing the build and test pipeline).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Consumer Layer
    subgraph "Consumer Layer"
        CA("Consumer Application"):::external
        CL("Consumer Localization Files"):::localization
    end

    %% Library Core Module
    subgraph "Library Core"
        LC("Core API (zodI18nMap & makeZodI18nMap)"):::core
        CLoc("Core Localization Files"):::localization
    end

    %% Testing and CI/CD
    subgraph "Testing & CI/CD"
        T("Testing Module"):::testing
        subgraph "Build and Configuration Tools"
            BC("Build Config (tsup)"):::build
            TC("TypeScript Config"):::build
            VT("Vitest Config"):::build
            CICD("CI/CD Workflow"):::build
        end
    end

    %% Relationships
    CA -->|"calls"| LC
    CA -->|"uses"| CL
    LC -->|"loads"| CLoc
    LC -->|"verifiedBy"| T
    CICD -->|"triggers"| T
    CICD -->|"builds"| LC

    %% Click Events
    click CA "https://github.com/aiji42/zod-i18n/tree/main/examples/with-next-i18next"
    click LC "https://github.com/aiji42/zod-i18n/blob/main/packages/core/src/index.ts"
    click CLoc "https://github.com/aiji42/zod-i18n/tree/main/packages/core/locales"
    click CL "https://github.com/aiji42/zod-i18n/tree/main/examples/with-next-i18next/public/locales"
    click T "https://github.com/aiji42/zod-i18n/tree/main/packages/core/tests"
    click BC "https://github.com/aiji42/zod-i18n/blob/main/packages/core/tsup.config.ts"
    click TC "https://github.com/aiji42/zod-i18n/blob/main/packages/core/tsconfig.json"
    click VT "https://github.com/aiji42/zod-i18n/blob/main/packages/core/vitest.config.ts"
    click CICD "https://github.com/aiji42/zod-i18n/tree/main/.github/workflows"

    %% Styles
    classDef external fill:#FFEEAD,stroke:#333,stroke-width:2px;
    classDef core fill:#AEDFF7,stroke:#333,stroke-width:2px;
    classDef localization fill:#B7E4C7,stroke:#333,stroke-width:2px;
    classDef testing fill:#F7A9A8,stroke:#333,stroke-width:2px;
    classDef build fill:#D3D3D3,stroke:#333,stroke-width:2px;
```
