# etdloauldaol/optimizer-and-legalizer-co-optimization architecture

> Architecture diagram of the GitHub repository etdloauldaol/optimizer-and-legalizer-co-optimization, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/etdloauldaol/optimizer-and-legalizer-co-optimization
- Repository: https://github.com/etdloauldaol/optimizer-and-legalizer-co-optimization

## Overview

##### Project type and purpose
- This is a monorepo of related CLI and web tools for “optimizer and legalizer co-optimization” lab tasks.
- Key components:
– Multiple Python scripts (CLI utilities) for analyses and conversions
– Video/GIF generators
– Two web front-ends (Node.js “WebCanvas” and Flask “web4MP4”)
– A shared “testcase” directory containing canonical input files (.lg, .opt)

##### File structure
Top-level folders:
- DieUtilRate – Python tool to compute utilization rates
- GenMP4 – Python + ffmpeg pipeline for MP4 generation
- GifAnimation – Python script to turn logs into GIFs
- Evaluator – (empty or placeholder for future evaluation code)
- WebCanvas – Node.js front-end that visualizes logs on HTML5 canvas
- web4MP4 – Flask app serving generated MP4s via a web UI
- testcase – shared inputs and a Python test harness
Notice pattern: CLI→data→visualization→web service.

##### README for extra clues
- README is minimal—no internal architecture docs. All insights must come from folder names, file types, and standard conventions (e.g. environment.yml → Conda Python).

##### Main components and interactions
A. Inputs (testcase/*.lg, testcase/*.opt)
B. CLI analyzers (Python scripts in DieUtilRate/, Evaluator/, testcase/testcase_checker.py)
– Produce .lg_post or .json analysis artifacts
C. Visualization pipelines:
1. GifAnimation/main.py
→ reads .lg/.opt → writes GIFs
2. GenMP4/main.py
→ reads .lg/.opt → calls ffmpeg → writes MP4s in GenMP4/mp4
D. Web front-ends:
1. WebCanvas (Node.js)
– Serves static HTML/JS
– Loads raw log data and video assets
2. web4MP4 (Flask/Python)
– Serves an index.html template
– Exposes static MP4s under /static
– Dependencies listed in requirements.txt

##### Architectural patterns & design principles
– Separation of concerns:
- Data processing (Python CLI)
- Asset generation (videos/GIFs)
- Presentation/UI (Node.js + Flask)
– File-based data flow: each stage reads/writes to disk
– Reusability: shared testcase folder as single source of truth
– Modular: each tool has its own directory, env spec, and CI potential

## Diagram (Mermaid)

```mermaid
graph TB
    %% Data Stores
    TC["Testcase Store<br/>(.lg/.opt)"]:::store

    %% Processing Layer
    subgraph "Data Processing (Python CLIs)"
        Checker["Testcase Checker CLI<br/>(Python)"]:::python
        DieRate["DieUtilRate CLI<br/>(Python)"]:::python
        GifCLI["GifAnimation CLI<br/>(Python)"]:::python
        MP4CLI["GenMP4 CLI<br/>(Python + ffmpeg)"]:::python
    end

    %% Output Stores
    GifOut["GIF Outputs"]:::store
    MP4Out["MP4 Outputs"]:::store

    %% Presentation Layer
    subgraph "Web Interfaces"
        WebCanvas["WebCanvas Frontend<br/>(Node.js)"]:::web
        web4MP4["web4MP4 Backend<br/>(Flask)"]:::web
    end

    %% Data Flows
    TC -->|".lg/.opt"| Checker
    TC -->|".lg/.opt"| DieRate
    TC -->|".lg/.opt"| GifCLI
    TC -->|".lg/.opt"| MP4CLI

    Checker -->|"analysis (.json/.lg_post)"| WebCanvas
    DieRate -->|"utilization rates"| WebCanvas
    GifCLI -->|".gif"| GifOut
    MP4CLI -->|".mp4"| MP4Out

    TC -->|"raw logs"| WebCanvas
    GifOut -->|"GIF assets"| WebCanvas
    MP4Out -->|"MP4 assets"| web4MP4

    %% Click Events
    click TC "https://github.com/etdloauldaol/optimizer-and-legalizer-co-optimization/tree/main/testcase/"
    click Checker "https://github.com/etdloauldaol/optimizer-and-legalizer-co-optimization/blob/main/testcase/testcase_checker.py"
    click DieRate "https://github.com/etdloauldaol/optimizer-and-legalizer-co-optimization/blob/main/DieUtilRate/UTIL_RATE.py"
    click GifCLI "https://github.com/etdloauldaol/optimizer-and-legalizer-co-optimization/blob/main/GifAnimation/main.py"
    click MP4CLI "https://github.com/etdloauldaol/optimizer-and-legalizer-co-optimization/blob/main/GenMP4/main.py"
    click MP4Out "https://github.com/etdloauldaol/optimizer-and-legalizer-co-optimization/tree/main/GenMP4/mp4/"
    click WebCanvas "https://github.com/etdloauldaol/optimizer-and-legalizer-co-optimization/blob/main/WebCanvas/server.js"
    click WebCanvas "https://github.com/etdloauldaol/optimizer-and-legalizer-co-optimization/tree/main/WebCanvas/public/"
    click WebCanvas "https://github.com/etdloauldaol/optimizer-and-legalizer-co-optimization/tree/main/WebCanvas/data/"
    click WebCanvas "https://github.com/etdloauldaol/optimizer-and-legalizer-co-optimization/blob/main/WebCanvas/package.json"
    click web4MP4 "https://github.com/etdloauldaol/optimizer-and-legalizer-co-optimization/blob/main/web4MP4/app.py"
    click web4MP4 "https://github.com/etdloauldaol/optimizer-and-legalizer-co-optimization/blob/main/web4MP4/templates/index.html"
    click web4MP4 "https://github.com/etdloauldaol/optimizer-and-legalizer-co-optimization/tree/main/web4MP4/static/"
    click web4MP4 "https://github.com/etdloauldaol/optimizer-and-legalizer-co-optimization/blob/main/web4MP4/requirements.txt"

    %% Styles
    classDef python fill:#D0E6FF,stroke:#4C78A8,color:#0B3D91
    classDef web fill:#DFF2D8,stroke:#4C9663,color:#256029
    classDef store fill:#F0F0F0,stroke:#888888,color:#333333
```
