Studdy-Buddy is an AI-powered study companion platform built with Next.js that revolutionizes the way students create and consume educational content. The application leverages Google's Gemini AI to automatically generate comprehensive study materials including notes, flashcards, quizzes, and Q&A sessions from any topic. With integrated YouTube recommendations, a marketplace for sharing study materials, and a credit-based premium system powered by Stripe, Studdy-Buddy provides a complete learning ecosystem for students and educators.
- Frontend: Next.js 15, React 18, Tailwind CSS
- Backend: Next.js API Routes, Drizzle ORM
- Database: PostgreSQL (Neon)
- Authentication: Clerk
- AI Integration: Google Gemini AI
- Payment Processing: Stripe
- Background Jobs: Inngest
- External APIs: YouTube Data API v3
- UI Components: Radix UI, Lucide React
- Deployment: Vercel
👉 AI-Powered Study Material Generation: Automatically create comprehensive study materials using Google Gemini AI, including detailed notes, interactive flashcards, quizzes, and Q&A sessions from any topic or content you provide.
👉 Smart Course Creation: Input any topic and difficulty level to generate structured courses with chapters, topics, and organized learning paths.
👉 Interactive Study Modes:
- Notes: AI-generated comprehensive notes for each chapter
- Flashcards: Interactive flip cards for quick review and memorization
- Quiz: Multiple-choice questions with instant feedback
- Q&A: Question-answer pairs for deeper understanding
👉 YouTube Integration: Smart YouTube video recommendations based on course content using advanced embedding similarity matching for relevant educational videos.
👉 Marketplace System:
- Share your study materials publicly with the community
- Discover and learn from materials created by other users
- Upvote and favorite system for quality content
- Public course pages with SEO-friendly URLs
👉 Credit-Based System:
- Free tier with 2 credits for new users
- Premium subscription for unlimited access
- Secure Stripe payment integration
👉 User Dashboard:
- Track all your created courses
- Monitor study progress
- Manage favorites and created content
- Credit usage analytics
👉 Background Processing: Inngest-powered background jobs for AI content generation, ensuring responsive user experience while processing intensive AI requests.
👉 Responsive Design: Modern, dark/light theme-compatible UI that works seamlessly across desktop, tablet, and mobile devices.
👉 Authentication & Security: Secure authentication with Clerk, including social login options and user management.
-
Course Creation Flow:
- User inputs topic and difficulty level
- AI generates course outline with chapters and topics
- Background job processes detailed content generation
- Content is progressively made available as it's generated
-
Study Material Processing:
- Inngest background jobs handle AI content generation
- Multiple AI models for different content types (notes, quiz, Q&A)
- Parallel processing for optimal performance
-
YouTube Recommendations:
- Course topics are converted to embeddings using Gemini
- YouTube search results are matched using cosine similarity
- Recommendations are cached for performance
-
Marketplace System:
- Users can publish courses publicly
- SEO-friendly public URLs with course slugs
- Upvoting and favoriting system
Follow these steps to set up the project locally on your machine.
Make sure you have the following installed:
git clone https://github.com/Sanskargupta0/Studdy-Buddy.git
cd Studdy-BuddyInstall dependencies using npm or use pnpm:
npm installor
pnpm install- Create a
.envfile in the root directory by copying from.env.example:
cp .env.example .env- Fill in all the required environment variables in your
.envfile. See the Environment Variables section below for detailed instructions on obtaining each key.
-
Set up PostgreSQL Database:
- Create a free PostgreSQL database on Neon
- Copy the connection string to your
.envfile
-
Run Database Migrations:
npx drizzle-kit push- Sign up at Clerk
- Create a new application
- Copy the publishable key and secret key to your
.envfile - Set up webhooks for user management (optional but recommended)
- Go to Google AI Studio
- Create a new API key for Gemini
- Add the API key to your
.envfile - Consider setting up multiple API keys for rate limiting
- Create account at Stripe
- Get your secret key from the dashboard
- Create a product and price for monthly subscription
- Copy the price ID to your
.envfile
- Go to Google Cloud Console
- Enable YouTube Data API v3
- Create credentials and get API key
- Add to your
.envfile
- Sign up at Inngest
- Create a new app and get signing key
- Add to your
.envfile
- Start the development server:
npm run dev- Start Inngest background job processor (in a separate terminal):
npx inngest-cli@latest devImportant: Both commands must be running simultaneously for the application to work properly. The Inngest CLI handles background job processing for AI content generation.
- Open your browser and navigate to
http://localhost:3000
All required environment variables with descriptions:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: Your Clerk publishable keyCLERK_SECRET_KEY: Your Clerk secret keyCLERK_WEBHOOK_SECRET: Webhook secret for Clerk events (optional)
NEXT_PUBLIC_DATABASE_CONNECTION_STRING: PostgreSQL connection string from Neon
NEXT_PUBLIC_GEMINI_API_KEY: Primary Gemini API key2ndNEXT_PUBLIC_GEMINI_API_KEY: Secondary API key for rate limiting3rdNEXT_PUBLIC_GEMINI_API_KEY: Tertiary API key for rate limiting
STRIPE_SECRET_KEY: Your Stripe secret keyNEXT_PUBLIC_STRIPE_PRICE_ID_MONTHLY: Price ID for monthly subscription
YOUTUBE_API_KEY: YouTube Data API v3 key
INNGEST_SIGNING_KEY: Inngest signing key for background job processing
HOST_URL: Your application URL (usehttp://localhost:3000/for development)
- Sign up/Login: Use the authentication system powered by Clerk
- Access Dashboard: Navigate to your personal dashboard
- Create Course: Click "Create New Course"
- Input Details:
- Enter your topic (be specific for better results)
- Select difficulty level (Easy, Medium, Hard)
- Wait for Generation: AI will create your course structure
- Study: Access notes, flashcards, quiz, and Q&A sections
- 📝 Notes: Comprehensive, AI-generated study notes for each chapter
- 🔄 Flashcards: Interactive cards with front/back content for memorization
- ❓ Quiz: Multiple-choice questions with instant feedback
- 💬 Q&A: Question-answer pairs for deeper understanding
- Publish: Make your courses available to the community
- Discover: Browse courses created by other users
- Engage: Upvote helpful content and save favorites
- Share: Each public course gets a unique, SEO-friendly URL
studdy-buddy/
├── app/ # Next.js app directory
│ ├── api/ # API routes
│ │ ├── courses/ # Course management
│ │ ├── generate-course-outline/ # AI course generation
│ │ ├── payment/ # Stripe integration
│ │ ├── youtube-recommendations/ # YouTube API
│ │ └── ...
│ ├── dashboard/ # Authenticated user area
│ │ ├── course/[courseId]/ # Individual course pages
│ │ ├── create/ # Course creation
│ │ ├── marketplace/ # Course discovery
│ │ └── upgrade/ # Payment pages
│ ├── public/[slug]/ # Public course pages
│ └── _context/ # React context
├── components/ # Reusable UI components
│ └── ui/ # Shadcn/ui components
├── configs/ # Configuration files
│ ├── AiModel.js # AI model configurations
│ ├── db.js # Database connection
│ └── schema.js # Database schema
├── inngest/ # Background job functions
├── lib/ # Utility functions
└── public/ # Static assets
# Install dependencies
npm install
# Start development server
npm run dev
# Start Inngest background jobs (separate terminal)
npx inngest-cli@latest dev
# Build for production
npm run build
# Start production server
npm start
# Lint code
npm run lint
# Database operations
npx drizzle-kit push # Push schema changes
npx drizzle-kit studio # Open database studioThe application uses Inngest for reliable background job processing:
- Course Generation: AI content creation happens in background
- Content Processing: Notes, flashcards, quizzes generated asynchronously
- Error Handling: Automatic retries and error recovery
- Status Updates: Real-time status updates for users
Important: Always run npx inngest-cli@latest dev in a separate terminal during development.
- Modern Design: Clean, minimalist interface with focus on readability
- Dark/Light Theme: Automatic theme switching with user preference
- Responsive Layout: Optimized for desktop, tablet, and mobile devices
- Loading States: Skeleton loaders and progress indicators
- Error Handling: User-friendly error messages and retry mechanisms
- Accessibility: ARIA labels, keyboard navigation, and screen reader support
- Free Tier: 2 credits for new users
- Credit Usage: 1 credit per course generation
- Premium Plan: Unlimited credits with monthly subscription
- Credit Tracking: Real-time credit balance in dashboard
- Authentication: Secure authentication with Clerk
- API Protection: Route protection for authenticated endpoints
- Environment Variables: Sensitive data stored securely
- CORS Configuration: Proper cross-origin resource sharing setup
- Input Validation: Server-side validation for all user inputs
- Inngest not working: Ensure
npx inngest-cli@latest devis running - AI generation fails: Check Gemini API key and quota limits
- YouTube recommendations not loading: Verify YouTube API key
- Payment issues: Confirm Stripe configuration
- Database errors: Check PostgreSQL connection string
- Use multiple Gemini API keys for better rate limiting
- Monitor credit usage to avoid hitting API limits
- Cache YouTube recommendations to reduce API calls
- Optimize database queries for better performance
If you encounter any issues or have questions:
- Check the troubleshooting section above
- Review your environment variables configuration
- Ensure all external services are properly set up
- Check console logs for detailed error messages
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
Built with ❤️ by Sanskar Gupta










