A timed trivia quiz application that allows users to sign up, play dynamic quizzes, view results, track play history, and compete on a leaderboard.
Responsibilities:
- Built the entire backend server using Node.js, Express, and MongoDB
- Initialized project and managed GitHub repository as the repo owner
- Wrote and formatted the full
README.mddocumentation - Handled all backend logic, routes, data models, and API integration
- Created two separate MongoDB databases:
userscollection for authenticationuserScorescollection for tracking quiz results
- Fully deployed the live app on Render including environment setup and domain
- Connected the backend with MongoDB Atlas using
.envsecurely
API Endpoints:
-
GET /api/start?amount=N- Fetches
Nquiz questions from the Trivia API (default 10) - Generates a unique
gameId - Starts a 120-second quiz timer
- Stores session in memory
- Returns:
{ gameId, questions }
- Fetches
-
POST /api/submit- Receives:
{ gameId, username, userAnswers } - Checks if submission is within the time limit
- Compares answers, calculates score
- Saves:
{ username, score, timeTaken, numQuestions }touserScoresin MongoDB - Returns:
{ score, timeTaken }
- Receives:
-
GET /api/history/:username- Retrieves full quiz attempt history for a user from the
userScorescollection - Returns data sorted by date/time
- Retrieves full quiz attempt history for a user from the
-
GET /api/leaderboard- Returns top 10 players
- Sorted by:
- Highest score
- Fastest time (as tiebreaker)
-
POST /api/user/signup- Creates a new user account
- Validates inputs and ensures unique usernames
- Stores users in the
userscollection in MongoDB
-
POST /api/user/signin- Authenticates an existing user based on stored credentials
- Used for login and access to profile/play history
Deployment:
- Deployed the entire full-stack app (backend and frontend) on Render
- Managed
.envconfiguration securely in the Render dashboard - Handled MongoDB URI integration and ensured live server is connected
- Verified all endpoints, session handling, and frontend/backend integration work live
Live App: https://quizapp-enwg.onrender.com/
Setup:
- Developed
script.jsto control quiz behavior - Integrated with backend endpoints for starting games, submitting answers, leaderboard, and history
- Used
localStorageto store username and result summaries - Handled game session memory, score tracking, and sound effects
- Applied dynamic DOM rendering for quiz flow
Key Features:
-
startQuiz()- Starts a quiz with selected question amount (
/api/start?amount=N) - Retrieves question amount using
localStorage.getItem("questionAmount") - Initializes 120-second countdown
- Stores
gameIdand questions - Renamed HTML call to safely use
if (window.startQuiz) window.startQuiz(); - Resolved conflict from double declarations of
startQuiz()
- Starts a quiz with selected question amount (
-
nextQuestion()- Validates answer selection
- Provides feedback with audio and visual cues (Correct! / Wrong!)
- Displays centered alert boxes that auto-fade
- Updates DOM elements like question count and category
- Navigates through questions and scores
- Ends quiz and triggers submission on last question
-
submitQuiz()- Sends game data to
/api/submitincluding:gameId,userAnswers,username, andtotalQuestions - Receives and displays
scoreandtimeTaken - Shows friendly "Time's Up!" screen if timer runs out
- Stores results in
localStorageand redirects toresults.html - Added alerts and error handling if score saving fails
- Sends game data to
-
showFinalResult()- Displays score, time, and timestamp
- Pulls from
localStorage
-
startTimer()- Starts and manages 120s countdown
- Auto-submits quiz on timeout
- Locks interaction and updates UI
-
UI/UX Improvements:
- Connected question amount buttons to script logic instead of relying on missing dropdowns
- Saved question amount from
quiz.htmlusinglocalStorage.setItem("questionAmount", N) - Improved layout with
centerQuizLayout()for all screen sizes - Cleaned up spacing and alignment for quiz text, buttons, and containers
- Removed unused/legacy elements and dropdowns
- Ensured state consistency across screens (quiz → results)
Setup:
- Created the frontend using HTML and CSS. Each
.htmlfile corresponds to a specific section of the application and is styled usingstyle.css.
HTML Files & Structure:
-
index.html- Acts as the main authentication portal
- Includes Sign Up and Log In forms within toggleable containers
- Input fields are validation-ready for username, email, and password
- Redirects to the quiz on successful authentication (via JavaScript)
- Contains site-wide header and footer with branding
-
home.html- Welcome/start page with a quiz description and timer warning
- Central “Start Quiz” button linked to
quiz.html - Structured using
.containerclass for spacing and alignment
-
quiz.html- Quiz setup interface where users choose number of questions (5–20)
- Hidden main quiz UI includes:
#timerelement (styled for visibility)- Category and question tracker
#quiz-questionand dynamically generated options- Sticky “Next” button
-
results.html- Displays final quiz results:
- Score in
X/10format - Time taken in seconds
- Score in
- Includes a “Restart Quiz” button with soft hover transitions
- Uses centered
.containerlayout with large headings
- Displays final quiz results:
-
profile.html- Displays a personalized welcome using the logged-in username
- Lists user’s past attempts using dynamically generated rows inside
#history-container
-
leaderboard.html- Shows top 10 players sorted by score and time
- Dynamically updates with rank, username, score, and time
- Styled using
#leaderboard-containerwith hover effects and responsive layout
-
signin.html- Standalone login screen for users
- Consistent UI with
index.htmlusing the same.containerlayout and form styling
Styling (style.css):
-
Color & Typography:
- Soft pastel palette:
#EDA9A9,#fcd6dc,#ffeef2 - Clean sans-serif font stack for a modern, readable look
- Soft pastel palette:
-
Layout & Components:
.containersets max-width and centers content.auth-box,.signup-container: card-style containers with rounded corners and shadows.site-headerand.site-footer: styled with spacing and consistent branding
-
Forms & Inputs:
- Inputs styled with padding, border-radius, and interactive hover feedback
- Buttons are rounded-pill style with transitions on hover
- Responsive full-width layout for mobile
-
Quiz-Specific Styles:
.question,.label,.options: block-style with background and margin for mobile-friendly design#timer: large, bold, and color-highlighted (#d6788d)- Quiz layout is touch-friendly and vertically stacked
-
Results & Leaderboard:
- Score/time outputs use enlarged fonts and spacing
.results-title,.score-line,.time-line: center-aligned for visibility#leaderboard-container: boxed layout with shadows and hover interaction for ranked players
- Clone the repository
git clone https://github.com/your-username/quizApp.git
cd quizApp
npm install
MONGO_URI=your_mongo_atlas_connection_string
node server.js
# or use nodemon if installed
nodemon server.js
http://localhost:3000