A starter lab for exploring automated strategies to modernize legacy stacks. It bundles lightweight analyzers, translators, reusable templates, and a pytest-powered harness so you can iterate quickly on migration ideas.
- Create a virtual environment and install dependencies:
python -m venv .venv .\.venv\Scripts\Activate.ps1 pip install -r requirements.txt
- Populate
docs/reports/by running the analyzers:python cli/analyze.py --path .
- Try a migration path. Example: Python 2 file to Python 3 stub:
Include
python cli/migrate.py --from python2 --to python3 --path path\to\legacy.py --refactor
--refactor(also available oncli/analyze.py) to enable automated cleanup of globals, oversized functions, and repeated blocks. Translated files land ingenerated/with JSON metadata indocs/reports/python2_to_python3/. - Launch the API gateway (FastAPI + Uvicorn) for REST access to analyzers and translators:
Visit
python cli/api_gateway.py --host 0.0.0.0 --port 8000
http://localhost:8000/docsfor interactive Swagger docs or export the static schema via:python services/api_gateway/export_openapi.py
- POST
http://localhost:8000/demo/translate/python2to3with{ "code": "<python2 snippet>" }to see the enhanced Python 2→3 translator in action (refactoring enabled by default). - The response echoes the original snippet, the translated Python 3 code, and the same metadata JSON you would get from the CLI/CLI file-based runs (refactorings, warnings, line counts, etc.).
- Example PowerShell request:
$body = @{ code = 'print "hi"' } | ConvertTo-Json Invoke-RestMethod -Uri http://localhost:8000/demo/translate/python2to3 -Method POST -Body $body -ContentType 'application/json'
- A recorded sample request/response pair is available at
docs/reports/demo_translation_sample.jsonfor quick client demos.
- POST a
.zipof Python 2 files tohttp://localhost:8000/demo/translate/python2to3/batch(multipart form fieldupload). - The gateway unpacks the archive, runs the inline translator on every
.py, and streams back a.zipcontaining:translated/with<filename>_py3.pystubsmetadata/with per-file JSON metadataconsolidated_report.jsonsummarizing totals/refactorings/warningssummary.mdhighlighting trends and red flagssummary_proposal.md– a client-ready proposal outlining totals, refactorings, warnings, and next steps
- Example PowerShell snippet:
Compress-Archive -Path .\legacy_samples\*.py -DestinationPath batch.zip Invoke-RestMethod -Uri http://localhost:8000/demo/translate/python2to3/batch -Method POST -InFile batch.zip -ContentType 'multipart/form-data'
- Sample outputs live under
docs/reports/sample_batch_output.zip,docs/reports/demo_batch_translation_sample.json, and the client-facing proposaldocs/reports/demo_batch_proposal_sample.md.- Optional PDF: when a PDF renderer (pandoc) is available, the batch archive will include
summary_proposal.pdfand the repo will containdocs/reports/demo_batch_proposal_sample.pdf.
- Optional PDF: when a PDF renderer (pandoc) is available, the batch archive will include
analyzers/dependency_scanner.pybuilds a cross-language import graph (JSON output).analyzers/code_smell_detector.pyflags common legacy constructs and suggests fixes.- Translators for Python 2→3, Selenium→Playwright, and PHP→Node generate actionable stubs in
templates/; the enhanced Python 2→3 path also emits JSON metadata describing refactorings (docs/reports/python2_to_python3/). services/api_gatewayexposes those capabilities through FastAPI endpoints plus a generateddocs/reports/openapi.jsonspecification.test_harness/run_tests.pyexecutes the translator unit tests and publishesdocs/reports/test_results.json.
- Add more translators or plug in real migration logic.
- Expand the docs under
docs/with project-specific guidance. - Integrate the CLI commands into your CI/CD pipeline once you are satisfied with the outputs.