An open API service indexing awesome lists of open source software.

https://github.com/biru-codeastromer/py2cpp

Python → C++ converter for competitive programming. React + FastAPI + Ollama (Qwen). Side-by-side run, compile-repair loop, CF boilerplate.
https://github.com/biru-codeastromer/py2cpp

ai-codegen cloudflare-tunnel codeforces competitive-programming fastapi ollama python-to-cpp qwen react vitejs

Last synced: 3 months ago
JSON representation

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

Awesome Lists containing this project

README

          

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

[![Vercel](https://img.shields.io/badge/Frontend-Vercel-black?logo=vercel)](https://py2cpp.vercel.app/)
![FastAPI](https://img.shields.io/badge/Backend-FastAPI-009485?logo=fastapi)
![Ollama](https://img.shields.io/badge/LLM-Ollama-000?logo=ollama)
![Model](https://img.shields.io/badge/Qwen2.5--Coder-7B-blue)
![License](https://img.shields.io/badge/License-MIT-informational)

**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**
```bash
brew install ollama cloudflare/cloudflare/cloudflared
ollama serve
ollama pull qwen2.5-coder:7b
```

2) **Backend**
```bash
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
```

3) **Frontend**
```bash
cd frontend
echo "VITE_API_URL=https://.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.

4) **Public URL**
```bash
cloudflared tunnel --url http://localhost:8000
# copy the https://.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": "" }

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

- POST /run/cpp → { "code": "", "stdin": "" }

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

### Key points:

- macOS/Clang is handled by a fallback header set when is unavailable.

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

### License
MIT © Birajit Saikia