Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ“ AI Study Assistant

GDG on Campus Workshop Project
Build an AI-powered study assistant using React, Firebase, and Google Gemini

Workshop Banner React Firebase Gemini

🌟 Features

  • πŸ“„ 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

πŸ› οΈ Workshop Setup (15 minutes)

Prerequisites

  • Node.js 18+ installed (download)
  • A Google account
  • Code editor (VS Code recommended)

Step 1: Clone & Install

# Clone the project (or download ZIP)
git clone <repository-url>
cd ai-study-assistant

# Install dependencies
npm install
npm install firebase

Step 2: Firebase Setup

  1. Go to Firebase Console
  2. Click "Create a project" (or use existing)
  3. Name it something like gdg-study-assistant
  4. Disable Google Analytics (optional for workshop)
  5. Click Create project

Enable Authentication

  1. In Firebase Console β†’ Authentication β†’ Get started
  2. Go to Sign-in method tab
  3. Click Anonymous β†’ Enable β†’ Save

Create Firestore Database

  1. In Firebase Console β†’ Firestore Database β†’ Create database
  2. Select Start in test mode (for workshop purposes)
  3. Choose a location close to you β†’ Enable

Get Firebase Config

  1. Go to Project Settings (gear icon) β†’ General
  2. Scroll to "Your apps" β†’ Click Web icon (</>)
  3. Register app with nickname (e.g., study-assistant-web)
  4. Copy the config object

Update Config in Code

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"
};

Step 3: Gemini API Setup

  1. Go to Google AI Studio
  2. Click "Create API key"
  3. Copy the API key

Update Config in Code

Open src/lib/gemini.js and replace:

const API_KEY = 'YOUR_GEMINI_API_KEY';

Step 4: Run the App

npm run dev

Open http://localhost:5173 in your browser πŸŽ‰


πŸ“ Project Structure

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

πŸ” Code Walkthrough

1. Firebase Authentication (src/lib/firebase.js)

// Anonymous sign-in - no account needed!
export const signInAnon = async () => {
  const result = await signInAnonymously(auth);
  return result.user;
};

2. Gemini AI Integration (src/lib/gemini.js)

// 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());
};

3. PDF Text Extraction (src/lib/pdfParser.js)

// Extract text from uploaded PDF
export const extractTextFromPDF = async (file) => {
  const pdf = await pdfjsLib.getDocument({ data: arrayBuffer }).promise;
  // Extract text from each page...
};

4. Firestore Database (src/lib/database.js)

// Save study material
export const saveMaterial = async (userId, material) => {
  return await addDoc(collection(db, 'materials'), {
    userId,
    ...material,
    createdAt: serverTimestamp()
  });
};

🎯 Workshop Challenges

Challenge 1: Add Flashcard Mode

Create a flashcard component that shows terms/definitions from the material.

Challenge 2: Export Study Plan

Add a button to download the study plan as a PDF or markdown file.

Challenge 3: Quiz History

Show previous quiz scores and allow retaking old quizzes.

Challenge 4: Share Feature

Generate a shareable link for study plans.


πŸ”’ Security Notes

⚠️ For Production:

  1. Never expose API keys in frontend code!

    • Use Firebase Cloud Functions or a backend server
    • Store keys in environment variables
  2. 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
  }
}
  1. Set up API key restrictions in Google Cloud Console

πŸ“š Resources


🀝 Contributing

Found a bug or want to add a feature? PRs welcome!


πŸ“„ License

MIT License - Feel free to use this for your own workshops!


Built with ❀️ for GDG on Campus

Report Bug Β· Request Feature

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages