# Legacy2Modern (L2M) โ AI Legacy Code Transpilation Engine
<div align="center">
<!-- Keep the gap above this line, otherwise they won't render correctly! -->
[](https://github.com/astrio-ai/openlegacy)
[](https://discord.gg/2BVwAUzW)
[](https://github.com/openrewrite/.github/blob/main/CONTRIBUTING.md)
</div>

Welcome to **Legacy2Modern (L2M)**, an open-source engine for transforming legacy source code into modern, maintainable software.
L2M specializes in **intelligent transpilation** of legacy languages (starting with COBOL) and **website modernization** into modern frameworks. It combines the precision of AST-based parsing with the flexibility of template-driven code generation, optionally augmented by Large Language Models (LLMs).
Whether you're modernizing COBOL business systems, migrating legacy websites to React/Next.js/Astro, or transforming decades-old enterprise code โ L2M is built to help you do it **safely**, **accurately**, and **transparently**.
## โจ Features
* ๐ **COBOL to Python Transpilation**
Translate COBOL programs into modern Python code with multiple transpilation approaches.
* ๐ **Legacy Website Modernization**
Transform HTML + Bootstrap + jQuery + PHP websites into modern React, Next.js, or Astro applications.
* ๐ฅ๏ธ **Modern CLI Interface**
Beautiful, interactive command-line interface with natural language commands and AI-powered analysis.
* ๐ง **Lossless Semantic Tree (LST) Parsing**
ANTLR4-based parser that retains all source code information including comments, whitespace, and semantic context.
* ๐๏ธ **Intermediate Representation (IR) System**
Language-agnostic IR that enables extensibility to other source and target languages.
* ๐ **Template-Based Code Generation**
Jinja2-powered template system for clean, maintainable code generation.
* ๐ค **AI-Powered Analysis & Optimization**
LLM integration for code analysis, review, and optimization suggestions with multi-provider support.
* ๐ฏ **Multiple Transpilation Approaches**
- Direct COBOL โ Python transpilation
- IR-based transpilation with templates
- Hybrid transpilation with LLM augmentation
- Static site modernization with framework selection
- Extensible architecture for future languages
* ๐งช **Comprehensive Testing Framework**
Unit tests, integration tests, and validation for all transpilation components.
* ๐ฆ **Easy Installation Options**
- Homebrew installation: `brew install legacy2modern-cli`
- Direct installation: `pip install -e .`
- Run without installation: `python run_cli.py`
## ๐ Quickstart
### Prerequisites
- Python 3.10+
- Git (for cloning the repository)
- Homebrew (for Option 3)
### Option 1: Quick Install (Recommended)
```bash
# Clone the repository
git clone https://github.com/astrio-ai/legacy2modern.git
cd legacy2modern
# Run the installation script
./install.sh
```
### Option 2: Manual Installation
```bash
# Clone the repository
git clone https://github.com/astrio-ai/legacy2modern.git
cd legacy2modern
# Install dependencies
pip install -r requirements.txt
# Install the CLI
pip install -e .
```
### Option 3: Homebrew Installation (macOS)
```bash
# Install via Homebrew
brew install legacy2modern-cli
# Run the CLI
legacy2modern
```
### Option 4: Run Directly (No Installation)
```bash
# Clone the repository
git clone https://github.com/astrio-ai/legacy2modern.git
cd legacy2modern
# Install dependencies
pip install -r requirements.txt
# Run the CLI directly
python run_cli.py
```
### Using the CLI
Once installed, you can use the CLI in several ways:
```bash
# Start the interactive CLI
legacy2modern
# Or use the short command
l2m
# Run directly without installation
python run_cli.py
```
**Note**: Homebrew installation provides the most convenient way to install and use the CLI on macOS.
### Examples
```bash
# Start the CLI
legacy2modern
# In the interactive mode:
> transpile examples/cobol/HELLO.cobol
> /transpile examples/cobol/HELLO.cobol
> modernize examples/website/legacy-site.html
> analyze the generated Python code
> /help
```
### Run Tests
```bash
# Run all tests
pytest tests/
# Run specific test
pytest tests/cobol_system/test_basic_transpilation.py
```
## ๐ Supported Languages & Frameworks
### **COBOL to Python**
- Variable declarations with PIC clauses
- Level numbers (01, 05, 77)
- Type inference (PIC X โ str, PIC 9 โ int/float)
- Control flow statements (PERFORM, IF-THEN-ELSE)
- File I/O operations
- Arithmetic operations
### **Legacy Websites to Modern Frameworks**
- **React**: Component-based architecture with hooks
- **Next.js**: Full-stack React framework with SSR
- **Astro**: Content-focused static site generator
- **Bootstrap โ Tailwind CSS**: Modern utility-first CSS
- **jQuery โ React Hooks**: State management and DOM manipulation
- **PHP โ API Routes**: Server-side logic conversion
### **Example Transformations**
**COBOL to Python:**
```cobol
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
PROCEDURE DIVISION.
DISPLAY 'HELLO WORLD!'.
GOBACK.
```
**Output:**
```python
# Generated Python code from main
def main():
print('HELLO WORLD!')
return
if __name__ == '__main__':
main()
```
**Legacy HTML to React:**
```html
<div class="container">
<h1>Welcome</h1>
<button onclick="showAlert()">Click me</button>
</div>
```
**Output:**
```jsx
import React, { useState } from 'react';
function App() {
const showAlert = () => {
alert('Hello!');
};
return (
<div className="container">
<h1>Welcome</h1>
<button onClick={showAlert}>Click me</button>
</div>
);
}
export default App;
```
## ๐ง Development
### **Project Structure**
```
legacy2modern/
โโโ engine/ # Core engine components
โ โโโ agents/ # LLM agent system
โ โโโ cli/ # Modern CLI interface
โ โโโ modernizers/ # Language-specific modernizers
โ โโโ cobol_system/ # COBOL transpilation
โ โโโ static_site/ # Website modernization
โโโ examples/
โ โโโ cobol/ # Sample COBOL programs
โ โโโ website/ # Sample legacy websites
โโโ tests/ # Test suite
โโโ docs/ # Documentation
โโโ scripts/ # CLI script wrappers
โโโ output/ # Generated output files
โโโ install.sh # Installation script
โโโ run_cli.py # Direct CLI runner
โโโ setup.py # Package configuration
```
### **Adding New Features**
1. **New Language Support**: Add grammar files and IR translators
2. **New Templates**: Create Jinja2 templates for target languages
3. **New Rules**: Implement transformation rules in the modernizers directory
4. **LLM Integration**: Extend agents for AI-powered suggestions
5. **CLI Enhancements**: Add new commands and interactive features
6. **Framework Support**: Add new target frameworks for website modernization
## ๐งช Testing
```bash
# Run all tests
pytest
# Run specific test file
pytest tests/cobol_system/test_basic_transpilation.py
# Run with coverage
pytest --cov=engine
```
## ๐ License
This project is licensed under the Apache-2.0 License. See the [LICENSE](./LICENSE) file for details.
## ๐ค Contributing
We welcome all contributions โ from fixing typos to adding new language support!
See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup instructions, coding guidelines, and how to submit PRs.
### Good First Issues
* Add support for more website frameworks
* Add support for more COBOL constructs
* Create templates for other target languages (JavaScript, C++)
* Improve error handling and reporting
* Add more comprehensive test cases
## ๐ฌ Community & Support
* ๐ข Follow our project updates on [X](https://x.com/nolan-lwin)
* ๐พ Join our [Discord](https://discord.gg/2BVwAUzW)
* ๐งโ๐ป Join the discussion: [GitHub Discussions](https://github.com/astrio-ai/legacy2modern/discussions)
* ๐งช Report bugs: [GitHub Issues](https://github.com/astrio-ai/legacy2modern/issues)
## ๐ฌ Contact Us
For partnership inquiries or professional use cases:
๐ง **[naingoolwin.astrio@gmail.com](mailto:naingoolwin.astrio@gmail.com)**
Raw data
{
"_id": null,
"home_page": "https://github.com/astrio-ai/legacy2modern",
"name": "legacy2modern",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "Naing Oo Lwin <naingoolwin.astrio@gmail.com>",
"keywords": "cobol, transpiler, legacy, modernization, python, cli",
"author": "Naing Oo Lwin",
"author_email": "Naing Oo Lwin <naingoolwin.astrio@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/0a/da/0a98692c7d0c31a096968521c9689d335168faab07fcee0f545785c63f7f/legacy2modern-0.1.0.tar.gz",
"platform": null,
"description": "# Legacy2Modern (L2M) \u2014 AI Legacy Code Transpilation Engine\n\n<div align=\"center\">\n\n<!-- Keep the gap above this line, otherwise they won't render correctly! -->\n[](https://github.com/astrio-ai/openlegacy) \n[](https://discord.gg/2BVwAUzW)\n[](https://github.com/openrewrite/.github/blob/main/CONTRIBUTING.md)\n</div>\n\n\n\nWelcome to **Legacy2Modern (L2M)**, an open-source engine for transforming legacy source code into modern, maintainable software.\n\nL2M specializes in **intelligent transpilation** of legacy languages (starting with COBOL) and **website modernization** into modern frameworks. It combines the precision of AST-based parsing with the flexibility of template-driven code generation, optionally augmented by Large Language Models (LLMs).\n\nWhether you're modernizing COBOL business systems, migrating legacy websites to React/Next.js/Astro, or transforming decades-old enterprise code \u2014 L2M is built to help you do it **safely**, **accurately**, and **transparently**.\n\n## \u2728 Features\n\n* \ud83d\udd04 **COBOL to Python Transpilation** \n Translate COBOL programs into modern Python code with multiple transpilation approaches.\n\n* \ud83c\udf10 **Legacy Website Modernization** \n Transform HTML + Bootstrap + jQuery + PHP websites into modern React, Next.js, or Astro applications.\n\n* \ud83d\udda5\ufe0f **Modern CLI Interface** \n Beautiful, interactive command-line interface with natural language commands and AI-powered analysis.\n\n* \ud83e\udde0 **Lossless Semantic Tree (LST) Parsing** \n ANTLR4-based parser that retains all source code information including comments, whitespace, and semantic context.\n\n* \ud83c\udfd7\ufe0f **Intermediate Representation (IR) System** \n Language-agnostic IR that enables extensibility to other source and target languages.\n\n* \ud83d\udcdd **Template-Based Code Generation** \n Jinja2-powered template system for clean, maintainable code generation.\n\n* \ud83e\udd16 **AI-Powered Analysis & Optimization** \n LLM integration for code analysis, review, and optimization suggestions with multi-provider support.\n\n* \ud83c\udfaf **Multiple Transpilation Approaches** \n - Direct COBOL \u2192 Python transpilation\n - IR-based transpilation with templates\n - Hybrid transpilation with LLM augmentation\n - Static site modernization with framework selection\n - Extensible architecture for future languages\n\n* \ud83e\uddea **Comprehensive Testing Framework** \n Unit tests, integration tests, and validation for all transpilation components.\n\n* \ud83d\udce6 **Easy Installation Options** \n - Homebrew installation: `brew install legacy2modern-cli`\n - Direct installation: `pip install -e .`\n - Run without installation: `python run_cli.py`\n\n## \ud83d\ude80 Quickstart\n\n### Prerequisites\n\n- Python 3.10+\n- Git (for cloning the repository)\n- Homebrew (for Option 3)\n\n### Option 1: Quick Install (Recommended)\n\n```bash\n# Clone the repository\ngit clone https://github.com/astrio-ai/legacy2modern.git\ncd legacy2modern\n\n# Run the installation script\n./install.sh\n```\n\n### Option 2: Manual Installation\n\n```bash\n# Clone the repository\ngit clone https://github.com/astrio-ai/legacy2modern.git\ncd legacy2modern\n\n# Install dependencies\npip install -r requirements.txt\n\n# Install the CLI\npip install -e .\n```\n\n### Option 3: Homebrew Installation (macOS)\n\n```bash\n# Install via Homebrew\nbrew install legacy2modern-cli\n\n# Run the CLI\nlegacy2modern\n```\n\n### Option 4: Run Directly (No Installation)\n\n```bash\n# Clone the repository\ngit clone https://github.com/astrio-ai/legacy2modern.git\ncd legacy2modern\n\n# Install dependencies\npip install -r requirements.txt\n\n# Run the CLI directly\npython run_cli.py\n```\n\n### Using the CLI\n\nOnce installed, you can use the CLI in several ways:\n\n```bash\n# Start the interactive CLI\nlegacy2modern\n\n# Or use the short command\nl2m\n\n# Run directly without installation\npython run_cli.py\n```\n\n**Note**: Homebrew installation provides the most convenient way to install and use the CLI on macOS.\n\n### Examples\n\n```bash\n# Start the CLI\nlegacy2modern\n\n# In the interactive mode:\n> transpile examples/cobol/HELLO.cobol\n> /transpile examples/cobol/HELLO.cobol\n> modernize examples/website/legacy-site.html\n> analyze the generated Python code\n> /help\n```\n\n### Run Tests\n\n```bash\n# Run all tests\npytest tests/\n\n# Run specific test\npytest tests/cobol_system/test_basic_transpilation.py\n```\n\n## \ud83d\udccb Supported Languages & Frameworks\n\n### **COBOL to Python**\n- Variable declarations with PIC clauses\n- Level numbers (01, 05, 77)\n- Type inference (PIC X \u2192 str, PIC 9 \u2192 int/float)\n- Control flow statements (PERFORM, IF-THEN-ELSE)\n- File I/O operations\n- Arithmetic operations\n\n### **Legacy Websites to Modern Frameworks**\n- **React**: Component-based architecture with hooks\n- **Next.js**: Full-stack React framework with SSR\n- **Astro**: Content-focused static site generator\n- **Bootstrap \u2192 Tailwind CSS**: Modern utility-first CSS\n- **jQuery \u2192 React Hooks**: State management and DOM manipulation\n- **PHP \u2192 API Routes**: Server-side logic conversion\n\n### **Example Transformations**\n\n**COBOL to Python:**\n```cobol\n IDENTIFICATION DIVISION.\n PROGRAM-ID. HELLO.\n PROCEDURE DIVISION.\n DISPLAY 'HELLO WORLD!'.\n GOBACK.\n```\n\n**Output:**\n```python\n# Generated Python code from main\n\ndef main():\n print('HELLO WORLD!')\n return\n\nif __name__ == '__main__':\n main()\n```\n\n**Legacy HTML to React:**\n```html\n<div class=\"container\">\n <h1>Welcome</h1>\n <button onclick=\"showAlert()\">Click me</button>\n</div>\n```\n\n**Output:**\n```jsx\nimport React, { useState } from 'react';\n\nfunction App() {\n const showAlert = () => {\n alert('Hello!');\n };\n\n return (\n <div className=\"container\">\n <h1>Welcome</h1>\n <button onClick={showAlert}>Click me</button>\n </div>\n );\n}\n\nexport default App;\n```\n\n## \ud83d\udd27 Development\n\n### **Project Structure**\n\n```\nlegacy2modern/\n\u251c\u2500\u2500 engine/ # Core engine components\n\u2502 \u251c\u2500\u2500 agents/ # LLM agent system\n\u2502 \u251c\u2500\u2500 cli/ # Modern CLI interface\n\u2502 \u2514\u2500\u2500 modernizers/ # Language-specific modernizers\n\u2502 \u251c\u2500\u2500 cobol_system/ # COBOL transpilation\n\u2502 \u2514\u2500\u2500 static_site/ # Website modernization\n\u251c\u2500\u2500 examples/\n\u2502 \u251c\u2500\u2500 cobol/ # Sample COBOL programs\n\u2502 \u2514\u2500\u2500 website/ # Sample legacy websites\n\u251c\u2500\u2500 tests/ # Test suite\n\u251c\u2500\u2500 docs/ # Documentation\n\u251c\u2500\u2500 scripts/ # CLI script wrappers\n\u251c\u2500\u2500 output/ # Generated output files\n\u251c\u2500\u2500 install.sh # Installation script\n\u251c\u2500\u2500 run_cli.py # Direct CLI runner\n\u2514\u2500\u2500 setup.py # Package configuration\n```\n\n### **Adding New Features**\n\n1. **New Language Support**: Add grammar files and IR translators\n2. **New Templates**: Create Jinja2 templates for target languages\n3. **New Rules**: Implement transformation rules in the modernizers directory\n4. **LLM Integration**: Extend agents for AI-powered suggestions\n5. **CLI Enhancements**: Add new commands and interactive features\n6. **Framework Support**: Add new target frameworks for website modernization\n\n## \ud83e\uddea Testing\n\n```bash\n# Run all tests\npytest\n\n# Run specific test file\npytest tests/cobol_system/test_basic_transpilation.py\n\n# Run with coverage\npytest --cov=engine\n```\n\n## \ud83d\udcc4 License\nThis project is licensed under the Apache-2.0 License. See the [LICENSE](./LICENSE) file for details.\n\n## \ud83e\udd1d Contributing\nWe welcome all contributions \u2014 from fixing typos to adding new language support!\nSee [CONTRIBUTING.md](./CONTRIBUTING.md) for setup instructions, coding guidelines, and how to submit PRs.\n\n### Good First Issues\n* Add support for more website frameworks\n* Add support for more COBOL constructs\n* Create templates for other target languages (JavaScript, C++)\n* Improve error handling and reporting\n* Add more comprehensive test cases\n\n## \ud83d\udcac Community & Support\n* \ud83d\udce2 Follow our project updates on [X](https://x.com/nolan-lwin)\n* \ud83d\udc7e Join our [Discord](https://discord.gg/2BVwAUzW)\n* \ud83e\uddd1\u200d\ud83d\udcbb Join the discussion: [GitHub Discussions](https://github.com/astrio-ai/legacy2modern/discussions)\n* \ud83e\uddea Report bugs: [GitHub Issues](https://github.com/astrio-ai/legacy2modern/issues)\n\n## \ud83d\udcec Contact Us\nFor partnership inquiries or professional use cases:\n\n\ud83d\udce7 **[naingoolwin.astrio@gmail.com](mailto:naingoolwin.astrio@gmail.com)**\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "AI-Powered Legacy Code Transpilation Engine with Modern CLI",
"version": "0.1.0",
"project_urls": {
"Bug Tracker": "https://github.com/astrio-ai/legacy2modern/issues",
"Documentation": "https://github.com/astrio-ai/legacy2modern#readme",
"Homepage": "https://github.com/astrio-ai/legacy2modern",
"Repository": "https://github.com/astrio-ai/legacy2modern"
},
"split_keywords": [
"cobol",
" transpiler",
" legacy",
" modernization",
" python",
" cli"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "d22d633ea811770d09b86a59a0b69ecd9d5b1a37f13cccd3890cb17360e3bc80",
"md5": "b04b3e0a888960a60111850de1d02f4a",
"sha256": "c331601d7d569db84d6833e0fccaa28b16bc92dbec6f87b49695a9e69d35b28c"
},
"downloads": -1,
"filename": "legacy2modern-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b04b3e0a888960a60111850de1d02f4a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 702453,
"upload_time": "2025-08-11T05:48:28",
"upload_time_iso_8601": "2025-08-11T05:48:28.120218Z",
"url": "https://files.pythonhosted.org/packages/d2/2d/633ea811770d09b86a59a0b69ecd9d5b1a37f13cccd3890cb17360e3bc80/legacy2modern-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "0ada0a98692c7d0c31a096968521c9689d335168faab07fcee0f545785c63f7f",
"md5": "39733f8445aea8c87dabcf47de621627",
"sha256": "9881bff22dc43167d76792058eb4c22c9a3a0c60d0f61b6e33051340448151d7"
},
"downloads": -1,
"filename": "legacy2modern-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "39733f8445aea8c87dabcf47de621627",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 645736,
"upload_time": "2025-08-11T05:48:29",
"upload_time_iso_8601": "2025-08-11T05:48:29.820944Z",
"url": "https://files.pythonhosted.org/packages/0a/da/0a98692c7d0c31a096968521c9689d335168faab07fcee0f545785c63f7f/legacy2modern-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-11 05:48:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "astrio-ai",
"github_project": "legacy2modern",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "pytest",
"specs": [
[
">=",
"8.0.0"
]
]
},
{
"name": "python-dotenv",
"specs": [
[
">=",
"1.0.0"
]
]
},
{
"name": "click",
"specs": [
[
">=",
"8.1.0"
]
]
},
{
"name": "rich",
"specs": [
[
">=",
"13.0.0"
]
]
},
{
"name": "typer",
"specs": [
[
">=",
"0.9.0"
]
]
},
{
"name": "prompt_toolkit",
"specs": [
[
">=",
"3.0.0"
]
]
},
{
"name": "pygments",
"specs": [
[
">=",
"2.15.0"
]
]
},
{
"name": "openai",
"specs": [
[
">=",
"1.0.0"
]
]
},
{
"name": "anthropic",
"specs": [
[
">=",
"0.7.0"
]
]
},
{
"name": "requests",
"specs": [
[
">=",
"2.31.0"
]
]
},
{
"name": "beautifulsoup4",
"specs": [
[
">=",
"4.12.0"
]
]
},
{
"name": "lxml",
"specs": [
[
">=",
"4.9.0"
]
]
},
{
"name": "antlr4-python3-runtime",
"specs": [
[
">=",
"4.9.0"
]
]
},
{
"name": "jinja2",
"specs": [
[
">=",
"3.0.0"
]
]
},
{
"name": "colorlog",
"specs": [
[
">=",
"6.0.0"
]
]
}
],
"lcname": "legacy2modern"
}