# languine-ai/languine architecture

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

- Interactive diagram: https://gitdiagram.com/languine-ai/languine
- Repository: https://github.com/languine-ai/languine

## Overview

Based on our analysis of the file tree and README, Languine is a monorepo that provides a CLI tool to automate and enhance localization (translation) workflows using AI. At its core, the tool helps developers extract translation keys from their codebases, parse multiple file formats, and then automatically translate them using AI models. The monorepo is structured with multiple packages (CLI, Action, React Email, SDK, Supabase) and a web app to support both command‐line interactions and possibly a visual dashboard.

##### Project Type and Purpose
- Languine is a developer-friendly localization tool with AI-powered translation. Its purpose is to help developers automatically detect and update translations across various file formats by integrating with Git (via diffs), using configuration files and parsers to handle content, and then leveraging AI for translation.
- The tool is available as a CLI application but is also integrated with GitHub Actions (via the “action” package) and comes with an optional web interface (under apps/web) for dashboards or a preview, plus additional integrations such as React Email and SDK for broader use.

##### Key Components Identified from the File Structure
a. CLI Application (packages/cli)
- Handles core commands such as extraction of translation keys, sync, transform, auth, and translation workflows.
- Contains multiple parsers for various file formats (json, yaml, md, po, etc.) and additional utility scripts.
b. GitHub Action Integration (packages/action)
- Provides integration with CI/CD pipelines using GitHub Actions.
- Contains platform-specific logic (e.g., Git provider factories, workflow management for branch or pull-request based automation).
c. Web Application (apps/web)
- Likely offers a user interface for managing translations, previewing changes, and possibly a dashboard for overview.
- Uses Next.js (as indicated by next.config.ts) and a rich set of React components.
- Includes database migrations and ORM configuration via Drizzle for storing meta or translation snapshots.
d. React Email (packages/react-email)
- Provides components and email templates so that translation notifications or invites can be sent in a templated, localized format.
e. SDK (packages/sdk)
- Offers an API for developers who wish to integrate the translation functionality directly in their apps.
f. Supabase Integration (packages/supabase)
- Contains client and server libraries for authentication/session management or handling data, likely used in the web app or to manage user-related translation data.
g. Supporting Examples and Documentation
- Multiple “examples” directories showing integration with various platforms (Expo, Nuxt, markdown, php, etc.) demonstrate how Languine can be adapted.
h. Infrastructure & CI/CD
- GitHub workflows in .github indicate automated builds, tests and deployments.
- Configuration files for Drizzle migrations, Tailwind, and TypeScript configurations indicate robust build and deployment pipelines.

##### Relationships and Interactions
- The CLI serves as the central interface where translation keys are extracted from source code, processed through a series of parsers (organized by file type), and then either updated or sent to external AI models to generate the translations.
- The GitHub Action package enables triggering these processes automatically on repository events (pull request, branch).
- The web application interacts with backend databases (via migrations and ORM in apps/web) and uses the SDK to ensure integration with the CLI and possibly other services (like Supabase for auth/session).
- The React Email package provides templated emails that could be generated as notifications or part of the translation update process.
- Each component is interconnected as part of the monorepo, following modular patterns and a separation of concerns; for example, the CLI handles command execution while the action package bridges with CI/CD environments.

##### Architectural Patterns and Principles
- Monorepo architecture: Clearly separating packages into different directories (CLI, action, SDK, etc.) while sharing common configurations.
- Modularity: Each functionality (translation extraction, file parsing, UI components, email templating) is isolated into its own package/module.
- Integration with external systems: The system leverages Git diff for change detection and integrates with AI models (external service) for translation.
- Developer-Centric: Uses TypeScript across the board, includes hooks, utilities, and is built to integrate seamlessly with existing version control and build systems.

##### Essential Elements
- Clear, labeled nodes/components for each major element (CLI, GitHub Action, Web App, SDK, React Email, Supabase).
- From repository & file system (with Git diffs) to the CLI’s extraction/parsing layer.
- From CLI/action to external AI translation service.
- From CLI to updates in the database, and then to the Web UI.
- Web-based components (rounded rectangles),
- Notes on technology stacks (TypeScript, Next.js, Drizzle ORM, GitHub Actions, AI services) next to the respective components.

##### Final Advice
- The input layer (source code repository, Git diff triggers),
- The processing layer (CLI, parsers, and AI translation engine),
- The output or integration layer (web UI/dashboard, email notifications, and API/SDK endpoints).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input Layer
    subgraph "Input Layer"
        Repo["Source Repository (Git)"]:::repo
    end

    %% Processing Layer
    subgraph "Processing Layer"
        CLI["CLI Application"]:::cli
        GHA["GitHub Action Integration"]:::gha
        AI["AI Translation Service"]:::external
    end

    %% Output Layer
    subgraph "Output Layer"
        Web["Web Application Dashboard (Next.js)"]:::web
        DB["Database (Drizzle ORM)"]:::db
        SDK["SDK"]:::sdk
        Email["React Email Service"]:::email
        Supabase["Supabase Integration"]:::supabase
    end

    %% Relationships
    Repo -->|"extractKeys"| CLI
    Repo -->|"triggerCI"| GHA
    GHA -->|"invokeCLI"| CLI
    CLI -->|"requestTranslation"| AI
    CLI -->|"updateTranslation"| Web
    CLI -->|"sendEmail"| Email
    CLI -->|"exposeAPI"| SDK
    Web -->|"manageData"| DB
    Web -->|"auth"| Supabase
    Web -->|"consumeAPI"| SDK

    %% Click Events
    click CLI "https://github.com/languine-ai/languine/tree/main/packages/cli"
    click GHA "https://github.com/languine-ai/languine/tree/main/packages/action"
    click Web "https://github.com/languine-ai/languine/tree/main/apps/web"
    click Email "https://github.com/languine-ai/languine/tree/main/packages/react-email"
    click SDK "https://github.com/languine-ai/languine/tree/main/packages/sdk"
    click Supabase "https://github.com/languine-ai/languine/tree/main/packages/supabase"

    %% Styles
    classDef repo fill:#E0FFFF,stroke:#000,stroke-width:2px;
    classDef cli fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef gha fill:#FFEFD5,stroke:#000,stroke-width:2px;
    classDef external fill:#FFE4E1,stroke:#000,stroke-width:2px;
    classDef web fill:#C1FFC1,stroke:#000,stroke-width:2px;
    classDef db fill:#F0E68C,stroke:#000,stroke-width:2px;
    classDef sdk fill:#FFD1DC,stroke:#000,stroke-width:2px;
    classDef email fill:#FFFFCC,stroke:#000,stroke-width:2px;
    classDef supabase fill:#E0BBE4,stroke:#000,stroke-width:2px;
```
