Skip to Content
Persona Lab

Architecture & API

Project structure, API routes, and security model for Persona Lab.

Project Structure

src/app/          Next.js App Router pages and API routes
src/components/   UI components (personas, folders, research chat, synthesis)
src/lib/          Database, multi-provider AI, auth, rate limiting, and research logic
db/schema.sql     PostgreSQL schema
db/seed.sql       12 starter personas

API Routes

RoutePurpose
/api/auth/login, /api/auth/logoutSession cookie authentication
/api/personas, /api/personas/[id]List, create, update, and delete personas
/api/personas/generateBulk AI persona generation
/api/folders, /api/folders/[id]Manage hierarchical persona folders
/api/sessions, /api/sessions/[id]Create, update, and delete research sessions
/api/sessions/[id]/personasAdd or remove personas in a session
/api/sessions/[id]/chatSend prompts and receive per-persona responses
/api/sessions/[id]/synthesisGenerate cross-persona synthesis reports

Security Model

  • Session cookies: HTTP-only, Secure, SameSite=Lax cookies with a 12-hour idle expiration.
  • Lockout & rate limiting: Per-IP and per-username login lockout, plus per-session AI rate limiting.
  • Password rotation: Updating AUTH_PASSWORD and redeploying invalidates existing session tokens immediately.

On this page