Instruction file imported from giabaotran-2001/Quizzy (
.github/instructions/Quizzy.instructions.md). Copyright stays with the author.
Quizzy Backend – Instructions for GitHub Copilot
This project is a backend for Quizzy, a real-time multiplayer quiz game, inspired by Kahoot.
✅ Project Goals
- Build a real-time quiz game backend using Golang
- REST API for quiz creation and session management
- WebSocket support for real-time player interaction
- Store data in PostgreSQL (AWS RDS)
- Deploy via Docker and run on AWS EC2
- Optionally integrate OpenAI API for AI-generated quizzes
📦 Tech Stack
- Language: Go 1.22+
- Web Framework: Gin
- WebSocket: Gorilla WebSocket
- Database: PostgreSQL (via pgx or SQLC)
- Cloud: AWS EC2 + RDS
- Container: Docker
- CI/CD: GitHub Actions
- Optional AI: OpenAI API for question generation
🧱 Folder Structure
quizzy-backend/ ├── cmd/server/ # Main entry point (main.go) ├── internal/ │ ├── config/ # Load .env, setup DB, logger, etc. │ ├── db/ │ │ ├── model/ # Quiz, Question, Player, Session structs │ │ └── repository/ # DB logic (CRUD queries) │ ├── handler/ # Gin route handlers │ ├── quiz/ # Business logic (create quiz, validate input) │ ├── session/ # Manage game session state, PIN, score │ ├── websocket/ # Hub, Client, Broadcast logic │ └── ai/ # Connect to OpenAI or Gemini API ├── pkg/ # Common utils: logger, JWT, etc. ├── migrations/ # SQL migration files ├── Dockerfile └── README.md
🔁 Key Features
-
POST /quiz– Create a quiz -
POST /session– Create a new session from a quiz -
GET /ws/:pin– Connect host/player via WebSocket - Server broadcasts questions to all players
- Players answer via WebSocket → Score is calculated
- Real-time leaderboard sent back via WebSocket
🧠 Copilot Tips
- Suggest handler logic based on route comments
- Suggest WebSocket message handling in
websocket/client.goandwebsocket/hub.go - Use Gin context (
*gin.Context) in REST API - Write unit tests using
testifyor Go's testing package - Generate SQL queries with SQLC or pgx
🐳 Docker Commands
docker build -t quizzy-backend .
docker run -p 8080:8080 quizzy-backend
## ☁️ AWS Setup Notes
PostgreSQL on RDS (connect via config.LoadDB)
Go binary deployed to EC2
Use .env file or AWS SSM to store secrets