# es-js/esjs architecture

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

- Interactive diagram: https://gitdiagram.com/es-js/esjs
- Repository: https://github.com/es-js/esjs

## Overview

##### Main Components Identification

a) Core Components:
- Compiler System (@esjs/core)
- Language Parser (@esjs/esbabel)
- Runtime Environment (@esjs/runtime)
- Sandbox Environment (@esjs/sandbox)

b) Development Tools:
- CLI Tool (@esjs/cli)
- VSCode Extension (@esjs/vscode-esjs)
- Language Tools (@esjs/language-tools)

c) Framework Integration:
- Vue.js Integration (@esjs/esvue)
- HTML Integration (@esjs/eshtml)
- Vite Plugins

**┌─────────────────────────────────────────────────────────────┐**
- Developer Interface                      │
- ┬──────────────────────────┬──────────────────┤
- CLI Tools   │    VSCode Extension      │  Online Editor   │
- ┬───────┴──────────────┬───────────┴────────┬─────────┘

**┌──────▼──────────────────────▼─────────────────────▼────────┐**
- Compilation Layer                       │
- ┬─────────────────────┬───────────────────┬─┘
- Core Compiler │   Babel Parser      │  Sucrase Parser   │
- ┬───────┴────────┬────────────┴─────────┬─────────┘

**┌────────▼────────────────▼──────────────────────▼─────────┐**
- Runtime Layer                          │
- ┬────────────────────┬────────────────────┬┘
- Base Runtime  │  Sandbox Runtime   │  Browser Runtime   │
- ┴────────────────────┴────────────────────┘

##### Component Relationships

- Input flow from developer tools to compilation layer
- Compilation process flow through parsers
- Runtime execution flow
- Integration with external tools and frameworks

##### Additional Elements

Supporting elements:
- File processing pipelines
- Plugin system architecture
- Framework integration points
- Development tool connections

##### Implementation Details

- The transformation from Spanish syntax to JavaScript
- The plugin architecture for language features
- The sandbox environment for code execution
- Integration with build tools and frameworks

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef developer fill:#2196F3,stroke:#1565C0,color:white
    classDef compiler fill:#4CAF50,stroke:#2E7D32,color:white
    classDef runtime fill:#FF9800,stroke:#EF6C00,color:white
    classDef integration fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef parser fill:#00BCD4,stroke:#00838F,color:white

    %% Developer Interface Layer
    subgraph DevTools
        CLI["CLI Tool"]
        VSCode["VSCode Extension"]
        Playground["Development Playground"]
    end

    %% Compilation Layer
    subgraph CompilationLayer
        CoreCompiler["Core Compiler System"]
        Parser["Language Parser"]
        Plugins["Core Plugins"]
        
        subgraph ParserComponents
            Lexer["Lexer"]
            TokenHandler["Token Handler"]
            Generator["Generator"]
        end
    end

    %% Runtime Layer
    subgraph RuntimeLayer
        Runtime["Runtime Environment"]
        Sandbox["Sandbox Environment"]
    end

    %% Integration Layer
    subgraph IntegrationLayer
        VueIntegration["Vue.js Integration"]
        HTMLIntegration["HTML Integration"]
        LangTools["Language Tools"]
        
        subgraph VitePlugins
            ViteVue["Vite Plugin Vue"]
            ViteHTML["Vite Plugin HTML"]
        end
    end

    %% Relationships
    CLI --> CoreCompiler
    VSCode --> CoreCompiler
    Playground --> CoreCompiler
    
    CoreCompiler --> Parser
    Parser --> ParserComponents
    ParserComponents --> Runtime
    
    CoreCompiler --> Plugins
    Plugins --> Runtime
    
    Runtime --> Sandbox
    
    VueIntegration --> Runtime
    HTMLIntegration --> Runtime
    LangTools --> Parser
    
    ViteVue --> VueIntegration
    ViteHTML --> HTMLIntegration

    %% Click Events
    click CLI "https://github.com/es-js/esjs/tree/main/packages/cli/commands/"
    click VSCode "https://github.com/es-js/esjs/tree/main/packages/vscode-esjs/src/"
    click Playground "https://github.com/es-js/esjs/tree/main/apps/playground/"
    click CoreCompiler "https://github.com/es-js/esjs/tree/main/packages/core/src/compiler/"
    click Parser "https://github.com/es-js/esjs/tree/main/packages/esbabel/src/"
    click Runtime "https://github.com/es-js/esjs/tree/main/packages/runtime/src/"
    click Sandbox "https://github.com/es-js/esjs/tree/main/packages/sandbox/src/"
    click LangTools "https://github.com/es-js/esjs/tree/main/packages/language-tools/src/"
    click VueIntegration "https://github.com/es-js/esjs/tree/main/packages/esvue/src/"
    click HTMLIntegration "https://github.com/es-js/esjs/tree/main/packages/eshtml/src/"
    click Lexer "https://github.com/es-js/esjs/blob/main/packages/esbabel/src/lexer.ts"
    click TokenHandler "https://github.com/es-js/esjs/blob/main/packages/esbabel/src/token.ts"
    click Generator "https://github.com/es-js/esjs/blob/main/packages/esbabel/src/generator.ts"
    click Plugins "https://github.com/es-js/esjs/tree/main/packages/core/src/plugins/"
    click ViteVue "https://github.com/es-js/esjs/tree/main/packages/vite-plugin-esvue/src/"
    click ViteHTML "https://github.com/es-js/esjs/tree/main/packages/vite-plugin-eshtml/src/"

    %% Style Applications
    class CLI,VSCode,Playground developer
    class CoreCompiler,Parser,Plugins,ParserComponents compiler
    class Runtime,Sandbox runtime
    class VueIntegration,HTMLIntegration,LangTools,VitePlugins integration
    class Lexer,TokenHandler,Generator parser
```
