How plastic-labs/tutor-gpt works
Project type and purpose
• This is a full-stack Next.js application (“app” directory uses the Next.js App Router).
• It provides a web UI (React components in components/) for an LLM-powered learning companion called Tutor-GPT.
• It uses Supabase for database/auth, Honcho for user modeling, Stripe for billing, PostHog for analytics, and an OpenAI-compatible inference endpoint for LLM calls.
File structure
• app/
• Next.js pages, layouts and server-handler API routes (chat, webhook, auth, settings).
• components/
• React components for UI: chat window, auth flows, settings, design system (components/ui).
• hooks/
• Custom React hooks for front-end behaviors (autoscroll, reactions).
• utils/
• Shared modules: AI client wrappers, Supabase clients, Stripe actions, PDF parsing, prompts, caching.
• supabase/
• SQL migrations, seed data, and email templates for Supabase Auth.
• scripts/stripeSync.mjs
• Lifecycle scripts for syncing subscription state.
• Config files
• Dockerfile/docker-compose.yaml for containerization; environment templates; Sentry/PostHog configs.
README for additional insights
• Confirms third-party integrations: Honcho (personalization), Supabase (auth + Postgres), Openrouter/open-ai API, PostHog, Stripe, Mistral OCR.
• Describes Supabase SSR auth flow, local dev with Docker, and environment variables needed.
Essential architectural elements
• Don’t break the Next.js app into overly fine details: treat app/ and utils/ as separate layers.
• Both real-time interactions (chat messages → AI) and event-driven flows (Stripe webhooks, script sync).