Skip to content

Python → C++ converter for competitive programming. React + FastAPI + Ollama (Qwen). Side-by-side run, compile-repair loop, CF boilerplate.

Notifications You must be signed in to change notification settings

biru-codeastromer/py2cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

py2cpp — AI Python → C++ (CF-ready)

Vercel FastAPI Ollama Model License

py2cpp converts Python to C++17 with a Codeforces-style boilerplate, then compiles and runs both versions side-by-side on the same input.
AI-first: Qwen2.5-Coder (via Ollama) + a compile-and-repair loop.
Live UI: https://py2cpp.vercel.app/


Requirements

  • macOS with Homebrew
  • Python 3.10+, Node 18+
  • Ollama installed

Quick start

  1. Model server
brew install ollama cloudflare/cloudflare/cloudflared
ollama serve
ollama pull qwen2.5-coder:7b
  1. Backend
cd backend
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
export OLLAMA_MODEL=qwen2.5-coder:7b
uvicorn main:app --host 0.0.0.0 --port 8000
  1. Frontend
cd frontend
echo "VITE_API_URL=https://<your-tunnel>.trycloudflare.com" > .env
npm install && npm run dev

The frontend is static. The backend (FastAPI + Ollama + g++) runs on your machine and must stay running.

  1. Public URL
cloudflared tunnel --url http://localhost:8000
# copy the https://<random>.trycloudflare.com URL

Notes: Deployment can be only for frontend via netlify or vercel ; backend would be running locally constantly to work

API

  • POST /ai/convert → body { "py": "" } → { "cpp": "<full c++ file>" }

  • POST /run/python → { "code": "", "stdin": "" }

  • POST /run/cpp → { "code": "<c++>", "stdin": "" }

  • GET /healthz → { "ok": true }

Key points:

  • macOS/Clang is handled by a fallback header set when <bits/stdc++.h> is unavailable.

  • Targeted at contest-style Python; highly dynamic features may require manual edits.

License

MIT © Birajit Saikia

About

Python → C++ converter for competitive programming. React + FastAPI + Ollama (Qwen). Side-by-side run, compile-repair loop, CF boilerplate.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published