Skip to content

SahilGupta721/CodeyVillage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

162 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Codey Village

Codey Village is a gamified developer productivity platform that rewards real-world coding activity with in-game currency. Solve a LeetCode problem, push a GitHub commit, or submit a job application β€” and watch your village grow.

Built as a full-stack web app with a Phaser 3 multiplayer game at its core, a Python FastAPI backend, a Node.js OAuth middleware server, and a Manifest v3 Chrome extension that passively monitors your activity across LeetCode, GitHub, and Workday.


πŸ† Awards


πŸ”— Links


Screenshots

Landing Page

Codey Village Landing Page

Game Lobby

Game Lobby

In-Game World

In-Game World


Table of Contents


Overview

Codey Village turns your daily developer workflow into a resource loop:

  1. A Chrome extension silently watches LeetCode, GitHub, and Workday.
  2. When it detects an accepted submission, a commit, or a job application, it fires a request to the FastAPI backend.
  3. The backend awards coins to your account and stores your activity in MongoDB.
  4. You spend those coins in the Next.js web app to build and decorate your island in a Phaser 3 top-down world.
  5. You can join multiplayer rooms (up to 5 players) over WebSockets and roam each other's villages in real time.

Features

Feature Description
Coin Earning Earn coins automatically from LeetCode solves, GitHub commits, and Workday job applications
Island Building Purchase and place buildings/decorations using earned coins
Multiplayer Rooms Real-time rooms supporting up to 5 simultaneous players via WebSockets
Player Interactions Interact with other players in the same room
Shop System Browse and buy items to customize your island
GitHub OAuth Link your GitHub account for commit tracking via webhooks
Activity Tracking Complete webhook and event pipeline from IDE β†’ extension β†’ backend β†’ game

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Browser                              β”‚
β”‚                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚   Next.js Frontend   β”‚   β”‚     Chrome Extension      β”‚  β”‚
β”‚  β”‚  (Phaser 3 Game UI)  β”‚   β”‚  (LeetCode / GitHub /     β”‚  β”‚
β”‚  β”‚  WebSocket client    β”‚   β”‚   Workday content scripts)β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚             β”‚                          β”‚                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚ HTTPS / WSS              β”‚ HTTPS
              β–Ό                          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Python FastAPI Backend β”‚   β”‚  Node.js OAuth Server    β”‚
β”‚  ─────────────────────  β”‚   β”‚  ──────────────────────  β”‚
β”‚  REST API               β”‚   β”‚  GitHub OAuth flow       β”‚
β”‚  WebSocket (rooms)      β”‚   β”‚  GitHub webhook receiver β”‚
β”‚  Coin system            β”‚   β”‚  Activity tracker        β”‚
β”‚  Island / shop logic    β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚  Firebase auth verify   β”‚
β”‚  ─────────────────────  β”‚
β”‚      MongoDB            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Data flow for a LeetCode coin award:

  1. User solves a LeetCode problem in the browser.
  2. The extension's leetcode.js content script detects the accepted submission.
  3. Extension sends a POST to the FastAPI backend /coins/award.
  4. Backend validates the Firebase auth token, increments user coins in MongoDB, and broadcasts to any active WebSocket room.
  5. The frontend updates the coin counter in real time.

Tech Stack

Layer Technology
Frontend Next.js 16, React 19, TypeScript, Phaser 3.90, Tailwind CSS 4
Auth Firebase Authentication
Backend Python 3.11, FastAPI, Uvicorn
Database MongoDB (Atlas) via pymongo
Real-time WebSockets (FastAPI native)
OAuth Server Node.js, Express 4
Chrome Extension Manifest v3, Vanilla JS
External APIs GitHub REST API, LeetCode (scraped), Workday
Deployment Render (backend), Vercel (frontend)
Containerization Docker (Python 3.11-slim)

Getting Started

Prerequisites

  • Node.js 18+ and npm
  • Python 3.11+
  • MongoDB Atlas account (or local MongoDB instance)
  • Firebase project with Authentication enabled
  • Google Chrome (for the extension)
  • A GitHub OAuth App (for the OAuth server)

Backend (Python FastAPI)

cd backend
pip install -r requirements.txt

Create a .env file in backend/:

MONGO_URL=mongodb+srv://<user>:<pass>@<cluster>.mongodb.net/?appName=<app>
FIREBASE_API_KEY=<your-firebase-api-key>
WEBHOOK_URL=https://<your-backend-domain>

Start the development server:

uvicorn main:app --reload --port 8000

The API will be available at http://localhost:8000. Interactive docs are at http://localhost:8000/docs.


OAuth/Webhook Server (Node.js)

cd server
npm install

Create a .env file in server/:

GITHUB_CLIENT_ID=<your-github-oauth-app-client-id>
GITHUB_CLIENT_SECRET=<your-github-oauth-app-client-secret>
WEBHOOK_URL=https://<your-backend-domain>
PORT=3001

Start the server:

npm start

Frontend (Next.js)

cd frontend
npm install

Create a .env.local file in frontend/:

NEXT_PUBLIC_IDENTITY_PLATFORM_API_KEY=<firebase-api-key>
NEXT_PUBLIC_IDENTITY_PLATFORM_AUTH_DOMAIN=<project>.firebaseapp.com
NEXT_PUBLIC_BACKEND_URL=http://localhost:8000
NEXT_PUBLIC_WS_URL=ws://localhost:8000

Start the development server:

npm run dev

Open http://localhost:3000 in your browser.

Available scripts:

npm run dev      # Start development server (hot reload)
npm run build    # Build for production
npm run start    # Start production server
npm run lint     # Run ESLint

Chrome Extension

  1. Open Chrome and navigate to chrome://extensions/.
  2. Enable Developer mode (top-right toggle).
  3. Click Load unpacked and select the extension/ directory.
  4. The Codey Village extension icon will appear in your toolbar.
  5. Sign in via the extension popup and connect your accounts.

The extension monitors:

  • leetcode.com β€” problem submissions
  • github.com β€” commit/push events
  • Workday job application portals β€” application submissions

Environment Variables

Backend (backend/.env)

Variable Description
MONGO_URL MongoDB Atlas connection string
FIREBASE_API_KEY Firebase project API key for token verification
WEBHOOK_URL Public URL of this backend (used for webhook registration)

Node.js Server (server/.env)

Variable Description
GITHUB_CLIENT_ID GitHub OAuth App Client ID
GITHUB_CLIENT_SECRET GitHub OAuth App Client Secret
WEBHOOK_URL Backend URL to forward GitHub webhook payloads
PORT Port to listen on (default: 3000)

Frontend (frontend/.env.local)

Variable Description
NEXT_PUBLIC_IDENTITY_PLATFORM_API_KEY Firebase API key
NEXT_PUBLIC_IDENTITY_PLATFORM_AUTH_DOMAIN Firebase auth domain
NEXT_PUBLIC_BACKEND_URL FastAPI backend base URL
NEXT_PUBLIC_WS_URL WebSocket URL for multiplayer

Deployment

Frontend β€” Vercel

The Next.js app is deployed to Vercel. Connect the frontend/ directory as the Vercel project root and set the environment variables in the Vercel dashboard.

Backend β€” Render

The FastAPI backend is deployed to Render. Connect your repository and set the environment variables in the Render dashboard. Use the following start command:

uvicorn main:app --host 0.0.0.0 --port 8000

API Overview

The FastAPI backend exposes the following route groups:

Prefix Description
/users User CRUD β€” profile, username, stats
/coins Coin award, balance, transaction history
/rooms Room creation, joining, listing
/island Island state, building placement
/shop Item catalog, purchase
/interactions Player-to-player interaction events
/ws WebSocket endpoint for real-time multiplayer

Full interactive documentation is available at /docs (Swagger UI) and /redoc when the backend is running.


Chrome Extension Details

The extension uses Manifest v3 with a persistent service worker and the following content scripts:

Script Injected On Purpose
leetcode.js leetcode.com/* Detects accepted problem submissions
github.js github.com/* Tracks commit/push activity
workday.js Workday job portals Detects completed job applications
webapp.js localhost:3000, production domain Bridges extension state with the game frontend
toast.js All monitored pages Renders coin-earned toast notifications

An injected/interceptor.js script is injected into the page context (not the extension context) to intercept outgoing API requests from LeetCode and GitHub before they leave the browser, allowing the extension to detect events without polling.


Multiplayer Architecture Notes

The WebSocket room manager (backend/routes/ws_routes.py) holds all active room and player state in memory inside a RoomManager class. This means the backend must run as a single instance β€” splitting across multiple instances would cause players in the same room to connect to different instances with no shared state.

The natural path to horizontal scaling is to move room state to a Redis pub/sub layer, which would allow any number of backend instances to share room events. This is the primary scalability improvement for a production rollout.


Project Structure

GDG-HACKS3/
β”œβ”€β”€ frontend/                   # Next.js web app
β”‚   β”œβ”€β”€ app/                    # App Router pages (auth, lobby, game, room/[id])
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ game/               # Phaser 3 game config, scenes, entities, map gen
β”‚   β”‚   β”œβ”€β”€ components/         # Shared React components
β”‚   β”‚   β”œβ”€β”€ hooks/              # Custom hooks (useCoins, useRoom, usePlayer)
β”‚   β”‚   β”œβ”€β”€ lib/                # Firebase, API client, Supabase utils
β”‚   β”‚   β”œβ”€β”€ store/              # Zustand game store
β”‚   β”‚   └── types/              # TypeScript type definitions
β”‚   └── public/                 # Static assets and game sprites
β”‚
β”œβ”€β”€ backend/                    # Python FastAPI service
β”‚   β”œβ”€β”€ main.py                 # App entrypoint, CORS, router registration
β”‚   β”œβ”€β”€ models/                 # Pydantic data models
β”‚   β”œβ”€β”€ controllers/            # Business logic
β”‚   β”œβ”€β”€ routes/                 # API route handlers + WebSocket manager
β”‚   β”œβ”€β”€ services/               # Firebase, GitHub, LeetCode integrations
β”‚   └── database/               # MongoDB connection
β”‚
β”œβ”€β”€ server/                     # Node.js OAuth + webhook middleware
β”‚   └── index.js                # Express app (GitHub OAuth, webhook receiver)
β”‚
β”œβ”€β”€ extension/                  # Chrome Extension (Manifest v3)
β”‚   β”œβ”€β”€ manifest.json
β”‚   β”œβ”€β”€ background/             # Service worker
β”‚   β”œβ”€β”€ popup/                  # Extension popup UI
β”‚   β”œβ”€β”€ content-scripts/        # Page-injected scripts (leetcode, github, workday)
β”‚   β”œβ”€β”€ injected/               # In-page context scripts (API interceptor)
β”‚   └── icons/                  # Extension icons (16, 48, 128px)
β”‚
└── LICENSE                     # GNU GPL v3

License

This project is licensed under the GNU General Public License v3.0. See LICENSE for the full text.

About

Codey Village is a gamified developer productivity platform that rewards real-world coding activity with in-game currency. πŸ† Best Gamification Hack: GDG Hacks 3

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors