How shlomoc/roast works
Project Type and Purpose
• This is a full-stack, server-rendered React web application built with Next.js 14 (app directory) and Tailwind CSS, exposing two REST API routes for AI roasting and TTS.
• Purpose: Accept a user’s photo, call external AI services (OpenRouter for roast text, ElevenLabs for speech), and present the results in a privacy-focused UI.
Main Components
a. Client Browser (React/Next.js)
b. Next.js Server (app router, serverless functions)
• API Route: /api/roast (image → OpenRouter AI → roast text)
• API Route: /api/tts (roast text → ElevenLabs TTS → audio)
c. UI Library & Static Assets
• Tailwind CSS, shadcn/ui components under src/components/ui
• Public folder for static files
d. Utility Layer
• src/lib/utils.ts for shared helpers
e. External Services
• OpenRouter.ai (AI vision + LLM models)
• ElevenLabs.io (Text-to-Speech)
Relationships & Data Flow
• User interacts with UI (upload or camera capture) → front-end posts image to /api/roast.
• Next.js API handler forwards image + parameters (model, intensity) to OpenRouter.
• OpenRouter returns roast text → Next.js returns JSON roast to front-end.
• User clicks “Play Roast” → front-end calls /api/tts with roast text.
• Next.js sends text to ElevenLabs → receives audio stream/URL → front-end plays audio.
Architectural Patterns & Design Principles
• Monolithic Next.js app with “app router” paradigm: pages, server components, and edge/serverless functions.
• Separation of concerns: UI components (src/components), styles (globals.css), business logic (src/lib/utils.ts), and API functions (src/app/api/…).
• Ephemeral processing: no persistent database or file storage; external APIs handle AI and TTS workloads.
• Environment-based configuration (.env.local) for secret keys.