# s00d/nuxt-i18n-micro architecture

> Architecture diagram of the GitHub repository s00d/nuxt-i18n-micro, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/s00d/nuxt-i18n-micro
- Repository: https://github.com/s00d/nuxt-i18n-micro

## Overview

##### Main Components

a. Core Module Layer:
- Module Configuration Handler (src/module.ts)
- Locale Manager (src/locale-manager.ts)
- Page Manager (src/page-manager.ts)
- Translation Server Middleware (src/runtime/translation-server-middleware.ts)

b. Runtime Components Layer:
- I18n Components (i18n-group, i18n-link, i18n-switcher, i18n-t)
- Composables (useI18n, useLocaleHead)
- Runtime Plugins (auto-detect, meta, define)

c. File System Layer:
- Global Translations Directory
- Page-specific Translations
- Dynamic Route Generation System

##### Interaction Flows to Highlight

a. Request Flow:
- Client Request → Route Detection → Locale Detection → Translation Loading → Response

b. Translation Loading Flow:
- Page Request → Check Global Translations → Load Page-specific Translations → Merge → Serve

##### Key Elements to Emphasize

a. Performance Optimizations:
- Dynamic route generation (only 2 routes)
- Lazy loading of translations
- Memory-efficient translation handling

b. Integration Points:
- Nuxt.js hooks
- Server middleware
- Client-side plugins

**┌─────────────────────────────────────────────────────────────┐**
- Nuxt Application                        │
- ┬─────────────────────┬───────────────────┤
- Core Module    │  Runtime Components │  Translation Store │
- Configuration│  - I18n Components  │  - Global Files   │
- Locale Mgr   │  - Composables     │  - Page Files     │
- Page Mgr     │  - Plugins         │  - Dynamic Gen    │
- ┬───────┴────────┬────────────┴────────┬──────────┘

- ▼                ▼                     ▼
- Route Handling    Translation Loading    File System

##### Implementation Notes

- Performance metrics at key points

##### Documentation Integration

- Performance comparison metrics
- Reference the build and runtime optimizations

This system design should emphasize the module's key differentiators: its performance optimizations, minimal route generation, and efficient translation handling system, while maintaining clarity about how all components interact within the Nuxt.js ecosystem.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Nuxt Application"
        subgraph "Core Module"
            ModConfig["Module Configuration"]:::core
            LocaleMgr["Locale Manager"]:::core
            PageMgr["Page Manager"]:::core
            TransMid["Translation Server Middleware"]:::core
        end

        subgraph "Runtime Components"
            subgraph "I18n Components"
                I18nGroup["I18n Group"]:::runtime
                I18nLink["I18n Link"]:::runtime
                I18nSwitch["I18n Switcher"]:::runtime
                I18nT["I18n T"]:::runtime
            end

            subgraph "Composables"
                UseI18n["useI18n"]:::runtime
                UseLocaleHead["useLocaleHead"]:::runtime
            end

            subgraph "Runtime Plugins"
                Plugin["Base Plugin"]:::runtime
                Meta["Meta Plugin"]:::runtime
                Define["Define Plugin"]:::runtime
                AutoDetect["Auto Detect Plugin"]:::runtime
            end
        end

        subgraph "Translation Store"
            GlobalTrans[("Global Translations")]:::storage
            PageTrans[("Page Translations")]:::storage
            DynamicGen["Dynamic Route Generation"]:::system
        end
    end

    %% Flow Connections
    ModConfig --> LocaleMgr
    ModConfig --> PageMgr
    LocaleMgr --> TransMid
    PageMgr --> TransMid
    TransMid --> GlobalTrans
    TransMid --> PageTrans
    DynamicGen --> PageMgr

    %% Runtime Connections
    UseI18n --> GlobalTrans
    UseI18n --> PageTrans
    UseLocaleHead --> LocaleMgr
    I18nGroup --> UseI18n
    I18nLink --> UseI18n
    I18nSwitch --> UseI18n
    I18nT --> UseI18n

    %% Plugin Connections
    Plugin --> UseI18n
    Meta --> UseLocaleHead
    Define --> UseI18n
    AutoDetect --> LocaleMgr

    %% Styling
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef runtime fill:#4CAF50,stroke:#2E7D32,color:white
    classDef storage fill:#FFC107,stroke:#FFA000,color:black
    classDef system fill:#9E9E9E,stroke:#616161,color:white

    %% Click Events
    click ModConfig "https://github.com/s00d/nuxt-i18n-micro/blob/main/src/module.ts"
    click LocaleMgr "https://github.com/s00d/nuxt-i18n-micro/blob/main/src/locale-manager.ts"
    click PageMgr "https://github.com/s00d/nuxt-i18n-micro/blob/main/src/page-manager.ts"
    click TransMid "https://github.com/s00d/nuxt-i18n-micro/blob/main/src/runtime/translation-server-middleware.ts"
    click I18nGroup "https://github.com/s00d/nuxt-i18n-micro/blob/main/src/runtime/components/i18n-group.vue"
    click I18nLink "https://github.com/s00d/nuxt-i18n-micro/blob/main/src/runtime/components/i18n-link.vue"
    click I18nSwitch "https://github.com/s00d/nuxt-i18n-micro/blob/main/src/runtime/components/i18n-switcher.vue"
    click I18nT "https://github.com/s00d/nuxt-i18n-micro/blob/main/src/runtime/components/i18n-t.vue"
    click UseI18n "https://github.com/s00d/nuxt-i18n-micro/blob/main/src/runtime/composables/useI18n.ts"
    click UseLocaleHead "https://github.com/s00d/nuxt-i18n-micro/blob/main/src/runtime/composables/useLocaleHead.ts"
    click Plugin "https://github.com/s00d/nuxt-i18n-micro/blob/main/src/runtime/plugins/01.plugin.ts"
    click Meta "https://github.com/s00d/nuxt-i18n-micro/blob/main/src/runtime/plugins/02.meta.ts"
    click Define "https://github.com/s00d/nuxt-i18n-micro/blob/main/src/runtime/plugins/03.define.ts"
    click AutoDetect "https://github.com/s00d/nuxt-i18n-micro/blob/main/src/runtime/plugins/04.auto-detect.ts"
    click GlobalTrans "https://github.com/s00d/nuxt-i18n-micro/tree/main/playground/locales"
    click PageTrans "https://github.com/s00d/nuxt-i18n-micro/tree/main/playground/locales/pages"
```
