Skip to content

icekidtech/devtrivia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

288 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ DevTrivia

A real-time, interactive quiz platform for tech events (inspired by Kahoot).

DevTrivia Demo

Table of Contents

๐ŸŒŸ Features

  • ๐ŸŽฏ Guest Mode: Join quizzes without signing up.
  • โšก Real-Time Play: Live leaderboard, WebSockets, and dynamic scoring.
  • ๐Ÿค– AI Question Generation: OpenAI-powered quiz questions.
  • ๐Ÿ› ๏ธ Moderator Tools: Create/manage quizzes, export results (CSV/PDF).
  • ๐ŸŽจ Theming: Dark/light mode + custom branding.

๐Ÿ›  Tech Stack

Area Technology
Frontend Next.js (TypeScript + Tailwind CSS)
Backend NestJS (Node.js)
Database PostgreSQL + Prisma ORM
Realtime Socket.IO
Auth NextAuth.js (JWT + Guest Mode)
AI OpenAI API (Question generation)
Deployment Vercel (Frontend) + Railway (Backend)

๐Ÿ“‚ Project Structure

devtrivia/
โ”œโ”€โ”€ backend/           # NestJS backend
โ”‚   โ”œโ”€โ”€ src/          
โ”‚   โ”‚   โ”œโ”€โ”€ auth/      # JWT authentication  
โ”‚   โ”‚   โ”œโ”€โ”€ quizzes/   # Quiz logic (CRUD, WebSockets)  
โ”‚   โ”‚   โ”œโ”€โ”€ users/     # User management  
โ”‚   โ”‚   โ””โ”€โ”€ main.ts    # App entry point  
โ”‚   โ””โ”€โ”€ prisma/        # DB schema + migrations  
โ”‚
โ”œโ”€โ”€ frontend/          # Next.js frontend  
โ”‚   โ”œโ”€โ”€ src/app/       # App Router (Next.js 13+)  
โ”‚   โ”œโ”€โ”€ components/    # React UI components  
โ”‚   โ””โ”€โ”€ lib/           # API clients, utilities  
โ”‚
โ”œโ”€โ”€ .env.example       # Environment variables template  
โ””โ”€โ”€ README.md          # This file  

๐Ÿš€ Quick Start

1. Clone & Install

git clone https://github.com/icekidtech/devtrivia.git
cd devtrivia
cd backend && pnpm install
cd ../frontend && ppnpm install

2. Set Up Database

  1. Install PostgreSQL and create a database named devtrivia.
  2. Update backend/.env:
    DATABASE_URL="postgresql://user:password@localhost:5432/devtrivia?schema=public"
    JWT_SECRET="your-jwt-secret-here"
    OPENAI_API_KEY="sk-your-openai-key"  # Optional for AI questions
  3. Run migrations:
    cd backend
    npx prisma migrate dev --name init
    npx prisma studio  # Optional: GUI to view DB

3. Run Servers

  • Backend:
    cd backend
    pnpm run start:dev  # http://localhost:3000
  • Frontend:
    cd ../frontend
    pnpm run dev        # http://localhost:3001

๐Ÿ”Œ API Endpoints (Backend)

Endpoint Method Description
/api/auth/guest POST Generate a guest session
/api/quizzes/create POST Create a new quiz (Moderator)
/api/socket.io WS Realtime quiz events

๐ŸŒ Frontend Routes

Route Description
/ Homepage + quiz join
/moderator Quiz creation dashboard
/play/[id] Live quiz session

๐Ÿ”ง Scripts

Command Action
pnpm run dev (FE/BE) Start dev server
npx prisma studio Open DB GUI (http://localhost:5555)
npx prisma migrate dev Run DB migrations

๐Ÿ“œ Environment Variables

Backend (.env)

DATABASE_URL="postgresql://user:password@localhost:5432/devtrivia?schema=public"
JWT_SECRET="change-this-to-a-random-string"
OPENAI_API_KEY="sk-..."  # Only if using AI

Frontend (.env.local)

NEXT_PUBLIC_BACKEND_URL="http://localhost:3000"
NEXTAUTH_SECRET="same-as-jwt-secret"

๐Ÿ› Debugging Tips

  • Database Issues: Run npx prisma studio to inspect tables.
  • CORS Errors: Ensure backend/src/main.ts allows your frontend origin.
  • Socket.IO: Verify the WebSocket path matches in both frontend/backend.

๐Ÿ“… Roadmap

  • Implement guest join flow
  • Add WebSockets for realtime play
  • Integrate OpenAI question generation

๐Ÿ“œ License

MIT

๐Ÿ™Œ Owner

About

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors