AI-powered study companion that transforms your notes into interactive flashcards with intelligent generation, smart storage, and subscription-based usage tiers.
- Features
- Tech Stack
- Application Structure
- Prerequisites
- Getting Started
- Setup Guides
- Development
- Troubleshooting
- π― Smart Flashcard Generation β Powered by Groq LLM, automatically create flashcards from your study material
- πΎ Persistent Storage β Save named flashcard sets with Firebase/Firestore for organized studying
- π Set Management β Browse, rename, and delete your saved flashcard collections
- π΄ Interactive Study View β Flip-card interface for reviewing saved sets
- π Smart Quotas β Usage limits tied to subscription tier
- π Clerk Authentication β Modern sign-in/sign-up with email or Google account
- π³ Stripe Integration β Checkout for different subscription plans
- π Tiered Plans β Free, Basic, and Pro plans with different usage allowances
- π¦ Billing Portal β Customer portal for managing subscriptions and invoices
| Plan | Generations/Month | Saved Sets | Price |
|---|---|---|---|
| Free | 10 | 3 | N/A |
| Basic | 100 | 25 | $5 |
| Pro | 500 | Unlimited | $10 |
| Category | Technologies |
|---|---|
| Frontend | Next.js 14, React 18, Material UI |
| Backend | Next.js API Routes, Firebase Admin SDK |
| Database | Firebase / Firestore |
| Auth | Clerk |
| AI | Groq LLM (Llama 3.1) |
| Payments | Stripe |
| Deployment | Vercel |
| Route | Purpose |
|---|---|
/ |
Landing page with pricing showcase |
/generate |
AI flashcard generation interface |
/flashcards |
Saved flashcard set library |
/flashcard?id=<setId> |
Individual set review view |
/sign-in / /sign-up |
Authentication pages |
/billing |
Plan details, usage stats, billing portal |
/result |
Checkout result confirmation |
| Method | Route | Purpose |
|---|---|---|
POST |
/api/generate |
Generate flashcards from text |
GET |
/api/flashcard-sets |
List user's saved sets |
POST |
/api/flashcard-sets |
Save new flashcard set |
GET |
/api/flashcard-sets/[setId] |
Load specific set |
PATCH |
/api/flashcard-sets/[setId] |
Rename set |
DELETE |
/api/flashcard-sets/[setId] |
Delete set |
GET |
/api/billing |
Get user's billing summary |
POST |
/api/billing_portal |
Open Stripe portal |
POST |
/api/checkout_sessions |
Create checkout session |
GET |
/api/checkout_sessions |
Get session result |
POST |
/api/stripe/webhook |
Stripe webhook handler |
Before running FlashBot locally, ensure you have:
- Node.js 18.17+ and npm
- A Clerk application
- A Firebase project with Firestore enabled
- A Groq API key
- A Stripe account (for checkout functionality)
npm installCopy the example env file:
cp .env.local.example .env.localUpdate the file with your credentials:
# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_your_publishable_key
CLERK_SECRET_KEY=sk_test_your_secret_key
# Firebase Web (Browser)
NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_web_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your-project-id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your-project.firebasestorage.app
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_messaging_sender_id
NEXT_PUBLIC_FIREBASE_APP_ID=your_firebase_app_id
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=G-XXXXXXXXXX
# Firebase Admin (Server-side)
FIREBASE_ADMIN_PROJECT_ID=your-project-id
FIREBASE_ADMIN_CLIENT_EMAIL=firebase-adminsdk-xxxxx@your-project-id.iam.gserviceaccount.com
FIREBASE_ADMIN_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY\n-----END PRIVATE KEY-----\n"
# Groq AI
GROQ_API_KEY=gsk_your_groq_api_key
GROQ_MODEL=llama-3.1-8b-instant
# Stripe
NEXT_PUBLIC_STRIPE_PUBLIC_KEY=pk_test_your_stripe_publishable_key
STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key
STRIPE_WEBHOOK_SECRET=whsec_your_stripe_webhook_secret
STRIPE_BASIC_PRICE_ID=price_your_basic_monthly_price_id
STRIPE_PRO_PRICE_ID=price_your_pro_monthly_price_id
NEXT_PUBLIC_APP_URL=http://localhost:3000| Variable | Purpose |
|---|---|
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY / CLERK_SECRET_KEY |
Enable Clerk authentication flows |
NEXT_PUBLIC_FIREBASE_* |
Configure browser Firebase app initialization |
FIREBASE_ADMIN_* |
Enable secure server-side Firestore access |
GROQ_API_KEY |
Required for AI flashcard generation |
GROQ_MODEL |
LLM model selection (default: llama-3.1-8b-instant) |
NEXT_PUBLIC_STRIPE_PUBLIC_KEY / STRIPE_SECRET_KEY |
Enable Stripe checkout and portal |
STRIPE_WEBHOOK_SECRET |
Verify incoming Stripe webhook events |
STRIPE_BASIC_PRICE_ID / STRIPE_PRO_PRICE_ID |
Map your Stripe products to plans |
NEXT_PUBLIC_APP_URL |
Stripe callback URLs (success, cancel, portal return) |
Note: If Clerk is not configured, the app renders normally, but authentication pages show a setup message.
-
Create a Firebase Project
- Go to Firebase Console
- Create a new project and register a Web App
-
Copy Web Config
- Find your web app config and populate
NEXT_PUBLIC_FIREBASE_*variables
- Find your web app config and populate
-
Enable Firestore
- Enable Firestore Database (use production mode and apply locked rules)
-
Create Service Account
- Generate a Firebase Admin service account
- Download the JSON key and populate
FIREBASE_ADMIN_*variables
-
Deploy Firestore Rules
- Apply the security rules from
firestore.rulesto your database
- Apply the security rules from
Firebase Architecture:
firebase.jsβ Browser app initialization withNEXT_PUBLIC_FIREBASE_*lib/firebase-admin.jsβ Server-side admin initialization- Data stored at:
users/{clerkUserId}/flashcardSets/{setId}
-
Create a Clerk Application
- Go to the Clerk Dashboard
- Create a new application (or select an existing one)
-
Configure Allowed Origins & Redirect URLs
- For local development, add
http://localhost:3000to:- Allowed origins
- Allowed redirect URLs (for sign-in/sign-up)
- Allowed webhooks (optional for advanced features)
- For local development, add
-
Retrieve Your API Keys
- From the Clerk dashboard, copy:
- Publishable key β
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY - Secret key β
CLERK_SECRET_KEY
- Publishable key β
- Add them to your
.env.localfile and restart the dev server
- From the Clerk dashboard, copy:
-
Verify Authentication Flows
- Visit
/sign-inor/sign-upin your local app - Ensure Clerk renders the hosted UI and you can sign in with email or Google
- Visit
-
Create Products & Prices
- Log into Stripe Dashboard
- Create recurring monthly prices for "Basic" and "Pro" plans
- Copy the price IDs into
STRIPE_BASIC_PRICE_IDandSTRIPE_PRO_PRICE_ID
-
Set Up Webhooks Locally
stripe listen --forward-to localhost:3000/api/stripe/webhook
- Copy the signing secret into
STRIPE_WEBHOOK_SECRET
- Copy the signing secret into
-
Test Checkout
- Use Stripe test cards:
4242 4242 4242 4242(Visa) - Confirm all keys are set, then restart the dev server
- Use Stripe test cards:
npm run devThen open http://localhost:3000
Tip: Restart the dev server after adding or changing environment variables.
npm run build
npm run startnpm run lint| Issue | Solution |
|---|---|
Missing publishableKey |
Verify Clerk keys in .env.local are correct |
Unauthorized |
Sign in before generating, saving, or checking out |
Missing Firebase Admin credentials |
Add all FIREBASE_ADMIN_* variables to .env.local |
Missing GROQ_API_KEY |
Add API key and restart dev server |
| Duplicate save/rename errors | Set names must be unique per user |
| Stripe checkout fails | Verify all Stripe keys and price IDs, restart server |
| Subscription not updating | Check webhook forwarder is running and secret matches |
| Node version warnings | Upgrade to Node 18.17+ |