For teams that want a React frontend + a Python AI backend together. Best for projects with a UI and serious backend logic (ML models, APIs, data processing).
frontend/ ← Next.js + Tailwind (your UI)
backend/ ← Python FastAPI (your AI/logic)
Terminal 1 — Backend:
cd backend
python -m venv venv
source venv/bin/activate # Mac/Linux
venv\Scripts\activate # Windows
pip install -r requirements.txt
cp .env.example .env # add your API keys
python main.pyTerminal 2 — Frontend:
cd frontend
npm install
npm run dev- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
The frontend calls the backend via fetch:
const res = await fetch("http://localhost:8000/chat", {
method: "POST",
body: JSON.stringify({ prompt: "hello" })
});- Frontend → Vercel (free, instant)
- Backend → Railway (free tier)
- Update
NEXT_PUBLIC_API_URLin frontend.env.localto point to your Railway URL
- Keep API keys only in the backend
.env— never in the frontend - Use the
/apiroutes in Next.js if you want to proxy backend calls and hide your backend URL