Skip to content
atshalahmedkhanPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

CodeOpoly 🎮💻

Competitive Coding Meets Monopoly — a real-time multiplayer game that combines the classic Monopoly board with LeetCode-style coding challenges. Solve problems to earn money, buy properties, and challenge opponents to code duels instead of paying rent.

Architecture

  • Frontend: React 18 + TypeScript + Vite + Tailwind CSS (client/)
  • Backend: Node.js + Express + Socket.io (server/)
  • Database: MongoDB via Mongoose, with an in-memory fallback store if MongoDB isn't connected
  • Code Execution: Judge0 API (via RapidAPI), with a client-side JS fallback when no key is set
  • Auth: username-only (no email/password) — the backend find-or-creates a player profile keyed by username and persists stats

Quick start (local)

# 1. Start MongoDB (Docker — persistent volume)
docker run -d --name codeopoly-mongo -p 27017:27017 -v codeopoly-mongo-data:/data/db mongo:7

# 2. Backend
cd server && npm install && npm run dev      # http://localhost:5001

# 3. Frontend (new terminal)
cd client && npm install && npm run dev      # http://localhost:3000

Then open http://localhost:3000 → pick a username → create/join a game.

CodeOpoly/
├── client/            # Vite React frontend
│   └── src/
│       ├── components/
│       ├── pages/
│       ├── hooks/
│       ├── services/
│       └── data/
└── server/            # Express + Socket.io backend
    └── src/
        ├── models/    # Mongoose schemas
        ├── routes/
        ├── socket/
        └── utils/

Game Features

  • Real-time multiplayer (2–4 players) over Socket.io
  • 40-space Monopoly board with tech-themed properties
  • Solve coding problems to buy properties
  • Code duels: challenge a property owner to avoid paying rent
  • Property upgrades (houses/hotels), Debug Hell (jail with bug-fixing), Chance/Community Chest events

Getting Started

Prerequisites

  • Node.js 18+ and npm
  • MongoDB (local or Atlas) — optional, falls back to an in-memory store if not connected
  • A RapidAPI account for Judge0 code execution

1. Install dependencies

cd server && npm install
cd ../client && npm install

2. Configure environment variables

server/.env

PORT=5001
MONGODB_URI=mongodb://localhost:27017/codeopoly
CLIENT_URLS=http://localhost:3000
RAPIDAPI_KEY=your-rapidapi-key-here
JUDGE0_API_URL=https://judge0-ce.p.rapidapi.com

3. Run it

# Terminal 1
cd server && npm run dev

# Terminal 2
cd client && npm run dev

Open http://localhost:3000.

Socket.io Events

Client → Server: join-game, roll-dice, buy-property, challenge-duel, submit-duel-code, end-turn, get-game-state

Server → Client: joined-game, player-joined, dice-rolled, landed-on-space, property-bought, duel-started, duel-progress, duel-ended, turn-ended, game-state

Deployment

See DEPLOYMENT.md.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages