# unbcic-tp2/r-python architecture

> Architecture diagram of the GitHub repository unbcic-tp2/r-python, 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/unbcic-tp2/r-python
- Repository: https://github.com/unbcic-tp2/r-python

## Overview

##### Main Components
- Main Entry Point: Represent the main.rs file as the primary entry that orchestrates the compilation process.
- Intermediate Representation (IR): Include a component for the IR layer from src/ir (and its ast.rs file). This layer represents the internal structure of the program after parsing.
- Supporting Artifacts: Indicate areas for configuration and build (Cargo.toml, Cargo.lock, CI workflows) which, though not part of the runtime flow, affect development and deployment.

##### Relationships and Data Flow
- Start from the Main Entry Point, which passes the source code to the Parser.
- The Parser outputs an AST that is encapsulated in the IR component.
- The output from the IR is then sent to the Type Checker for validation.
- Upon successful type checking, control is transferred to the Interpreter for execution (or further transformation/compilation).

##### Architectural Patterns and Design Principles
- Layered Architecture: Emphasize how each component (parsing, IR generation, type checking, execution) is isolated into separate modules.
- Modularity and Separation of Concerns: Each directory (parser, ir, tc, interpreter) has a clearly defined role.
- Educational/Experimental Nature: Acknowledge that this design facilitates experimentation within different compilation phases.

##### Relevant Technologies
- Continuous integration components (e.g., GitHub workflows) as part of the development ecosystem, though they might not be part of the runtime architecture.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Compiler Components Subgraph
    subgraph "Compiler Components"
        rust["Rust"]
        main["Main Entry Point"]
        parser["Parser"]
        ir["IR (AST)"]
        tc["Type Checker"]
        interp["Interpreter"]
        
        rust ---|"implemented"| main
        main -->|"passes_source_code_to"| parser
        parser -->|"generates_AST_for"| ir
        ir -->|"feeds_IR_to"| tc
        tc -->|"triggers_execution_in"| interp
    end

    %% Supporting Artifacts Subgraph
    subgraph "Supporting Artifacts"
        a1["Cargo.toml"]
        a2["Cargo.lock"]
        a3["CI Workflow"]
    end

    %% Styling for better visualization
    class main,parser,ir,tc,interp core
    class a1,a2,a3 support
    class rust tech

    %% Click Events for Components
    click main "https://github.com/unbcic-tp2/r-python/blob/main/src/main.rs"
    click parser "https://github.com/unbcic-tp2/r-python/blob/main/src/parser/parser.rs"
    click ir "https://github.com/unbcic-tp2/r-python/blob/main/src/ir/ast.rs"
    click tc "https://github.com/unbcic-tp2/r-python/blob/main/src/tc/type_checker.rs"
    click interp "https://github.com/unbcic-tp2/r-python/blob/main/src/interpreter/interpreter.rs"
    click a1 "https://github.com/unbcic-tp2/r-python/blob/main/Cargo.toml"
    click a2 "https://github.com/unbcic-tp2/r-python/blob/main/Cargo.lock"
    click a3 "https://github.com/unbcic-tp2/r-python/blob/main/.github/workflows/ci.yml"

    %% Class Definitions with Colors
    classDef core fill:#BBF,stroke:#333,stroke-width:2px;
    classDef support fill:#F9E79F,stroke:#333,stroke-width:2px;
    classDef tech fill:#CFC,stroke:#333,stroke-width:2px;
```
