# harshitha14-cyber/codetune architecture

> Architecture diagram of the GitHub repository harshitha14-cyber/codetune, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/harshitha14-cyber/codetune
- Repository: https://github.com/harshitha14-cyber/codetune

## Overview

CodeTune is a multi-language compiler optimizer: source is parsed and translated into a common IR, analyzed and optimized, then differentially validated. Its Digital Twin evaluates optimization strategies, while the dashboard, Copilot, and report generation expose results. The README documents the overall workflow and capabilities; sampled source confirms key selector, validation, interpreter, and dashboard behavior. Some subsystem connections rely on README documentation because their implementation was not sampled.

Main entry points: [`optimizer/pass_manager.py`](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/optimizer/pass_manager.py) (Pass Manager), [`digital_twin/twin.py`](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/digital_twin/twin.py) (Strategy Experiments), [`ir/ir_nodes.py`](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/ir/ir_nodes.py) (Common IR), [`copilot/copilot.py`](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/copilot/copilot.py) (Copilot)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Front End"]
  node_parser["Language Parser<br/>[parser.py]"]
  node_translator["IR Translators"]
  node_common_ir["Common IR<br/>[ir_nodes.py]"]
end

subgraph group_optimizer["Analysis and Optimization"]
  node_features["Feature Extraction"]
  node_rules["Rule Selector<br/>[pass_selector.py]"]
  node_ml["ML Selector<br/>[ml_selector.py]"]
  node_pass_manager["Pass Manager<br/>[pass_manager.py]"]
  node_passes["Optimization Passes"]
end

subgraph group_validation_twin["Validation and Digital Twin"]
  node_validator["Differential Validator"]
  node_interpreter["IR Interpreter<br/>[interpreter.py]"]
  node_twin["Strategy Experiments<br/>[twin.py]"]
  node_cost_model["Cost Model<br/>[cost_model.py]"]
  node_sandbox["Strategy Sandbox<br/>[sandbox.py]"]
end

subgraph group_assist["Insights and Assistance"]
  node_copilot["Copilot<br/>[copilot.py]"]
  node_knowledge["Code Knowledge<br/>[knowledge.py]"]
  node_llm["Optional Gemini<br/>[llm.py]"]
  node_refactor["Refactoring<br/>[refactor.py]"]
end

subgraph group_delivery["User Interfaces and Reports"]
  node_dashboard["Dashboard Server<br/>[server.py]"]
  node_dashboard_ui["Dashboard UI<br/>[app.js]"]
  node_reports["Reports"]
end

node_user(("Developer"))
node_source["Source Code"]
node_developer["Optimized Results"]

node_user -->|"provides"| node_source
node_source -->|"parses"| node_parser
node_parser -->|"translates syntax"| node_translator
node_translator -->|"produces IR"| node_common_ir
node_common_ir -->|"extracts features"| node_features
node_features -->|"informs selection"| node_rules
node_rules -.->|"optional comparison"| node_ml
node_rules -->|"selects passes"| node_pass_manager
node_ml -.->|"optional selection"| node_pass_manager
node_pass_manager -->|"runs passes"| node_passes
node_pass_manager -->|"checks candidates"| node_validator
node_validator -->|"executes comparisons"| node_interpreter
node_pass_manager -->|"returns optimized code"| node_developer
node_common_ir -->|"evaluates strategies"| node_twin
node_twin -->|"predicts cost"| node_cost_model
node_twin -->|"runs experiments"| node_sandbox
node_twin -->|"validates strategies"| node_validator
node_common_ir -->|"supplies code context"| node_copilot
node_copilot -->|"answers from analysis"| node_knowledge
node_copilot -.->|"optionally consults"| node_llm
node_copilot -->|"offers refactoring"| node_refactor
node_user -->|"uses"| node_dashboard
node_dashboard_ui -.->|"sends requests"| node_dashboard
node_dashboard -->|"presents results"| node_developer
node_pass_manager -->|"formats run"| node_reports
node_twin -->|"formats twin results"| node_reports
node_reports -->|"delivers reports"| node_developer

click node_parser "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/frontend/parser.py"
click node_translator "https://github.com/harshitha14-cyber/codetune/tree/milestone-1/ir/translators"
click node_common_ir "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/ir/ir_nodes.py"
click node_features "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/analysis/feature_extractor.py"
click node_rules "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/analysis/pass_selector.py"
click node_ml "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/ml/ml_selector.py"
click node_pass_manager "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/optimizer/pass_manager.py"
click node_passes "https://github.com/harshitha14-cyber/codetune/tree/milestone-1/optimizer"
click node_validator "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/validation/differential_tester.py"
click node_interpreter "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/ir/interpreter.py"
click node_twin "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/digital_twin/twin.py"
click node_cost_model "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/digital_twin/cost_model.py"
click node_sandbox "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/digital_twin/sandbox.py"
click node_copilot "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/copilot/copilot.py"
click node_knowledge "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/copilot/knowledge.py"
click node_llm "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/copilot/llm.py"
click node_refactor "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/copilot/refactor.py"
click node_dashboard "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/dashboard/server.py"
click node_dashboard_ui "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/dashboard/static/app.js"
click node_reports "https://github.com/harshitha14-cyber/codetune/blob/milestone-1/reporting/report_generator.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_parser,node_translator,node_common_ir toneBlue
class node_features,node_rules,node_ml,node_pass_manager,node_passes toneAmber
class node_validator,node_interpreter,node_twin,node_cost_model,node_sandbox toneMint
class node_copilot,node_knowledge,node_llm,node_refactor toneRose
class node_dashboard,node_dashboard_ui,node_reports,node_user,node_source,node_developer toneIndigo
```

## Components

### Front End

- [Language Parser](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/frontend/parser.py): `frontend/parser.py`
- [IR Translators](https://github.com/harshitha14-cyber/codetune/tree/milestone-1/ir/translators): `ir/translators`
- [Common IR](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/ir/ir_nodes.py): `ir/ir_nodes.py`

### Analysis and Optimization

- [Feature Extraction](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/analysis/feature_extractor.py): `analysis/feature_extractor.py`
- [Rule Selector](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/analysis/pass_selector.py): `analysis/pass_selector.py`
- [ML Selector](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/ml/ml_selector.py): `ml/ml_selector.py`
- [Pass Manager](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/optimizer/pass_manager.py): `optimizer/pass_manager.py`
- [Optimization Passes](https://github.com/harshitha14-cyber/codetune/tree/milestone-1/optimizer): `optimizer`

### Validation and Digital Twin

- [Differential Validator](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/validation/differential_tester.py): `validation/differential_tester.py`
- [IR Interpreter](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/ir/interpreter.py): `ir/interpreter.py`
- [Strategy Experiments](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/digital_twin/twin.py): `digital_twin/twin.py`
- [Cost Model](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/digital_twin/cost_model.py): `digital_twin/cost_model.py`
- [Strategy Sandbox](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/digital_twin/sandbox.py): `digital_twin/sandbox.py`

### Insights and Assistance

- [Copilot](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/copilot/copilot.py): `copilot/copilot.py`
- [Code Knowledge](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/copilot/knowledge.py): `copilot/knowledge.py`
- [Optional Gemini](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/copilot/llm.py): `copilot/llm.py`
- [Refactoring](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/copilot/refactor.py): `copilot/refactor.py`

### User Interfaces and Reports

- [Dashboard Server](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/dashboard/server.py): `dashboard/server.py`
- [Dashboard UI](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/dashboard/static/app.js): `dashboard/static/app.js`
- [Reports](https://github.com/harshitha14-cyber/codetune/blob/milestone-1/reporting/report_generator.py): `reporting/report_generator.py`

### Other components

- **Developer**
- **Source Code**
- **Optimized Results**

## Connections

- Developer → Source Code: provides (evidence: `README.md`)
- Source Code → Language Parser: parses (evidence: `README.md`)
- Language Parser → IR Translators: translates syntax (evidence: `README.md`)
- IR Translators → Common IR: produces IR (evidence: `README.md`)
- Common IR → Feature Extraction: extracts features (evidence: `README.md`)
- Feature Extraction → Rule Selector: informs selection (evidence: `analysis/pass_selector.py`)
- Rule Selector → ML Selector: optional comparison (evidence: `README.md`)
- Rule Selector → Pass Manager: selects passes (evidence: `README.md`)
- ML Selector → Pass Manager: optional selection (evidence: `README.md`)
- Pass Manager → Optimization Passes: runs passes (evidence: `optimizer/pass_manager.py`)
- Pass Manager → Differential Validator: checks candidates (evidence: `optimizer/pass_manager.py`)
- Differential Validator → IR Interpreter: executes comparisons (evidence: `validation/differential_tester.py`)
- Pass Manager → Optimized Results: returns optimized code (evidence: `README.md`)
- Common IR → Strategy Experiments: evaluates strategies (evidence: `README.md`)
- Strategy Experiments → Cost Model: predicts cost (evidence: `digital_twin/twin.py`)
- Strategy Experiments → Strategy Sandbox: runs experiments (evidence: `digital_twin/twin.py`)
- Strategy Experiments → Differential Validator: validates strategies (evidence: `digital_twin/twin.py`)
- Common IR → Copilot: supplies code context (evidence: `README.md`)
- Copilot → Code Knowledge: answers from analysis (evidence: `copilot/copilot.py`)
- Copilot → Optional Gemini: optionally consults (evidence: `README.md`)
- Copilot → Refactoring: offers refactoring (evidence: `copilot/copilot.py`)
- Developer → Dashboard Server: uses (evidence: `README.md`)
- Dashboard UI → Dashboard Server: sends requests (evidence: `README.md`)
- Dashboard Server → Optimized Results: presents results (evidence: `README.md`)
- Pass Manager → Reports: formats run (evidence: `README.md`)
- Strategy Experiments → Reports: formats twin results (evidence: `README.md`)
- Reports → Optimized Results: delivers reports (evidence: `README.md`)
