# dmomotic/matriosh-ts-c3d architecture

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

- Interactive diagram: https://gitdiagram.com/dmomotic/matriosh-ts-c3d
- Repository: https://github.com/dmomotic/matriosh-ts-c3d

## Overview

##### Project Type and Purpose
- The project is a Quasar Framework application, which means it is a Vue.js–based front-end. However, it is not a typical UI-only app. Alongside the user interface (built with Vue single-file components like App.vue, layouts, pages, and various UI components), the project embeds a complex compiler-like engine. This engine is divided into several modules (analyzer, abstract syntax tree construction, translation, and optimization) and handles tasks such as parsing, semantic analysis, intermediate code generation and optimization.
- In short, the project is a hybrid system: a front-end application (using Quasar/Vue components) that integrates a language processing engine (with its own analyzer, translator, and optimizer modules).

##### Analyzing the File Structure
- Top-Level Files: Configuration files (e.g., package.json, quasar.conf.js, babel.config.js) indicate that the project is managed via standard JavaScript tooling, including build and deployment scripts.
- Front-end/Quasar Layers: The "public" and "src" directories contain Vue components (App.vue, layouts, pages, router) and CSS/SCSS styling—these form the presentation layer.
- Domain Logic Modules:
- The "src/analizador" folder includes grammar definitions (using .jison files) and corresponding JavaScript result files. This is responsible for parsing input (likely using Jison as a parser generator).
- The "src/arbol" directory handles Abstract Syntax Tree (AST) nodes and error reporting (files like nodoAST.js and error.js/ts).
- The "src/traduccion" folder is subdivided into modules for expressions, instructions (with further segregations for assignments, conditionals, cycles, etc.), and code generation utilities like those for generating three-address code (as seen in codigo3D.js/ts). This indicates that translation from a source language to an intermediate representation is a core component.
- The "src/optimizacion" folder contains modules for several optimization strategies (handling both two-address and three-address assignment optimizations, among others). Both JavaScript and TypeScript versions coexist, possibly for gradual migration or additional typing.

- UI Layer:
- Components: Vue components in "src/components", "src/layouts", and "src/pages".
- Router: Navigation configured in "src/router".
- Bootstrapping: Initial configuration in the "src/boot" directory.
- Function: This layer supplies the interface for users to interact with the language processing engine (e.g., displaying the AST, symbol tables, and optimization results).

- Parsing/Analysis Module (Analizador):
- Contains grammar definitions (gramatica.jison, optimizacion.jison) that serve as the entry point for parsing user input.
- Converts source code into a preliminary AST.

- AST and Error Handling Module (Arbol):
- Manages AST node creation (nodoAST.js) and error reporting.
- Interacts with subsequent phases to pass on parsed data.

- Translation Module (Traduccion):
- Responsible for building the intermediate representation (e.g., Three Address Code).
- Organizes various language constructs (expressions, instructions, control structures) and leverages a set of utilities (from "src/traduccion/utils") to manage symbol tables, environments, and code generation.

- Optimization Module (Optimizacion):
- Applies optimization rules to the intermediate code.
- Contains specific implementations (assignment optimizations, control flow optimizations) and works alongside the translation module to refine the generated code.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI/Quasar Front-End"
        A1("App.vue"):::ui
        A2("Components"):::ui
        A3("Layouts"):::ui
        A4("Pages"):::ui
        A5("Router"):::ui
        A6("Boot"):::ui
    end

    %% Domain Processing Engine
    subgraph "Language Processing Engine"
        B1("Parser/Analyzer"):::logic
        B2("AST & Error Handler"):::logic
        B3("Translator (Code Generation)"):::logic
        B4("Optimizer"):::logic
    end

    %% Data Flow Connections
    A6 -->|"InputCode"| B1
    B1 -->|"ParsedAST"| B2
    B2 -->|"IntermediateCode"| B3
    B3 -->|"OptimizedCode"| B4

    %% Click Events
    click A1 "https://github.com/dmomotic/matriosh-ts-c3d/blob/master/src/App.vue"
    click A2 "https://github.com/dmomotic/matriosh-ts-c3d/tree/master/src/components"
    click A3 "https://github.com/dmomotic/matriosh-ts-c3d/tree/master/src/layouts"
    click A4 "https://github.com/dmomotic/matriosh-ts-c3d/tree/master/src/pages"
    click A5 "https://github.com/dmomotic/matriosh-ts-c3d/tree/master/src/router"
    click A6 "https://github.com/dmomotic/matriosh-ts-c3d/tree/master/src/boot"
    
    click B1 "https://github.com/dmomotic/matriosh-ts-c3d/blob/master/src/analizador/gramatica.jison"
    click B2 "https://github.com/dmomotic/matriosh-ts-c3d/blob/master/src/arbol/nodoAST.js"
    click B3 "https://github.com/dmomotic/matriosh-ts-c3d/blob/master/src/traduccion/traduccion.js"
    click B4 "https://github.com/dmomotic/matriosh-ts-c3d/blob/master/src/optimizacion/optimizacion.js"
    
    %% Styles
    classDef ui fill:#AED6F1,stroke:#154360,stroke-width:2px;
    classDef logic fill:#F9E79F,stroke:#7D6608,stroke-width:2px;
```
