# brpapa/recursion-tree-visualizer architecture

> Architecture diagram of the GitHub repository brpapa/recursion-tree-visualizer, 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/brpapa/recursion-tree-visualizer
- Repository: https://github.com/brpapa/recursion-tree-visualizer

## Overview

- Backend (Lambda Function): Show the serverless function that is responsible for executing the user’s code to generate the recursion tree. Inside this component, note the presence of internal modules for validations, error handling, the runner logic (separating out steps for initial, intermediate, final, and source code compilation), and shared static code (utilities and templates).
- Deployment Infrastructure (Terraform): Illustrate how Terraform is used to deploy the Lambda function (and possibly other infrastructure). Although it’s a couple of files, it conceptually ties into how the system is provisioned on the cloud.

##### Interactions and dependencies
- Lambda function processing flow: Receiving the event payload, running through various steps (as indicated by subdirectories under the “runner” folder such as “initial-tree”, “intermediate-tree”, etc.), and then returning the computed tree visualization.
- Optionally, show that during local development and production, there are separate deployment considerations – the Web App is shipped via Vercel while the Lambda is packaged with Docker (local emulation) and deployed with Terraform.

##### Architectural patterns and design principles
- Separation of Concerns: Clearly separate frontend (user interaction and presentation logic) from backend processing (code execution and tree generation).
- Extensibility: The architecture supports plug-and-play components. For example, the runner steps can be thought of as a pipeline processing the user code, which is modular and testable.
- Serverless and Infrastructure as Code: Emphasize the serverless nature of the Lambda component along with Terraform-managed deployment.

##### Additional details
- You may also include a note that tests (found under the “lambda/tests” and “web/tests” directories) ensure each module works as expected, which adds quality assurance to the system’s design.
- Do not leave out the README-provided demo video and live project links that help contextualize how a user would interact with the system.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    U("User"):::user

    %% Frontend Layer - Web Application
    subgraph "Frontend Layer - Web Application"
        WE("Web Application (React/Next.js UI)"):::frontend
        CE("Code Editor"):::frontend
        GV("Graph Viewer"):::frontend
        AS("Static Assets"):::frontend
    end

    %% Backend Layer - Lambda Function
    subgraph "Backend Layer - Lambda Function"
        LF("Lambda Function"):::backend
        VAL("Input Validations"):::backend
        RL("Runner Logic"):::backend
        EH("Error Handling"):::backend
    end

    %% Deployment & Infrastructure
    subgraph "Deployment & Infrastructure"
        TI("Terraform Deployment"):::infra
    end

    %% Connections between layers
    U -->|"submitCode"| WE
    WE -->|"HTTP_Request"| LF
    LF -->|"runValidation"| VAL
    VAL -->|"proceedToRunner"| RL
    RL -->|"ifError"| EH
    RL -->|"generatesTree"| LF
    LF -->|"returnResults"| WE
    AS ---|"providesAssets"| WE

    %% Deployment flow
    TI -->|"deploysLambda"| LF

    %% Styling for vertical layout classes
    class U user
    class WE,CE,GV,AS frontend
    class LF,VAL,RL,EH backend
    class TI infra

click WE "https://github.com/brpapa/recursion-tree-visualizer/tree/master/web/"
click RL "https://github.com/brpapa/recursion-tree-visualizer/tree/master/lambda/src/runner"
click VAL "https://github.com/brpapa/recursion-tree-visualizer/tree/master/lambda/src/validations"
click EH "https://github.com/brpapa/recursion-tree-visualizer/tree/master/lambda/src/errors"
click TI "https://github.com/brpapa/recursion-tree-visualizer/tree/master/terraform/"
click AS "https://github.com/brpapa/recursion-tree-visualizer/tree/master/assets/"

classDef frontend fill:#f9f,stroke:#333,stroke-width:2px;
classDef backend fill:#bbf,stroke:#333,stroke-width:2px;
classDef infra fill:#cfc,stroke:#333,stroke-width:2px;
classDef user fill:#fcf,stroke:#333,stroke-width:2px;
```
