Skip to content

Commit ad66b59

Browse files
authored
Python vibe coding ide (#1267)
### Description A vibe coding browser IDE built with FastAPI and Next.js, using the Vercel Python Sandboxes SDK. <img width="1264" height="880" alt="Screenshot 2025-10-20 at 3 23 04 PM" src="https://github.com/user-attachments/assets/56e8844e-41b7-4d60-8268-ce7cd1f888f6" /> ### Demo URL https://python-vibe-coding-ide.labs.vercel.dev/ ### Type of Change - [x] New Example - [ ] Example updates (Bug fixes, new features, etc.) - [ ] Other (changes to the codebase, but not to examples) ### New Example Checklist - [ ] 🛫 `npm run new-example` was used to create the example - [x] 📚 The template wasn't used but I carefuly read the [Adding a new example](https://github.com/vercel/examples#adding-a-new-example) steps and implemented them in the example - [x] 📱 Is it responsive? Are mobile and tablets considered?
1 parent b3a691b commit ad66b59

File tree

136 files changed

+16351
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+16351
-0
lines changed

python/vibe-coding-ide/.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# PyCharm
2+
.idea/
3+
4+
# Docker
5+
.dockerignore
6+
7+
# OS generated files
8+
.DS_Store
9+
.DS_Store?
10+
._*
11+
.Spotlight-V100
12+
.Trashes
13+
ehthumbs.db
14+
Thumbs.db

python/vibe-coding-ide/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## Getting Started
2+
3+
First, run the backend development server:
4+
5+
```bash
6+
cd backend
7+
8+
vercel link
9+
vercel env pull
10+
11+
# or manually set env vars
12+
# cat .env.example > .env
13+
14+
python -m venv .venv
15+
source .venv/bin/activate
16+
pip install -r requirements.txt
17+
18+
python server.py
19+
```
20+
21+
Open [http://localhost:8081/docs](http://localhost:8081/docs) with your browser to see the backend.
22+
23+
Then, run the frontend development server:
24+
25+
```bash
26+
# in a separate terminal
27+
cd frontend
28+
29+
npm i
30+
31+
npm run dev
32+
```
33+
34+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the backend.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
VERCEL_TOKEN=your_token_here
2+
VERCEL_PROJECT_ID=prj_...your_project_id_here
3+
VERCEL_TEAM_ID=team_...your_team_here
4+
VERCEL_AI_GATEWAY_API_KEY=vck_...your_key_here
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
104+
# pdm
105+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106+
#pdm.lock
107+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108+
# in version control.
109+
# https://pdm.fming.dev/#use-with-ide
110+
.pdm.toml
111+
112+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113+
__pypackages__/
114+
115+
# Celery stuff
116+
celerybeat-schedule
117+
celerybeat.pid
118+
119+
# SageMath parsed files
120+
*.sage.py
121+
122+
# Environments
123+
.env
124+
.venv
125+
env/
126+
venv/
127+
ENV/
128+
env.bak/
129+
venv.bak/
130+
131+
# Spyder project settings
132+
.spyderproject
133+
.spyproject
134+
135+
# Rope project settings
136+
.ropeproject
137+
138+
# mkdocs documentation
139+
/site
140+
141+
# mypy
142+
.mypy_cache/
143+
.dmypy.json
144+
dmypy.json
145+
146+
# Pyre type checker
147+
.pyre/
148+
149+
# pytype static type analyzer
150+
.pytype/
151+
152+
# Cython debug symbols
153+
cython_debug/
154+
155+
# PyCharm
156+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157+
# be added to the global gitignore or merged into this project gitignore. For a PyCharm
158+
# project, it is recommended to ignore the entire .idea directory.
159+
.idea/
160+
161+
# Docker
162+
.dockerignore
163+
164+
# OS generated files
165+
.DS_Store
166+
.DS_Store?
167+
._*
168+
.Spotlight-V100
169+
.Trashes
170+
ehthumbs.db
171+
Thumbs.db
172+
173+
.vercel

python/vibe-coding-ide/backend/__init__.py

Whitespace-only changes.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[build-system]
2+
requires = ["hatchling>=1.25.0"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "nfactorial-code-agent-backend"
7+
version = "0.1.0"
8+
description = "Backend for the nfactorial code agent (FastAPI)"
9+
requires-python = ">=3.10"
10+
dependencies = [
11+
"python-dotenv==1.0.0",
12+
"pydantic",
13+
"fastapi~=0.117.0",
14+
"uvicorn",
15+
"openai-agents[litellm]",
16+
"PyJWT==2.9.0",
17+
"vercel>=0.3.2",
18+
"httpx",
19+
"httpx-sse",
20+
"ruff>=0.14.0",
21+
]
22+
23+
[project.optional-dependencies]
24+
dev = [
25+
"ruff>=0.5.0",
26+
"mypy",
27+
]
28+
29+
[project.urls]
30+
homepage = "https://example.com"
31+
repository = "https://example.com/repo"
32+
33+
34+
[tool.hatch.build.targets.wheel]
35+
# Include the src package so Hatch can build the wheel after refactor
36+
only-include = [
37+
"src",
38+
]
39+
40+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
python-dotenv==1.0.0
2+
pydantic
3+
httpx==0.27.2
4+
httpx-sse==0.4.0
5+
fastapi==0.115.12
6+
uvicorn[standard]==0.34.2
7+
openai-agents[litellm]
8+
PyJWT==2.9.0
9+
vercel>=0.3.2
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import os
2+
import logging
3+
from dotenv import load_dotenv
4+
from fastapi import FastAPI, Request
5+
from fastapi.middleware.cors import CORSMiddleware
6+
from dotenv import load_dotenv
7+
from typing import Callable
8+
from vercel.headers import set_headers
9+
10+
from src.api.agent import router as agent_router
11+
from src.api.sandbox import router as sandbox_router
12+
from src.api.models import router as models_router
13+
14+
15+
load_dotenv()
16+
17+
18+
logger = logging.getLogger("ide_agent.server")
19+
if not logger.handlers:
20+
logger.setLevel(logging.INFO)
21+
22+
app = FastAPI()
23+
24+
is_prod = (
25+
os.getenv("NODE_ENV") or os.getenv("ENV") or "development"
26+
).lower() == "production"
27+
28+
app.add_middleware(
29+
CORSMiddleware,
30+
allow_origins=[],
31+
allow_origin_regex=r"^https://.*\.labs\.vercel\.dev(:\d+)?$" if is_prod else r".*",
32+
allow_credentials=True,
33+
allow_methods=["*"],
34+
allow_headers=["*"],
35+
)
36+
37+
@app.middleware("http")
38+
async def vercel_context_middleware(request: Request, call_next: Callable):
39+
set_headers(request.headers)
40+
return await call_next(request)
41+
42+
app.include_router(models_router)
43+
app.include_router(agent_router)
44+
app.include_router(sandbox_router)
45+
46+
47+
@app.get("/")
48+
def read_root():
49+
return {"Hello": "IDE Agent"}
50+
51+
52+
if __name__ == "__main__":
53+
import uvicorn
54+
55+
uvicorn.run("server:app", host="0.0.0.0", port=8081, factory=False)

python/vibe-coding-ide/backend/src/__init__.py

Whitespace-only changes.

python/vibe-coding-ide/backend/src/agent/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)