How copilotkit/demo-presentation works
Project type and purpose
• This is a full-stack, server-rendered web application built on Next.js 13 (app router) that lets users build and navigate PowerPoint-like presentations in the browser.
• It leverages CopilotKit (LangChain + LangGraph) for AI-driven slide generation and research, Tavily for web research, OpenAI for text-to-speech, and a transcription endpoint for audio input.
File structure
• Top level
• next.config.mjs, tsconfig.json, Tailwind & PostCSS configs, package.json → standard Next.js/TypeScript setup.
• src/app/
• layout.tsx, page.tsx → Next.js layout + main entry point.
• components/
– buttons/ → UI controls (add, delete, generate slide, speak, research toggle).
– main/ → core presentation components (Header, Presentation container, Slide).
– misc/ → slide preview, number indicator.
• actions/ → React Server Actions or client hooks (useAppendSlide, useUpdateSlide) that mutate slide state.
• api/
– /copilotkit/research.ts & route.ts → serverless endpoint that invokes the CopilotKit researchAction using LangChain/Tavily.
– /tts/route.ts → serverless endpoint to generate speech via OpenAI TTS.
– /transcribe/route.ts → endpoint to transcribe audio inputs.
• utils/globalAudio.tsx → client audio playback manager.
• types.ts → shared TypeScript interfaces.
Extract architecture cues from the README
• Deploys on Vercel as serverless functions (Next.js API routes).
• Requires environment variables: NEXT_PUBLIC_COPILOT_CLOUD_API_KEY, TAVILY_API_KEY, OPENAI_API_KEY.
• Frontend makes calls to backend routes; backend routes proxy to external services (CopilotKit Cloud, Tavily, OpenAI).
• Client (Browser): Next.js/React UI, Tailwind styling
• CDN / Static Assets: public/ folder
• State & Hooks: useAppendSlide, useUpdateSlide, useMakeCopilotReadable (in components)
• Next.js Server (Vercel)
• App Server (SSR/SSG)
• API Routes
/api/copilotkit/research
/api/tts
/api/transcribe
• External Services
• CopilotKit Cloud API (LangChain + LangGraph)
• Tavily Research API
• OpenAI API (TTS)
• UI → (user action) → client hooks → Next.js API route → external service → JSON response → next.js server → client UI updates state
• UI “Speak” button → /api/tts → audio blob → globalAudio.play()
• Optional: audio capture → /api/transcribe → plain text → injected into slide content
c. Architectural patterns & principles
• Full-stack separation: React on client vs serverless API endpoints
• Server Actions / React Hooks to encapsulate side effects
• Micro-service style API routes in Next.js
• No persistent database: state lives in client memory; persistence can be added with a DB later
d. Key technologies/frameworks
• Next.js 13 (app directory, Server Components, API routes)
• React + TypeScript + Tailwind CSS
• CopilotKit (LangChain + LangGraph)
• Tavily API for web research
• OpenAI for TTS
• Vercel for hosting (serverless functions)