# t3-oss/t3-env architecture

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

- Interactive diagram: https://gitdiagram.com/t3-oss/t3-env
- Repository: https://github.com/t3-oss/t3-env

## Overview

##### Main Components

a) Framework Integration Layer:
- Next.js Integration (@t3-oss/env-nextjs)
- Nuxt Integration (@t3-oss/env-nuxt)
- Core Package (@t3-oss/env-core)

b) Core Processing Layer:
- Environment Variable Processing
- Server-side ENV Handler
- Client-side ENV Handler
- Runtime ENV Validator
- Schema Definition System
- Type Generation System

c) Schema Validation Layer:
- Validation Libraries Support
- Zod Integration
- Valibot Integration
- Standard Schema Compliance

##### Specific Elements

a) Input/Output Points:
- ENV File Input
- Type Definitions Output
- Runtime Validation Results

b) Framework-Specific Features:
- Next.js Edge Runtime Support
- Nuxt Server Routes Integration
- Client/Server ENV Separation

##### Important Details to Highlight

- ESM Module System
- TypeScript Integration
- Standard Schema Compliance
- Framework-Specific Safety Checks

##### Implementation Details

Annotations showing:
- Validation Flow
- Type Generation Process
- Framework-Specific Configurations

##### Additional Elements

- TypeScript support
- ESM compatibility
- Framework logos
- Validation library logos

##### The validation flow from definition to runtime

Keep the abstraction level focused on the architectural components while showing the key technical implementations that make the system unique, particularly the type-safety mechanisms and framework integrations.

- Component types
- Special symbols

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Framework_Integration_Layer
        NI["Nuxt Integration"]:::framework
        NXI["Next.js Integration"]:::framework
        CP["Core Package"]:::core
    end

    subgraph Core_Processing_Layer
        SSENV["Server-side ENV Handler"]:::core
        CSENV["Client-side ENV Handler"]:::core
        REV["Runtime ENV Validator"]:::core
        SDS["Schema Definition System"]:::core
        TGS["Type Generation System"]:::core
    end

    subgraph Schema_Validation_Layer
        ZI["Zod Integration"]:::validation
        VI["Valibot Integration"]:::validation
        SSC["Standard Schema Compliance"]:::validation
    end

    subgraph Framework_Specific_Features
        NER["Next.js Edge Runtime"]:::feature
        NSR["Nuxt Server Routes"]:::feature
        CSE["Client/Server ENV Separation"]:::feature
    end

    subgraph Implementation_Examples
        NE["Next.js Example"]:::example
        NUE["Nuxt Example"]:::example
        AE["Astro Example"]:::example
    end

    %% Core Relationships
    CP --> SSENV
    CP --> CSENV
    CP --> REV
    CP --> SDS
    CP --> TGS

    %% Framework Integration Relationships
    NI --> CP
    NXI --> CP

    %% Validation Relationships
    SDS --> ZI
    SDS --> VI
    SDS --> SSC

    %% Framework Features
    NXI --> NER
    NI --> NSR
    CP --> CSE

    %% Implementation Examples
    NXI --> NE
    NI --> NUE
    CP --> AE

    %% Click Events
    click CP "https://github.com/t3-oss/t3-env/blob/main/packages/core/src/index.ts"
    click NXI "https://github.com/t3-oss/t3-env/blob/main/packages/nextjs/src/index.ts"
    click NI "https://github.com/t3-oss/t3-env/blob/main/packages/nuxt/src/index.ts"
    click ZI "https://github.com/t3-oss/t3-env/blob/main/packages/core/src/presets-zod.ts"
    click VI "https://github.com/t3-oss/t3-env/blob/main/packages/core/src/presets-valibot.ts"
    click SSC "https://github.com/t3-oss/t3-env/blob/main/packages/core/src/standard.ts"
    click NER "https://github.com/t3-oss/t3-env/blob/main/examples/nextjs/app/api/edge/route.ts"
    click NSR "https://github.com/t3-oss/t3-env/blob/main/examples/nuxt/server/api/hello.get.ts"
    click NE "https://github.com/t3-oss/t3-env/blob/main/examples/nextjs/app/env.ts"
    click NUE "https://github.com/t3-oss/t3-env/blob/main/examples/nuxt/env.ts"
    click AE "https://github.com/t3-oss/t3-env/blob/main/examples/astro/src/t3-env.ts"

    classDef core fill:#2b6cb0,stroke:#1a4971,color:white
    classDef framework fill:#48bb78,stroke:#2f855a,color:white
    classDef validation fill:#ecc94b,stroke:#d69e2e,color:black
    classDef feature fill:#9f7aea,stroke:#805ad5,color:white
    classDef example fill:#ed8936,stroke:#dd6b20,color:white

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Framework Integration"]:::framework
        L3["Validation Components"]:::validation
        L4["Framework Features"]:::feature
        L5["Examples"]:::example
    end
```
