GDG on Campus Workshop Project
Build an AI-powered study assistant using React, Firebase, and Google Gemini
- π PDF & Text Upload - Extract content from PDFs or paste text directly
- π AI Study Plans - Generate personalized day-by-day study schedules
- π§ Smart Quizzes - Take AI-generated quizzes (MCQ, True/False, Short Answer)
- π Progress Tracking - Track completed study days and quiz scores
- π Anonymous Auth - No sign-up required, powered by Firebase
- Node.js 18+ installed (download)
- A Google account
- Code editor (VS Code recommended)
# Clone the project (or download ZIP)
git clone <repository-url>
cd ai-study-assistant
# Install dependencies
npm install
npm install firebase- Go to Firebase Console
- Click "Create a project" (or use existing)
- Name it something like
gdg-study-assistant - Disable Google Analytics (optional for workshop)
- Click Create project
- In Firebase Console β Authentication β Get started
- Go to Sign-in method tab
- Click Anonymous β Enable β Save
- In Firebase Console β Firestore Database β Create database
- Select Start in test mode (for workshop purposes)
- Choose a location close to you β Enable
- Go to Project Settings (gear icon) β General
- Scroll to "Your apps" β Click Web icon (
</>) - Register app with nickname (e.g.,
study-assistant-web) - Copy the config object
Open src/lib/firebase.js and replace the config:
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "YOUR_PROJECT_ID.firebaseapp.com",
projectId: "YOUR_PROJECT_ID",
storageBucket: "YOUR_PROJECT_ID.appspot.com",
messagingSenderId: "YOUR_SENDER_ID",
appId: "YOUR_APP_ID"
};- Go to Google AI Studio
- Click "Create API key"
- Copy the API key
Open src/lib/gemini.js and replace:
const API_KEY = 'YOUR_GEMINI_API_KEY';npm run devOpen http://localhost:5173 in your browser π
ai-study-assistant/
βββ src/
β βββ components/
β β βββ FileUpload.jsx # PDF/text upload component
β β βββ StudyPlanGenerator.jsx # Study plan UI
β β βββ QuizGenerator.jsx # Quiz UI with scoring
β βββ lib/
β β βββ firebase.js # Firebase config & auth
β β βββ gemini.js # Gemini API integration
β β βββ pdfParser.js # PDF text extraction
β β βββ database.js # Firestore operations
β βββ App.jsx # Main app component
β βββ main.jsx # Entry point
β βββ index.css # Tailwind styles
βββ index.html
βββ package.json
βββ vite.config.js
βββ tailwind.config.js
βββ README.md
// Anonymous sign-in - no account needed!
export const signInAnon = async () => {
const result = await signInAnonymously(auth);
return result.user;
};// Generate study plan with Gemini
export const generateStudyPlan = async (content, numberOfDays) => {
const prompt = `Create a ${numberOfDays}-day study plan for: ${content}`;
const result = await model.generateContent(prompt);
return JSON.parse(result.response.text());
};// Extract text from uploaded PDF
export const extractTextFromPDF = async (file) => {
const pdf = await pdfjsLib.getDocument({ data: arrayBuffer }).promise;
// Extract text from each page...
};// Save study material
export const saveMaterial = async (userId, material) => {
return await addDoc(collection(db, 'materials'), {
userId,
...material,
createdAt: serverTimestamp()
});
};Create a flashcard component that shows terms/definitions from the material.
Add a button to download the study plan as a PDF or markdown file.
Show previous quiz scores and allow retaking old quizzes.
Generate a shareable link for study plans.
-
Never expose API keys in frontend code!
- Use Firebase Cloud Functions or a backend server
- Store keys in environment variables
-
Update Firestore Rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /materials/{doc} {
allow read, write: if request.auth != null
&& request.auth.uid == resource.data.userId;
}
// Similar rules for studyPlans, quizzes, quizResults
}
}- Set up API key restrictions in Google Cloud Console
Found a bug or want to add a feature? PRs welcome!
MIT License - Feel free to use this for your own workshops!
Built with β€οΈ for GDG on Campus