Skip to content

ObaidAbdullah16/Quiz-App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  AI Quiz App

An intelligent, beginner-friendly quiz application powered by Google Gemini AI that generates unlimited quiz questions on diverse topics. Get personalized learning experiences with instant feedback and detailed explanations.

๐ŸŒ Live Demo

๐Ÿ‘‰ quiz.obaidinfo.xyz - Primary URL
๐Ÿ‘‰ kwiz.obaidinfo.xyz - Alternative URL

Both URLs point to the same application hosted on AWS S3 with CloudFront CDN for fast global access.


โœจ Features

  • ๐ŸŽฒ Random Topic Generation - AI selects from 100+ diverse topics (History, Science, Sports, Movies, Technology, and more)
  • ๐Ÿค– AI-Powered Questions - Uses Google Gemini 2.5 Flash for intelligent question generation
  • ๐Ÿ“Š Real-Time Score Tracking - See your progress instantly
  • ๐Ÿ’ก Detailed Explanations - Learn why answers are correct with educational explanations
  • ๐Ÿ“ฑ Fully Responsive Design - Works perfectly on mobile, tablet, and desktop
  • ๐Ÿš€ No Backend Required - Pure front-end application, works as static website
  • โ˜๏ธ Cloud Hosted - Deployed on AWS S3 with CloudFront CDN
  • ๐Ÿ”’ Privacy Focused - API key stored locally in your browser only
  • ๐Ÿ’พ Topic History - Tracks used topics to ensure variety in questions
  • โšก Fast Loading - Instant page load with optimized assets

๐Ÿ› ๏ธ Technologies Used

  • Frontend:

    • HTML5 (Semantic markup)
    • CSS3 (Animations, Gradients, Responsive Design)
    • JavaScript (Vanilla ES6+, no frameworks)
    • Bootstrap 5 (UI Components)
  • AI & API:

    • Google Gemini 2.5 Flash API
    • JSON-based question generation
  • Hosting:

    • AWS S3 (Storage)
    • CloudFront CDN (Global distribution)
    • Route 53 DNS (Domain management)

๐Ÿ“š Available Quiz Topics

The app can generate quizzes on topics including but not limited to:

  • History: World History, Ancient Civilizations, Modern History, Art History
  • Science: Biology, Chemistry, Physics, Astronomy, Space Exploration
  • Geography: World Capitals, Countries & Flags, Mountains & Rivers
  • Entertainment: Movies, Cinema, Animated Films, TV Shows
  • Sports: Football, Basketball, Olympics, Cricket
  • Technology: AI, Programming, Computer Science, Inventions
  • Culture: Music, Literature, Mythology, Languages, Art
  • And 70+ more topics!

๐Ÿš€ Getting Started

Quick Start (Online)

Simply visit one of the live URLs above:

Local Setup

  1. Clone the repository:
git clone https://github.com/ObaidAbdullah16/Quiz-App.git
cd Quiz-App
  1. Get a Free Google Gemini API Key:

  2. Run locally:

    • Open index.html in your web browser
    • Or use a local server:
    python -m http.server 8000
    # Visit http://localhost:8000
  3. Start the quiz:

    • Paste your Google Gemini API key
    • Click "Save & Start Quiz"
    • Enjoy learning!

Note: Your API key is stored only in your browser's localStorage and never shared.

๐Ÿ“Š How It Works

Step-by-Step Process:

1. User enters API key
   โ†“
2. App generates random topic
   โ†“
3. AI creates 5 multiple-choice questions
   โ†“
4. User answers each question
   โ†“
5. Instant feedback with correct answer highlighted
   โ†“
6. Detailed explanation provided
   โ†“
7. Final score displayed with motivational message
   โ†“
8. User can start new quiz with different topic

Question Generation Flow:

Random Topic Selection (from 100+ topics)
          โ†“
Google Gemini API Request
          โ†“
AI Generates:
  - Question text
  - 4 Multiple choice options
  - Correct answer index
  - Educational explanation
          โ†“
JSON Response Parsing
          โ†“
Display on Screen with Animations

๐Ÿ“ Project Structure

Quiz-App/
โ”œโ”€โ”€ index.html          # Main HTML structure
โ”‚   โ”œโ”€โ”€ Header section with title & buttons
โ”‚   โ”œโ”€โ”€ API Key input form
โ”‚   โ”œโ”€โ”€ Quiz display section
โ”‚   โ”œโ”€โ”€ Results section
โ”‚   โ””โ”€โ”€ Loading spinner
โ”‚
โ”œโ”€โ”€ script.js          # JavaScript logic (~415 lines)
โ”‚   โ”œโ”€โ”€ API Configuration
โ”‚   โ”œโ”€โ”€ Global Variables & Topic List
โ”‚   โ”œโ”€โ”€ DOM Element References
โ”‚   โ”œโ”€โ”€ Event Listeners
โ”‚   โ”œโ”€โ”€ Quiz Generation Logic
โ”‚   โ”œโ”€โ”€ Question Display & Validation
โ”‚   โ”œโ”€โ”€ Score Calculation
โ”‚   โ”œโ”€โ”€ Topic History Management
โ”‚   โ””โ”€โ”€ Error Handling
โ”‚
โ”œโ”€โ”€ style.css          # Custom styling (~163 lines)
โ”‚   โ”œโ”€โ”€ Purple gradient background
โ”‚   โ”œโ”€โ”€ Card & Container styling
โ”‚   โ”œโ”€โ”€ Button animations & hover effects
โ”‚   โ”œโ”€โ”€ Topic display styling
โ”‚   โ”œโ”€โ”€ Explanation box animations
โ”‚   โ”œโ”€โ”€ Loading spinner
โ”‚   โ””โ”€โ”€ Mobile responsive design
โ”‚
โ””โ”€โ”€ README.md          # This file

๐ŸŽจ UI Components

1. API Key Setup Section

  • Input field for Google Gemini API key
  • "Save & Start Quiz" button
  • Link to get free API key
  • Privacy notice

2. Quiz Display

  • Current topic shown in alert box
  • Question counter (e.g., "Question 1/5")
  • Question text
  • 4 Multiple-choice answer buttons (A, B, C, D)
  • Real-time score display

3. Answer Feedback

  • Correct answer highlighted in green
  • Wrong answer highlighted in red
  • Detailed explanation with educational content
  • "Next Question" button

4. Results Screen

  • Final score display
  • Motivational message based on performance
  • "Try Another Topic" button to restart

5. Utility Buttons

  • "Reset Topic History" - Clear used topics
  • "Show Topic History" - View topics you've seen

๐Ÿ” Privacy & Security

โœ… Secure:

  • API key stored only in browser's localStorage
  • Never transmitted to any server except Google Gemini
  • No personal data collection
  • No tracking or analytics

โœ… Local Storage:

  • Used topics list saved locally
  • API key persists across sessions
  • User can clear all data anytime

๐Ÿ’ฐ Cost Breakdown

Component Cost
Google Gemini API FREE (60 requests/minute)
AWS S3 Storage FREE (5GB tier)
CloudFront CDN FREE (1GB/month tier)
Route 53 DNS $0.50/month
Total Monthly Cost ~$0.50

๐Ÿ“ฑ Responsive Design

Breakpoints:

Mobile:     320px - 576px   (Full width, optimized touch)
Tablet:     577px - 992px   (Wide layout, comfortable spacing)
Desktop:    993px+          (Max width 800px container)

Mobile Optimizations:

  • Reduced padding on small screens
  • Touch-friendly button sizes
  • Optimized font sizes
  • Full-screen support

๐Ÿงช Testing & Debugging

Browser Console:

Press F12 to open developer tools. You'll see:

  • Selected topic
  • API request details
  • API response data
  • Error messages with solutions

Troubleshooting:

"API Error: Invalid API Key"

  • Check if your API key is correct
  • Make sure it's for Google Gemini
  • Regenerate key at Google AI Studio

"No JSON found in response"

  • AI failed to generate valid JSON
  • Try again - it usually works on retry
  • Check browser console for details

"Network Error"

  • Check internet connection
  • Verify not behind restrictive firewall
  • Try disabling browser extensions

Questions not appearing?

  • Wait for loading spinner to complete
  • Check browser console (F12)
  • Clear localStorage and try again

๐Ÿš€ Deployment Guide

Deploy on AWS S3 + CloudFront (Recommended)

  1. Create S3 Bucket:

    aws s3 mb s3://quiz-app-production
  2. Upload Files:

    aws s3 sync ./ s3://quiz-app-production \
      --exclude "README.md" \
      --exclude ".git"
  3. Enable Static Website Hosting:

    • S3 Console โ†’ Properties โ†’ Static website hosting
    • Index document: index.html
    • Error document: index.html (for SPA routing)
  4. Create CloudFront Distribution:

    • Origin: S3 website endpoint
    • Alternate domain names: quiz.obaidinfo.xyz, kwiz.obaidinfo.xyz
    • SSL certificate: Your domain certificate
    • Default root object: index.html
  5. Update Route 53 DNS:

    Record name: quiz
    Type: A (Alias)
    Alias target: CloudFront domain
    
    Record name: kwiz
    Type: A (Alias)
    Alias target: CloudFront domain
    

Deploy on GitHub Pages

  1. Push to GitHub:

    git push origin main
  2. Enable GitHub Pages:

    • Settings โ†’ Pages
    • Branch: main
    • Deploy to https://username.github.io/Quiz-App

๐Ÿ“– Code Highlights

Clean Code Practices:

  • โœ… Extensive comments explaining logic
  • โœ… Semantic variable names
  • โœ… Modular functions (single responsibility)
  • โœ… Error handling with helpful messages
  • โœ… No external dependencies (vanilla JavaScript)

Key Functions:

generateQuiz()           // AI generates questions via Gemini API
displayQuestion()        // Shows current question on screen
selectAnswer()           // Handles user answer selection
nextQuestion()           // Moves to next question
showResults()            // Displays final score & message
getRandomUnusedTopic()   // Selects new topic with variety

๐ŸŒŸ Performance Metrics

  • Page Load Time: < 1 second
  • Quiz Generation: 2-3 seconds (API call)
  • Answer Feedback: Instant (< 100ms)
  • Overall Latency: Optimized with CDN caching

๐Ÿ“ Future Enhancements

  • Difficulty levels (Easy, Medium, Hard)
  • Custom topic input
  • Leaderboard with scoring history
  • Category-based quizzes
  • Timer mode (timed questions)
  • Dark mode toggle
  • Multiplayer quiz sessions
  • Export score as PDF
  • Community-shared quizzes
  • Mobile app version

๐Ÿค Contributing

Contributions are welcome! Here's how:

  1. Fork the repository
  2. Create a feature branch:
    git checkout -b feature/YourFeature
  3. Make your changes:
    • Add comments for complex logic
    • Ensure responsive design
    • Test on mobile & desktop
  4. Commit your changes:
    git commit -m "Add YourFeature"
  5. Push to your branch:
    git push origin feature/YourFeature
  6. Open a Pull Request

Ideas to Contribute:

  • New UI themes
  • Additional quiz topics
  • Performance optimizations
  • Accessibility improvements
  • Bug fixes & testing

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ‘จโ€๐Ÿ’ป Author

Obaid Abdullah

๐Ÿ“š Learning Resources

Want to learn more about the technologies used?

๐Ÿ› Known Issues

None currently! If you find any bugs or have issues, please report them.

๐Ÿ“ž Support

If you encounter any issues or have questions:

โญ Show Your Support

Give a โญ๏ธ if you found this project helpful!


Built with โค๏ธ using vanilla JavaScript and powered by Google Gemini AI

Last Updated: May 26, 2026

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors