Skip to content

Latest commit

Β 

History

37 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⚑ AI Code Migration Platform

AI-powered Python β†’ C++20 code migration with automated compilation, execution, benchmarking, evaluation, and reporting.


πŸš€ Live Demo Β Β β€’Β Β  πŸ’» GitHub Repository

Python C++20 Streamlit Groq Tests License


πŸš€ Live Application

Try the AI Code Migration Platform

πŸ‘‰ https://ai-code-migration-platform-zievvdkcz9mr83emx2brgv.streamlit.app/

The application is deployed on Streamlit Community Cloud and provides an end-to-end Python-to-C++20 migration workflow.

What the live application does

Python Source
      β”‚
      β–Ό
   AI Analysis
      β”‚
      β–Ό
Python β†’ C++20
      β”‚
      β–Ό
 C++ Compilation
      β”‚
      β–Ό
 Executable
      β”‚
      β–Ό
   Execution
      β”‚
      β–Ό
 Benchmarking
      β”‚
      β–Ό
  Evaluation
      β”‚
      β–Ό
 Migration Report
      β”‚
      β–Ό
  Leaderboard

🧠 Overview

AI Code Migration Platform is a production-oriented AI application designed to automate the migration of Python programs into standalone, compilable modern C++20 programs.

Unlike a basic code translator, the platform validates the entire migration lifecycle:

Translate β†’ Analyze β†’ Compile β†’ Execute β†’ Benchmark β†’ Evaluate β†’ Report

The system uses an extensible provider architecture so different LLM backends can be integrated without changing the core migration pipeline.


✨ Key Capabilities

Capability Status
Python β†’ C++20 translation βœ…
LLM-powered migration βœ…
Groq provider βœ…
Ollama provider βœ…
Provider factory architecture βœ…
Python source analysis βœ…
Automatic C++ compilation βœ…
Executable validation βœ…
Runtime execution βœ…
Multi-run benchmarking βœ…
Migration evaluation βœ…
JSON reporting βœ…
Leaderboard βœ…
CLI interface βœ…
Streamlit interface βœ…
Structured logging βœ…
Centralized exceptions βœ…
Automated test suite βœ…
Cloud deployment βœ…

πŸ—οΈ System Architecture

                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚       User / Client      β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚       CLI / Streamlit       β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚       Input Validation      β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚      Provider Factory       β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   β”‚                                     β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚      Groq       β”‚                  β”‚      Ollama      β”‚
          β”‚      LLM        β”‚                  β”‚       LLM        β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚                                     β”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚        Translator           β”‚
                       β”‚       Python β†’ C++20        β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚      Python Analyzer         β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚         Compiler             β”‚
                       β”‚          g++ / C++20         β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚         Executor             β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚        Benchmark             β”‚
                       β”‚      Multiple Runs           β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚         Evaluator            β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚      Report Generator        β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚       Output Manager         β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚         Leaderboard          β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”„ End-to-End Migration Workflow

The platform treats code migration as a complete engineering pipeline rather than a single LLM request.

1. Source Validation

The input Python file is validated before the migration begins.

2. LLM Translation

The selected provider generates standalone modern C++20 source code.

3. Source Analysis

The Python source is analyzed to provide additional structural information to the migration process.

4. Compilation

Generated C++ is compiled using the configured C++ compiler and C++20 standard.

5. Execution

The compiled executable is executed with configurable timeout protection.

6. Benchmarking

The generated program is executed multiple times to calculate runtime performance.

7. Evaluation

Translation, compilation, execution, and benchmark results are aggregated into an overall migration result.

8. Reporting

A structured migration report is generated.

9. Leaderboard

Migration results can be recorded for performance comparison.


πŸ€– LLM Provider Architecture

The project uses a provider abstraction to keep LLM integrations independent from the migration pipeline.

                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚    BaseProvider      β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚                      β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚  GroqProvider   β”‚    β”‚ OllamaProvider  β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Groq

The deployed application currently uses:

Provider: Groq
Model: openai/gpt-oss-120b

Ollama

Ollama support allows local LLM execution during development and experimentation.

The provider factory makes it possible to add future providers without rewriting the migration pipeline.


πŸ› οΈ Technology Stack

Core

  • Python
  • C++20
  • g++

AI / LLM

  • Groq
  • Ollama

Application

  • Streamlit
  • argparse

Engineering

  • Pytest
  • Ruff
  • Black
  • python-dotenv
  • Structured logging
  • Custom exception hierarchy

Deployment

  • GitHub
  • Streamlit Community Cloud

πŸ“‚ Project Structure

AI-Code-Migration-Platform/
β”‚
β”œβ”€β”€ analyzer/
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── python_analyzer.py
β”‚
β”œβ”€β”€ benchmark/
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── benchmark.py
β”‚
β”œβ”€β”€ cli/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ arguments.py
β”‚   └── validators.py
β”‚
β”œβ”€β”€ compiler/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ compiler.py
β”‚   └── executor.py
β”‚
β”œβ”€β”€ evaluator/
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── evaluator.py
β”‚
β”œβ”€β”€ leaderboard/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ leaderboard_entry.py
β”‚   β”œβ”€β”€ leaderboard_store.py
β”‚   └── manager.py
β”‚
β”œβ”€β”€ pipeline/
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── migration_pipeline.py
β”‚
β”œβ”€β”€ providers/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ base_provider.py
β”‚   β”œβ”€β”€ groq_provider.py
β”‚   β”œβ”€β”€ ollama_provider.py
β”‚   └── provider_factory.py
β”‚
β”œβ”€β”€ report/
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── report_generator.py
β”‚
β”œβ”€β”€ translator/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ prompt_builder.py
β”‚   └── translator.py
β”‚
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ exceptions.py
β”‚   β”œβ”€β”€ helpers.py
β”‚   └── logger.py
β”‚
β”œβ”€β”€ workspace/
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── workspace_manager.py
β”‚
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ test_analyzer/
β”‚   β”œβ”€β”€ test_benchmark/
β”‚   β”œβ”€β”€ test_cli/
β”‚   β”œβ”€β”€ test_compiler/
β”‚   β”œβ”€β”€ test_evaluator/
β”‚   β”œβ”€β”€ test_groq/
β”‚   β”œβ”€β”€ test_leaderboard/
β”‚   β”œβ”€β”€ test_pipeline/
β”‚   β”œβ”€β”€ test_report/
β”‚   β”œβ”€β”€ test_translator/
β”‚   β”œβ”€β”€ test_workspace/
β”‚   └── test_main.py
β”‚
β”œβ”€β”€ app.py
β”œβ”€β”€ config.py
β”œβ”€β”€ main.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .env.example
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
└── README.md

βš™οΈ Getting Started

Prerequisites

Make sure the following are installed:

  • Python 3.x
  • Git
  • g++
  • An LLM provider/API key

1. Clone

git clone https://github.com/creatorKrishna05/ai-code-migration-platform.git
cd ai-code-migration-platform

2. Create Virtual Environment

Windows

python -m venv .venv
.venv\Scripts\activate

Linux / macOS

python -m venv .venv
source .venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

πŸ” Configuration

Create a .env file from .env.example.

Example:

GROQ_API_KEY=your_groq_api_key

For Streamlit Cloud, configure secrets through the application's deployment settings.

Never commit API keys or credentials to GitHub.


πŸ’» CLI

The platform includes a complete command-line interface.

Basic migration

python main.py migrate examples/sample.py

Select provider

python main.py migrate examples/sample.py --provider groq

Select model

python main.py migrate examples/sample.py \
    --provider groq \
    --model "openai/gpt-oss-120b"

Configure benchmark runs

python main.py migrate examples/sample.py --benchmark-runs 5

Configure execution timeout

python main.py migrate examples/sample.py --timeout 30

Generate JSON report

python main.py migrate examples/sample.py --report-json

🌐 Run the Web Application

Start Streamlit locally:

streamlit run app.py

Then open the local Streamlit URL displayed in the terminal.


πŸ“Š Benchmarking

The benchmark system executes the generated program multiple times and calculates the average runtime.

Example production verification:

Benchmark runs:       5
Average execution:    0.001900 seconds

This provides a simple performance signal for generated C++ programs.


πŸ“„ Output Artifacts

A successful migration can generate:

outputs/
β”œβ”€β”€ source.cpp
β”œβ”€β”€ program
β”œβ”€β”€ report.json
└── leaderboard.json

On Windows, the compiled executable may use:

program.exe

The exact executable name depends on the operating system.


πŸ† Leaderboard

The leaderboard tracks migration results and provides a foundation for comparing migration performance.

Current local storage:

outputs/leaderboard.json

For production-scale deployments, persistent external storage can be introduced in future iterations.


πŸ§ͺ Testing & Quality

The project has a comprehensive automated test suite.

Run:

python -m pytest -q

Current verification

170 passed in 3.67s

Coverage areas

  • CLI argument parsing
  • CLI validation
  • Provider initialization
  • Groq provider
  • Ollama provider
  • Translation
  • Python analysis
  • Compilation
  • Execution
  • Benchmarking
  • Evaluation
  • Reporting
  • Leaderboard
  • Workspace management
  • Pipeline orchestration
  • Application entry point

☁️ Production Deployment

The application is deployed on Streamlit Community Cloud.

Live application

πŸš€ https://ai-code-migration-platform-zievvdkcz9mr83emx2brgv.streamlit.app/

The deployed environment has successfully completed an end-to-end migration using:

Groq
  ↓
openai/gpt-oss-120b
  ↓
Python β†’ C++20
  ↓
g++
  ↓
Executable
  ↓
5Γ— Benchmark
  ↓
Evaluation
  ↓
Report
  ↓
Leaderboard

Production verification

Application startup             βœ…
Dependencies                    βœ…
Groq provider                   βœ…
LLM generation                  βœ…
Translation                     βœ…
C++ compilation                 βœ…
Executable execution            βœ…
Benchmarking                    βœ…
Evaluation                      βœ…
Report generation               βœ…
Output generation               βœ…
Leaderboard                     βœ…
End-to-end pipeline             βœ…

πŸ›‘οΈ Error Handling

The platform implements centralized exception handling.

Supported failure categories include:

  • CLI validation errors
  • Provider errors
  • Translation errors
  • Compilation errors
  • Execution errors
  • Benchmarking errors
  • Evaluation errors
  • Pipeline errors

CLI exit codes:

0 β†’ Success
1 β†’ Application / migration failure
2 β†’ Invalid CLI input

πŸ“ Logging

The application uses structured logging across the migration lifecycle.

Example:

Starting migration pipeline.
Starting code translation.
Sending translation request to Groq.
Code translation completed successfully.
Starting C++ compilation.
C++ compilation completed successfully.
Execution completed with return code: 0.
Benchmark completed.
Evaluation completed successfully.
Migration report generated successfully.
Migration pipeline completed successfully.

πŸ”’ Security

Generated C++ code is compiled and executed as part of the migration process.

Current safeguards include:

  • Configurable execution timeout
  • Temporary workspaces
  • Input validation
  • Structured exception handling
  • Environment-based secret management
  • Controlled compilation workflow

For unrestricted production workloads, additional isolation such as containerization or sandboxed execution is recommended.


🧭 Engineering Principles

The project is designed around several software engineering principles:

Separation of Concerns

Each major responsibility is implemented as an independent service.

Provider Abstraction

LLM providers implement a common interface.

Dependency Injection

Core pipeline components are wired explicitly through the application composition layer.

Centralized Error Handling

Application failures use a structured exception hierarchy.

Testability

Services are independently testable through unit and integration tests.

Observability

Important pipeline events are captured through structured logging.

Extensibility

New providers and migration capabilities can be added without redesigning the entire system.


🚧 Roadmap

Near Term

  • Stronger execution sandboxing
  • Persistent cloud leaderboard
  • Improved Streamlit result dashboard
  • Migration history
  • Better generated-code validation
  • More integration tests

Future

  • Additional LLM providers
  • Containerized compilation
  • Advanced performance analytics
  • Parallel benchmarking
  • Semantic equivalence checking
  • Multi-language migration support
  • Enterprise deployment architecture

🎯 Why This Project?

Traditional code migration can require significant manual effort.

This platform explores how LLMs can be integrated into a complete software engineering workflow, where generated code is not simply returned to the user but is:

Generated
   ↓
Analyzed
   ↓
Compiled
   ↓
Executed
   ↓
Benchmarked
   ↓
Evaluated
   ↓
Reported

This makes the project more than an AI code-generation demoβ€”it is an end-to-end AI-assisted migration pipeline.


πŸ“ˆ Project Status

Area Status
Core architecture 🟒 Complete
Python β†’ C++20 migration 🟒 Complete
Groq integration 🟒 Complete
Ollama integration 🟒 Complete
Compiler pipeline 🟒 Complete
Execution pipeline 🟒 Complete
Benchmarking 🟒 Complete
Evaluation 🟒 Complete
Reporting 🟒 Complete
Leaderboard 🟒 Complete
CLI 🟒 Complete
Streamlit UI 🟒 Complete
Cloud deployment 🟒 Complete
Automated tests 🟒 170 passed
Advanced sandboxing 🟑 Planned
Persistent cloud storage 🟑 Planned

πŸ‘¨β€πŸ’» Author

Krishna

BCA Student & AI/ML Developer

GitHub: https://github.com/creatorKrishna05


πŸ“œ License

This project is licensed under the MIT License.

See LICENSE for details.


⭐ Support the Project

If you find this project interesting or useful:

⭐ Star the repository

🍴 Fork the project

πŸ› Open an issue

πŸ’‘ Suggest an improvement


πŸš€ AI Code Migration Platform

Translate. Compile. Execute. Benchmark. Evaluate.


🌐 Launch Live Demo β†’

About

AI-powered Python to Modern C++20 code migration platform using LLMs, compilation, benchmarking, evaluation and leaderboard analytics.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages