A real-time multiplayer quiz game backend built with Go, inspired by Kahoot.
- REST API for quiz creation and session management
- Real-time WebSocket communication
- PostgreSQL database integration
- Docker support
- AI-powered quiz generation (optional)
- Language: Go 1.22+
- Web Framework: Gin
- WebSocket: Gorilla WebSocket
- Database: PostgreSQL (via pgx)
- Configuration: Environment variables with .env support
- Logging: Structured logging with Logrus
- Deployment: Docker + AWS EC2/RDS
- Go 1.22 or higher
- PostgreSQL database
-
Clone and setup the project:
git clone <your-repo-url> cd quizzy-backend
-
Install dependencies:
go mod download
-
Configure environment:
cp .env.example .env # Edit .env with your database credentials -
Run the server:
go run cmd/server/main.go
The server will start on http://localhost:8080
- Health check:
GET http://localhost:8080/health - API endpoints:
http://localhost:8080/api/v1/
quizzy-backend/
├── cmd/server/ # Main entry point
├── internal/
│ ├── config/ # Configuration loading
│ ├── db/
│ │ ├── model/ # Data models
│ │ └── repository/ # Database queries
│ ├── handler/ # HTTP route handlers
│ ├── quiz/ # Quiz business logic
│ ├── session/ # Game session management
│ ├── websocket/ # WebSocket handling
│ └── ai/ # AI integration
├── pkg/
│ └── logger/ # Logging utilities
├── migrations/ # Database migrations
├── .env.example # Environment variables template
└── go.mod # Go module definition
See .env.example for all available configuration options.
# Build image
docker build -t quizzy-backend .
# Run container
docker run -p 8080:8080 quizzy-backendPOST /api/v1/quiz- Create a new quizGET /api/v1/quiz/:id- Get quiz details
POST /api/v1/session- Create a game sessionGET /api/v1/session/:pin- Get session details
GET /api/v1/ws/:pin- WebSocket connection for game session
This project is perfect for learning Go! Each component demonstrates different Go concepts:
- Structs & Interfaces: Data models and repository patterns
- Goroutines & Channels: WebSocket handling and real-time communication
- HTTP Servers: REST API with Gin framework
- Database Integration: PostgreSQL with pgx driver
- Error Handling: Go's explicit error handling patterns
- Package Organization: Clean architecture with internal packages
This is a learning project! Feel free to:
- Add new features
- Improve error handling
- Add tests
- Optimize performance
- Enhance documentation
This project is for educational purposes.