How emmy123222/tutor works
Project Type & Purpose
• Type: Full-stack, serverless web application
• Purpose: AI-powered educational platform that generates lessons, quizzes, flashcards, and PDFs using OpenAI
Main Components
a. Client (Browser / Mobile)
• React-based UI (Next.js pages & components)
• Pages: index.tsx (home/topic input), dashboard.tsx (results view)
• Components: LessonViewer, QuizComponent, Flashcard, SubjectInput
• Static assets & CSS (global.css, PrismJS)
b. Frontend Framework
• Next.js 14 with server-side rendering (SSR) & client-side hydration
• _app.tsx for global state & styles
c. API Layer (Serverless Functions)
• Next.js API routes under pages/api/:
• POST /generate-lessons
• POST /generate-quiz
• POST /generate-flashcards
• POST /export-pdf
• Each handler validates input, invokes backend utils, and returns JSON or PDF
d. Backend Utilities
• backend/utils/ai.ts: Wraps OpenAI GPT-3.5-turbo calls, builds & parses prompts
• backend/utils/pdf.ts: Uses pdf-lib to generate formatted PDF documents
e. External Services
• OpenAI API: Natural language generation
• (Optionally) Vercel Edge Network / CDN for static asset delivery
f. Development Tooling
• Kiro config & hooks (.kiro/):
• Auto-test-generation
• PDF & flashcard export hooks
• Jest for unit & integration tests
• CI/CD via Vercel (or alternative platforms)
Relationships & Data Flows
• User → Browser UI → Next.js frontend (React)
• Frontend → HTTP(S) → Next.js API route
• API route → Backend utils → External service (OpenAI)
• API route → pdf-lib → returns PDF stream
• API response → Frontend → Render or Trigger Download
• Kiro hooks & tests operate offline: interact with codebase but not runtime
Key Architectural Patterns
• Serverless functions for scaling API routes
• Separation of concerns: UI vs. API vs. AI logic vs. PDF logic
• Stateless API handlers (no persistent database)
• Modular utilities (ai.ts, pdf.ts) for single-responsibility
• CI/CD automation with Kiro and Vercel