A beautifully themed interactive web quiz that sorts users into their Hogwarts house based on their answersβjust like the Sorting Hat! Built with Next.js 14 App Router, TypeScript, Tailwind CSS, and hosted on Vercel.
Live site: https://harrypotter-hogwarts-sorting.vercel.app
src/ β βββ app/ # App Router pages and routes β βββ quiz/ # Quiz logic and pages β βββ admin/ # Admin dashboard (stats, questions) β βββ layout.tsx # Root layout β βββ components/ β βββ ui/ # Reusable UI components (buttons, cards) β βββ shared/ # Shared layout components (Header, Footer, Charts) β βββ lib/ β βββ constants.ts # Questions and house definitions β βββ types.ts # Custom TypeScript interfaces β βββ utils.ts # Utility functions β βββ styles/ # Global styles (tailwind.config, globals.css)
Each answer has a houseAffinity
like:
ts { Gryffindor: 2, Slytherin: 1, }
At the end of the quiz, the house with the highest total score is chosen for the user.
π Admin Stats Dashboard
Accessible at /admin/stats. Displays:
Horizontal bar chart of house distribution
Total quizzes taken
Average questions answered
Most common sorting period (mocked)
π§ Environment Variables
If youβre using Gemini API or external integrations, add .env.local:
NEXT_PUBLIC_GEMINI_API_KEY=your-api-key-here
π¦ Build & Deploy Local Development
git clone https://github.com/devspidr/HPHH.git cd HPHH npm install npm run dev
Deploy to Vercel
Push to GitHub
Import to Vercel
Set the following in Environment Variables: Key: NEXT_PUBLIC_GEMINI_API_KEY Value: AIzaSyA9oK9a-i0c4Q5yHdspGdl5CBh-uAxveVM
π Acknowledgments
Based on the Wizarding World by J.K. Rowling
Inspired by the Sorting Hat quiz on Pottermore
Icons by Lucide and React Icons
π¨βπ» Author
Soundar Balaji J
π https://github.com/devspidr
πΌ https://www.linkedin.com/in/soundar-balaji-j-133b691b9/
πͺ License
MIT License. This is a fan project and not affiliated with J.K. Rowling or Warner Bros.
Let me know if youβd like me to add:
Iβll be happy to enhance this!