A full-stack "Would You Rather" game application built with Go backend and React frontend. Users can vote on questions and submit their own questions to the database.
| Backend | Frontend |
|---|---|
| Go with Gin framework | React with TypeScript |
| MongoDB for data storage | Vite for build tooling |
| RESTful API architecture | Modern component-based architecture |
- 🗳️ Vote on Questions - Browse and vote on "Would You Rather" questions
- 📝 Submit Questions - Add your own questions to the database
- 📊 Progress Tracking - Visual indicators for voting progress
- 📱 Responsive Design - Works on mobile and desktop
- ⚡ Real-time Voting - Live vote counting
- 🔧 Error Handling - Comprehensive error states and loading screens
wouldyouratherchoose/
├── 🔧 backend/
│ ├── cmd/wouldyouratherchoose/main.go # 🚀 Application entry point
│ ├── internal/
│ │ ├── db/ # 🗄️ Database connection
│ │ ├── handler/ # 🌐 HTTP handlers
│ │ ├── service/ # 💼 Business logic
│ │ ├── repository/ # 📊 Data access layer
│ │ ├── model/ # 🏗️ Data models
│ │ └── middleware/ # 🔒 HTTP middleware
│ └── seed/ # 🌱 Database seeding
├── 🎨 frontend/
│ ├── src/
│ │ ├── components/ # ⚛️ React components
│ │ ├── pages/ # 📄 Page components
│ │ ├── services/ # 🔌 API calls
│ │ └── types/ # 📝 TypeScript types
│ └── public/ # 📂 Static assets
└── 📖 README.md
- Go 1.19 or higher
- Node.js 18 or higher
- MongoDB instance (local or cloud)
-
Navigate to the backend directory:
cd backend -
Install Go dependencies:
go mod download
-
Create environment file: Create a
.envfile in the backend directory:MONGO_URI=mongodb://localhost:27017 DB_NAME=wouldyourather FRONTEND_ORIGIN=http://localhost:5173
-
Seed the database:
go run seed/seed.go
-
Start the backend server:
go run cmd/wouldyouratherchoose/main.go
🌐 The API will be available at
http://localhost:8080
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Create environment file: Create a
.envfile in the frontend directory:VITE_API_BASE_URL=http://localhost:8080
-
Start the development server:
npm run dev
🎯 The application will be available at
http://localhost:5173
Check out the live application: wouldyouratherchoose.vercel.app
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/questions |
Retrieve questions for voting |
POST |
/api/votes |
Submit a vote for a question |
POST |
/api/questions |
Submit a new question |
Backend:
cd backend
go test ./...Frontend:
cd frontend
npm testBackend:
cd backend
go build -o bin/wouldyouratherchoose cmd/wouldyouratherchoose/main.goFrontend:
cd frontend
npm run buildWe welcome contributions! Here's how to get started:
- 🍴 Fork the repository
- 🌿 Create a feature branch (
git checkout -b feature/new-feature) - 💾 Commit your changes (
git commit -m 'Add new feature') - 📤 Push to the branch (
git push origin feature/new-feature) - 🔄 Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by @prabalesh