Sorting-Hat

πŸ§™β€β™‚οΈ Harry Potter - Hogwarts House Sorting Quiz

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.


✨ Features


πŸš€ Demo

Live site: https://harrypotter-hogwarts-sorting.vercel.app


πŸ› οΈ Tech Stack


🧩 Folder Structure

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)


🧠 Sorting Logic

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!