How vaishnav-3/ai-project works
Main Components
• Frontend (Next.js App Router): This includes the “app” directory where pages, UI components, and layouts reside. Notice separate subdirectories such as:
• (auth): Containing sign-in/sign-up pages (authentication flows with Clerk).
• course/[courseId]: Dynamic routing for individual course pages with nested components (flashcards, notes, Q&A, quizzes).
• create and dashboard: For course creation and user-specific dashboards.
• API Endpoints within “app/api”: Contains endpoints to handle course generation, user creation, study type content generation, etc.
• Background Tasks and Orchestration (Inngest):
• Separate Inngest files (inngest/client.js and inngest/functions.js) and related API endpoints trigger backend functions for asynchronous operations, such as generating notes or study-type content.
• Database and Configuration:
• The “configs” folder holds files for AI models (using Google Gemini), database connection (db.js) and schema definitions (schema.js).
• Drizzle ORM setup (drizzle.config.js and SQL migration files in “drizzle”).
• External Services:
• Clerk for authentication.
• Google Gemini for AI content generation.
• Neon Serverless PostgreSQL for database hosting.
Relationships and Interactions
• User Interaction Flow:
• Users authenticate via Clerk on the frontend (pages under app/(auth)).
• Authenticated users interact with dashboards and course pages.
• API and Background Workflow:
• When users initiate actions (e.g., generating a course outline or study materials), the client calls corresponding API endpoints (in “app/api/...”).
• The API endpoints trigger background tasks via Inngest functions (e.g., GenerateNotes, GenerateStudyTypeContent) and update the course state in the database.
• Database Operations:
• API endpoints and Inngest tasks interact with the Neon PostgreSQL database through Drizzle ORM (configured in configs/db.js and schema.js).
Architectural Patterns/Design Principles
• Separation of Concerns: Frontend components are separated from backend API logic, and asynchronous tasks are offloaded to Inngest.
• Modular Design: Each service (authentication, content generation, study material rendering) is encapsulated in its own module or API route.
• Dynamic Routing: Next.js dynamic routing for courses (course/[courseId]) allows for individual course pages.
• Asynchronous Processing: Background task orchestration via Inngest ensures that AI content generation and database updates are processed in a decoupled manner.
Relevant Technologies
• Frontend: Next.js, React, Tailwind CSS, client-side UI libraries.
• Backend/API: Node.js, Next.js API Routes.
• Authentication: Clerk.
• Background Tasks: Inngest.
• Database: Neon PostgreSQL with Drizzle ORM.
• AI Service: Google Gemini.
• Additional scripts or configuration from package.json, jest.config.js, etc., that support the build and testing process.
Specific Elements
• Frontend: App Router with subdirectories (auth, course, dashboard, create).
• API Endpoints: /api/courses, /api/generate-course-outline, /api/create-user, /api/study-type, /api/study-type-content.
• Inngest Service: Functions like GenerateNotes and GenerateStudyTypeContent.
• Configuration and Database modules (configs, drizzle).
• External Services: Clerk, Google Gemini, Neon PostgreSQL.
• Client → API → Inngest functions.
• Inngest functions → Database.
• API → External Services (if directly involved).
• That all dependencies (e.g., the use of Drizzle ORM, integration with Clerk) are clearly marked.