Concept & Design
- Let users input a topic and select a format
- Use GPT-4o to generate structured arguments
- Stream results live and support PDF export
- Keep infra + dev time minimal
What I Built
Key Features
- Real-time SSE streaming
- Debate templates (Pro/Con/Synth)
- PDF export from UI
- Stripe subscription management
- Clean dev experience via Cursor IDE and Docker
1. Quick Tech Spec
2. Minimal Architecture
Browser → Next.js → FastAPI → GPT‑4o (short debates)
│
└─ Celery/Redis → GPT‑4o (long debates)
│
├─ Postgres
└─ S3 (exports)
SSE streams responses directly to frontend.
3. Core User Journey
- Sign-up via Clerk OAuth
- Dashboard shows usage + past debates
- New Debate → select template, submit prompt
- Loading bar shows real-time streaming
- Result view with Pro/Con/Synth tabs
- Export as PDF
- History page → revisit old debates
- Account → Stripe portal for plan changes
4. Build Guide (Cursor on macOS)
Phase 0 · Prereqs
Bash
brew install redis awscli
pyenv install 3.12.3 && pyenv global 3.12.3
npm install -g pnpm
Phase 1 · Monorepo Layout
/ (root)
frontend/ # Next.js
backend/ # FastAPI + Celery
docker/ # Docker & Compose files
.env.example
package.json
turbo.json
Phase 2 · Backend Setup (FastAPI)
Bash
cd backend
python -m venv .venv && source .venv/bin/activate
pip install fastapi[all] uvicorn psycopg[binary] redis celery "openai>=1.12" python-dotenv boto3
- Models: User, Debate, Message (SQLAlchemy)
- /debates routes: POST to create, GET/stream to stream results
- LLM service wraps GPT-4o API
- Celery task runs long debates and stores results
- Auth via Clerk JWT introspection
- Stripe webhook syncs plan + quota info
Phase 3 · Frontend Setup (Next.js 14)
Bash
pnpm create next-app frontend --ts --tailwind
- Auth with Clerk → wrap <ClerkProvider>
-
Routes:
- /dashboard: list debates, start new
- /new: input topic, pick template
- /debate/[id]: stream + view result
- Use EventSource to receive real-time LLM output
- Export via React‑PDF or backend-generated PDFKit
Phase 4 · Local Dev Orchestration
Yaml
docker-compose.yaml
services:
db:
image: postgres:16-alpine
ports: [5432:5432]
redis:
image: redis:7-alpine
ports: [6379:6379]
Phase 5 · Deploy
- Frontend: vercel --prod
-
Backend/Worker: AWS Fargate
- FastAPI task (port 8000)
- Celery task (no port)
- IAM role for S3 + SecretsManager
-
Infra:
- RDS Postgres (free tier)
- Redis (AWS ElastiCache or Upstash)
- S3 (presigned export links only)
-
Webhooks:
- Stripe and Clerk point to api.perspektiv.ai/webhook/*
Phase 6 · Polish & Launch
- Seed DB with Pro/Con/Synth templates
- Rate-limit free plan (10 debates/month)
- Sentry in both FE + BE
- robots.txt, landing copy
- README for devs
Final Thoughts
- 2 days backend
- 2 days frontend
- 1 day infra setup
- 2 days polish + QA
Thanks for reading. You can explore the project at perspektiv.ai.
