ββββββ βββββββββββββββββββββ βββββββββββββββββββββββ
ββββββββββββββββββββββββββββββ ββββββββββββββββββββββββ
ββββββββββββββββ βββ ββββββββββββββ βββββ ββββββ
ββββββββββββββββ βββ ββββββββββββββ βββββ ββββββ
βββ βββββββββββ βββ βββ βββ ββββββββββββββββββββββ
βββ βββββββββββ βββ βββ ββββββββββββββββββββββ
Python is the language developers think in. C++ is the language performance demands.
Rewriting Python to C++ by hand is slow, error-prone, and interrupts creative flow. Existing tools use regex-and-replace β they don't understand context, types, or idiomatic C++.
Astmize closes that gap.
Paste Python. Get production-ready C++. Run it instantly in the browser β no setup, no compiler, no context switching.
Astmize sends your Python source through an AI orchestration engine that understands intent and context β not just syntax. The output is clean, compilable C++ with proper STL usage, type inference, and optional AI enhancement.
# Input β Python 3.x
def find_max(nums: list[int]) -> int:
result: int = nums[0]
for i in range(1, len(nums)):
if nums[i] > result:
result = nums[i]
return result
print(find_max([3, 7, 2, 9, 1]))// Output β C++17 (Astmize)
#include <iostream>
#include <vector>
int find_max(std::vector<int> nums) {
int result = nums[0];
for (int i = 1; i < (int)nums.size(); ++i) {
if (nums[i] > result) result = nums[i];
}
return result;
}
int main() {
std::cout << find_max({3, 7, 2, 9, 1}) << "\n";
return 0;
}βΆ Output: 9 β Compiled & executed via GCC
| Input | Output |
|---|---|
| Python 3.x (type hints, f-strings, modern syntax) | C++11 / C++17 |
Type annotations are preserved as strongly-typed C++ equivalents. When hints are absent, the AI infers types from context.
| Feature | Description |
|---|---|
| π€ AI Orchestration | 8 free AI models queried in sequence β automatic fallback ensures availability |
| π AST Fallback Engine | If all AI models are unavailable, a pure-Python AST transpiler handles conversion locally |
| β¦ AI Enhancement | One-click C++ refactor β AI improves idioms, explains every change |
| βΆ Live Execution | Compiles and runs generated C++ in the browser via Wandbox (GCC) |
| β³ Conversion History | Last 7 sessions stored locally β restore any previous conversion instantly |
| π Bilingual UI | Full English & Arabic interface with RTL support |
| β¬οΈ Multi-Format Export | Download .cpp, copy as Markdown, or plain text |
| π Complexity Indicator | Real-time simple / moderate / complex estimate as you type |
| Drag to resize editors β layout ratio saved across sessions | |
| βοΈ Editor Settings | Font size, tab size, line numbers β all configurable |
| π‘οΈ Rate Limiting | 60 req/min on /convert, 20 req/min on /enhance |
| π± Mobile-First PWA | Installable, offline-capable β full tab-switcher layout on small screens |
| β¨οΈ Keyboard Shortcuts | Ctrl+Enter to transpile Β· full shortcut reference in-app |
βββββββββββββββββββ POST /convert ββββββββββββββββββββββββββββ
β Python Input β βββββββββββββββββββΆ β Flask Backend β
β (Browser UI) β β β
βββββββββββββββββββ β Model 1 (Qwen3 Coder) β
β β β Model 2 (DeepSeek) β
β C++ + Warnings β β Model 3 β¦ (Γ8 total) β
β βββββββββββββββββββββββββββββ β β AST Fallback Engine β
βΌ ββββββββββββββββββββββββββββ
βββββββββββββββββββ POST /enhance ββββββββββββββββββββββββββββ
β C++ Output β βββββββββββββββββββΆ β AI Refactor + Explain β
β (Highlighted) β βββββββββββββββββββ ββββββββββββββββββββββββββββ
β β
β [ β¦ Enhance ] β POST β Wandbox ββββββββββββββββββββββββββββ
β [ βΆ Run ] β βββββββββββββββββββΆ β GCC Compiler (Live) β
β Console Output β βββββββββββββββββββ β stdout / stderr β
βββββββββββββββββββ ββββββββββββββββββββββββββββ
Reliability by design: No single point of failure. Every conversion attempt cascades through 8 AI models before falling back to the deterministic AST engine β ensuring output is always returned.
Astmize approaches correctness at multiple layers:
| Layer | Mechanism |
|---|---|
| Compilation check | All output is immediately runnable via Wandbox (GCC) β errors surface in the console, not silently |
| AI fallback chain | 8 models tried in sequence; the first valid compilable response is used |
| AST fallback | Deterministic rule-based transpiler activates when AI is unavailable |
| Warning system | Non-fatal translation issues are surfaced as inline warnings, not discarded |
| Enhancement pass | Optional AI refactor further improves correctness and C++ idiom compliance |
Note: Astmize targets Python-to-C++ transpilation for prototyping, learning, and performance porting workflows. For safety-critical or production-compiled binaries, human review of the generated output is recommended β as with any code generation tool.
astmize/
βββ app.py # Flask API β AI orchestration, AST fallback, rate limiting
βββ index.html # Full frontend (single-file, zero build step)
βββ requirements.txt # Production dependencies
βββ Procfile # Process definition (Render / Heroku)
βββ LICENSE
βββ README.md
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Health check β returns service version and status |
POST |
/convert |
Accepts Python source, returns AI-generated C++ |
POST |
/enhance |
Accepts C++, returns AI-refactored version + explanation |
{
"service": "Astmize API",
"status": "ok",
"version": "2.1.0"
}Request
POST /convert
Content-Type: application/json
{
"python_code": "def greet(name: str):\n print(f'Hello, {name}!')"
}Response 200
{
"success": true,
"cpp_code": "#include <iostream>\n#include <string>\n\nvoid greet(std::string name) {\n std::cout << \"Hello, \" << name << \"!\\n\";\n}\n",
"warnings": [],
"error": null
}Error responses
| Code | Meaning |
|---|---|
429 |
Rate limit exceeded |
413 |
Payload exceeds 64 KB limit |
502 |
All AI models unavailable (AST fallback also failed) |
Request
POST /enhance
Content-Type: application/json
{
"cpp_code": "#include <iostream>\n..."
}Response 200
{
"success": true,
"enhanced_code": "#include <iostream>\n...",
"explanation": "Replaced raw loop with std::max_element; renamed variable for clarity.",
"error": null
}Test with cURL / Python / Postman
cURL
# Health check
curl https://astmize.onrender.com/
# Transpile
curl -X POST https://astmize.onrender.com/convert \
-H "Content-Type: application/json" \
-d '{"python_code": "x: int = 42\nprint(x)"}'
# Enhance
curl -X POST https://astmize.onrender.com/enhance \
-H "Content-Type: application/json" \
-d '{"cpp_code": "#include <iostream>\nint main(){std::cout<<42;}"}'Python
import requests
resp = requests.post(
"https://astmize.onrender.com/convert",
json={"python_code": "for i in range(5):\n print(i)"},
)
data = resp.json()
if data["success"]:
print(data["cpp_code"])
resp2 = requests.post(
"https://astmize.onrender.com/enhance",
json={"cpp_code": data["cpp_code"]},
)
print(resp2.json()["explanation"])# 1. Clone
git clone https://github.com/TheSpacetimeDebugger/Astmize.git
cd Astmize
# 2. Virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Set environment variables
export OPENROUTER_API_KEY="your-openrouter-api-key"
export FLASK_DEBUG=true
# 5. Start server
python app.py
# API available at http://localhost:5000Open index.html directly in your browser β no build step required.
OpenRouter key: Free at openrouter.ai β all models Astmize uses are on free tiers.
- Push to GitHub
- render.com β New Web Service β connect repo
- Configure:
| Field | Value |
|---|---|
| Environment | Python 3 |
| Build Command | pip install -r requirements.txt |
| Start Command | gunicorn app:app --workers 4 --bind 0.0.0.0:$PORT |
- Add
OPENROUTER_API_KEYunder Environment Variables
Cold start: Render's free tier spins down after inactivity. The first request after a sleep period may take 30β90 seconds β the UI notifies users automatically.
- π AST Fallback Engine β deterministic transpiler activates when all AI models are unavailable
- π¦ Python 3.x β C++11 / C++17 version matrix documented
- π Complexity Indicator β real-time simple / moderate / complex estimate
βοΈ Resizable Panels with saved layout ratio- β€ Export Dropdown β
.cpp, Markdown, plain text - β Keyboard Shortcuts Modal
- π² PWA β installable with offline Service Worker
- πͺ Privacy Consent Banner
- β¦ AI Enhancement β
/enhanceendpoint with refactor + explanation - β³ Conversion History β last 7 sessions in localStorage
- π’ Live editor stats (line + character counter)
- π Fixed
program_messageβprogram_output(Wandbox stdout now displays correctly)
- π€ Replaced pure AST engine with AI orchestration via OpenRouter
- π 8-model fallback chain
- π‘οΈ Rate limiting with bilingual error messages
- βΆ Live C++ execution via Wandbox (GCC)
- π± Mobile-first layout with tab switcher
- π Full Arabic UI with RTL support
- Initial release β pure Python AST transpiler engine
- Flask backend, dark cyber frontend
Contributions, issues, and feature requests are welcome.
- Fork the repository
- Create a branch:
git checkout -b feature/your-feature - Commit:
git commit -m 'feat: describe your change' - Push:
git push origin feature/your-feature - Open a Pull Request
For significant changes, open an issue first to align on approach.
Astmize Studio Β· Built by Ibrahim El-Shami
π§ sydbrahim02@gmail.com Β· π¦ @AstmizeStudio Β· π Product Hunt
For bugs or feature requests β open a GitHub issue or send an email.
MIT Β© Astmize Studio
If Astmize saved you time, a β helps others discover the project.
Built with β‘ by Astmize Studio