Ryan Frigo Logo
Projects

Perspektiv

May 13, 2025
Perspektiv is an AI-powered debate tool that transforms a single prompt into a structured, multi-perspective report using a format like Pro/Con/Synthesis. The goal was to build and ship a functional SaaS product—fast, cheap, clean. Nothing extra. It needed to:
  • 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
A clean monorepo (Next.js frontend + FastAPI backend) tied together with Celery for async jobs, PostgreSQL for structured data, and Clerk + Stripe for auth and billing.
  • Real-time SSE streaming
  • Debate templates (Pro/Con/Synth)
  • PDF export from UI
  • Stripe subscription management
  • Clean dev experience via Cursor IDE and Docker
| Layer | Choice & Why | | ------------- | ------------------------------------------------------ | | Frontend | Next.js + Tailwind – slick DX, SSR, easy Vercel deploy | | State | React Context + useReducer – minimal boilerplate | | Backend | FastAPI (Python) – async, type‑hinted, automatic docs | | LLM | GPT-4o via openai SDK – abstracted provider file | | Queue | Celery + Redis – triggered only if job > 5s | | DB | Postgres – users, debates, messages | | Storage | S3 – for transcripts & PDF exports | | Auth | Clerk.dev – JWT tokens | | Billing | Stripe – tiered subscriptions | | Hosting | Vercel (FE), AWS Fargate (API + Worker) | | Observability | Sentry + CloudWatch (basic setup) | | Targets | ≤15s p95 latency · ≤ $0.05 cost per debate |
Browser → Next.js → FastAPI → GPT‑4o        (short debates)
                   │
                   └─ Celery/Redis → GPT‑4o  (long debates)
                   │
                   ├─ Postgres
                   └─ S3 (exports)
SSE streams responses directly to frontend.
  1. Sign-up via Clerk OAuth
  2. Dashboard shows usage + past debates
  3. New Debate → select template, submit prompt
  4. Loading bar shows real-time streaming
  5. Result view with Pro/Con/Synth tabs
  6. Export as PDF
  7. History page → revisit old debates
  8. Account → Stripe portal for plan changes
Bash
brew install redis awscli
pyenv install 3.12.3 && pyenv global 3.12.3
npm install -g pnpm
Clone the GitHub repo: perspektiv-mvp
/ (root)
  frontend/          # Next.js
  backend/           # FastAPI + Celery
  docker/            # Docker & Compose files
  .env.example
  package.json
  turbo.json
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
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
Yaml
docker-compose.yaml
services:
  db:
    image: postgres:16-alpine
    ports: [5432:5432]
  redis:
    image: redis:7-alpine
    ports: [6379:6379]
Set DATABASE_URL and REDIS_URL env vars.
  • 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/*
  • 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
I built and deployed this in a 7-day solo sprint:
  • 2 days backend
  • 2 days frontend
  • 1 day infra setup
  • 2 days polish + QA
It’s fast, clean, modular, and designed to scale just enough to get feedback before iterating. If you want to fork it, use it, or build on it—feel free to reach out.
Thanks for reading. You can explore the project at perspektiv.ai.