A modern, interactive flashcard generator app built with React, TypeScript, and Tailwind CSS. Features PDF upload support and uses Google's Gemini 2.5 Flash API for intelligent flashcard generation.
-
Three Input Methods:
- Describe Topic: Generate flashcards from a topic description
- Paste Text: Extract flashcards from pasted text content
- Upload PDF: Upload PDF files and extract flashcards from the content
-
Interactive Study Mode:
- Beautiful 3D flip animations
- Keyboard navigation (arrow keys)
- Progress tracking
- Responsive design
-
AI-Powered Generation:
- Uses Google Gemini 2.5 Flash API
- Intelligent content extraction and flashcard creation
- Optimized prompts for different content types
- Node.js (v16 or higher)
- npm or yarn
- Google AI API key
-
Clone the repository:
git clone <repository-url> cd flashcardgen
-
Install dependencies:
npm install
-
Get a Google AI API Key:
- Go to Google AI Studio
- Create a new API key
- Copy the API key
-
Configure the API Key:
Option A: Using Environment Variables (Recommended)
- Create a
.envfile in the project root:
echo "VITE_GEMINI_API_KEY=your-actual-api-key-here" > .env
Option B: Direct Code Replacement
- Open
src/FlashcardApp.tsx - Replace
'YOUR_API_KEY'with your actual API key:
const model = new genAI.GenerativeModel('gemini-1.5-flash', 'your-actual-api-key-here');
- Create a
-
Start the development server:
npm run dev
-
Open your browser: Navigate to
http://localhost:3000
-
Choose an input method:
- Describe Topic: Enter a topic like "capitals of the world" or "fun facts about San Diego"
- Paste Text: Paste any text content you want to extract flashcards from
- Upload PDF: Click the upload area and select a PDF file
-
Generate Flashcards:
- Click "Generate flashcards" button
- Wait for the AI to process your content
- Your flashcards will be ready to study!
- Flip Cards: Click on a card or use ↑↓ arrow keys
- Navigate: Use ←→ arrow keys or click the navigation buttons
- Progress: See your current position (e.g., "3 / 10")
- Create New: Click "Create new flashcards" to start over
- Frontend: React 18 with TypeScript
- Styling: Tailwind CSS
- Build Tool: Vite
- AI API: Google Gemini 1.5 Flash (latest)
- PDF Processing: PDF.js
The app includes comprehensive console logging to help debug issues:
- 🔧 API Initialization: Logs Gemini API setup process
- 📁 File Upload: Tracks PDF file processing
- 📖 PDF Extraction: Detailed PDF.js loading and text extraction
- 🚀 Flashcard Generation: Step-by-step AI generation process
- ❌ Error Handling: Detailed error information with context
Open your browser's developer console (F12) to see detailed logs during operation.
flashcardgen/
├── src/
│ ├── FlashcardApp.tsx # Main application component
│ ├── main.tsx # React entry point
│ └── index.css # Global styles with Tailwind
├── index.html # HTML template
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── vite.config.ts # Vite configuration
├── tailwind.config.js # Tailwind CSS configuration
└── README.md # This file
The app uses Google's Gemini 2.5 Flash API for generating flashcards. The API is loaded dynamically from CDN and configured with your API key.
PDF files are processed client-side using PDF.js, which extracts text content for flashcard generation. No files are uploaded to external servers.
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run type-check- Run TypeScript type checking
For production deployment, consider using environment variables for the API key:
-
Create a
.envfile:VITE_GEMINI_API_KEY=your-api-key-here -
Update the API key usage in
FlashcardApp.tsx:const model = new genAI.GenerativeModel('gemini-2.0-flash-exp', import.meta.env.VITE_GEMINI_API_KEY);
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details.
If you encounter any issues or have questions, please open an issue on the repository.