# sudokentucky/olc1_proyecto2_202100106 architecture

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

- Interactive diagram: https://gitdiagram.com/sudokentucky/olc1_proyecto2_202100106
- Repository: https://github.com/sudokentucky/olc1_proyecto2_202100106

## Overview

Below are guidelines that specifically capture the essential architectural elements:

##### Main Components
- Back-end Interpreter Engine:
- Parser & Grammar: Located in back-end/Grammar (using Jison in parser.jison). This component is responsible for lexing/parsing the source input.
- Analyzer/Interpreter: Under back-end/src/Analizador, you see directories for instructions, expressions, environment (symbol tables, arrays), error handling, and abstract syntax tree (AST) generation. These modules form the core execution and interpretation logic.
- AST & DOT Generation: The presence of back-end/src/Analizador/Tree (including AST.ts and DotGenerator.ts) signals that the AST is built and potentially visualized with Graphviz dot language.
- Documentation & Manuals: The Documentacion folder includes technical and user manuals which could be referenced as part of system documentation but are not part of runtime architecture.

- Front-end User Interface:
- UI Components: Found under front-end/src/components (e.g., AST.tsx, CommandExecution.tsx, ErrorTable.tsx, SymbolTable.tsx, Navbar.tsx, FileInput.tsx). These provide the different views for interacting with the system.
- Custom Hooks: In front-end/src/hooks (such as useCommandExecution, useErrors, useGenerateDot, and useSymbolTable) which abstract state management and behavior for handling outputs from the back-end.
- Entry and Configuration: The index.html, main.tsx along with Vite configuration files establish how the application is bootstrapped.

##### Understand the Relationships and Interactions
- The Front-end acts as the presentation layer, gathering program inputs (e.g., via FileInput.tsx) and streaming commands.
- The input is then handed over—directly or via an API call—to the Back-end Interpreter.
- Within the back-end, the parser (using the Jison grammar) processes the source code to generate an AST.
- The Analyzer/Interpreter traverses the AST, invoking various Instruction modules, Expression handlers, and updating the Environment (symbol tables) accordingly.
- As analysis proceeds, errors are captured and aggregated, while the AST might be translated into a DOT graph for visualization.
- Processed results (for example, execution outcomes, errors, and symbol table details) are then sent back to the front-end where they are rendered in appropriate components.

##### Important Architectural Patterns/Design Principles
- Separation of Concerns: The project clearly separates the interpreter logic (back-end) from the user interface (front-end).
- Modular Design: Diverse language constructs are implemented in distinct modules (e.g., separate files for each instruction like loops, conditionals, arithmetic).
- Extensibility: The back-end’s rich module structure (with abstract and concrete implementations of expressions and instructions) supports future language enhancements.
- Clear Data Flow: With dedicated hooks in the front-end processing data streams (outputs such as errors, AST graphs), the design highlights a unidirectional data flow.

##### Relevant Technologies, Frameworks, and Libraries
- Node.js & TypeScript: The back-end is written in TypeScript (tsconfig.json present), and the project uses Node.js features.
- Jison: For grammar parsing & language processing.
- React with Vite: The front-end is built using React with Vite as the build tool.
- Graphviz (implied by DotGenerator.ts): For AST visualization.

- The Grammar/Parser module (using Jison)
- The Analyzer/Interpreter module, broken down to show sub-components (Environment management, Error processing, Instruction execution)
- The AST and DOT Generation sub-module.
- Input flow from Front-end → Back-end (code submission).
- Processing flow inside the Back-end (from Parser → AST → Execution/Analysis).
- Output flow from Back-end → Front-end (execution results, error logs, graphical representations).
- Annotations highlighting design principles like “Separation of Concerns” and “Modularity”.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Node
    U("User Input"):::external

    %% Front-end Subgraph
    subgraph "Front-end"
        FE1("UI Components (AST, CommandExecution, ErrorTable, FileInput, Navbar, SymbolTable)"):::frontend
        FE2("Custom Hooks (useCommandExecution, useErrors, useGenerateDot, useLineCounter, useSymbolTable)"):::frontend
        FE3("Entry: index.html"):::frontend
        FE4("Main: main.tsx"):::frontend
    end

    %% Back-end Interpreter Subgraph
    subgraph "Back-end Interpreter"
        BE1("Parser (Jison)"):::backend
        BE2("AST & DOT Generation"):::backend
        BE3("Interpreter Core (Analyzer, Instructions, Environment, ErrorHandler)"):::backend
        BE4("Documentation & Manuals"):::backend
    end

    %% Data Flow Connections
    U --> FE1
    FE1 -->|"submitCode"| BE1
    BE1 -->|"buildAST"| BE2
    BE2 -->|"executeAnalysis"| BE3
    BE3 -->|"returnResults"| FE1

    %% Class Definitions for coloring
    classDef backend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef frontend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;

    %% Click Events for component mapping
    click BE1 "https://github.com/sudokentucky/olc1_proyecto2_202100106/blob/main/back-end/Grammar/parser.jison"
    click BE3 "https://github.com/sudokentucky/olc1_proyecto2_202100106/tree/main/back-end/src/Analizador"
    click BE2 "https://github.com/sudokentucky/olc1_proyecto2_202100106/tree/main/back-end/src/Analizador/Tree"
    click BE4 "https://github.com/sudokentucky/olc1_proyecto2_202100106/tree/main/back-end/Documentacion"
    click FE1 "https://github.com/sudokentucky/olc1_proyecto2_202100106/tree/main/front-end/src/components"
    click FE2 "https://github.com/sudokentucky/olc1_proyecto2_202100106/tree/main/front-end/src/hooks"
    click FE3 "https://github.com/sudokentucky/olc1_proyecto2_202100106/blob/main/front-end/index.html"
    click FE4 "https://github.com/sudokentucky/olc1_proyecto2_202100106/blob/main/front-end/src/main.tsx"
```
