Skip to content

developerved2312/code-auction-arena

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฏ Code Auction

A complete full-stack web application for competitive coding events featuring live auctions, virtual currency, code evaluation, and real-time leaderboards.

Next.js TypeScript Prisma Tailwind CSS

๐Ÿš€ Quick Start

# Install dependencies
npm install

# Setup database
npx prisma db push

# Seed sample data
npm run db:seed

# Start development server
npm run dev

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

๐Ÿ”‘ Login Credentials

Role Username/ID Password
Admin admin admin123
Team 1 TEAM-001 team001pass
Team 2 TEAM-002 team002pass
Team 3 TEAM-003 team003pass
Team 4 TEAM-004 team004pass
Team 5 TEAM-005 team005pass

โœจ Features

๐Ÿ”จ Live Auction System

  • Real-time bidding with countdown timers
  • Minimum bid increments
  • Bid history tracking
  • Automatic auction ending

๐Ÿ’ฐ Virtual Currency Economy

  • Each team starts with 1000 Coins
  • Strategic resource management
  • Inverse pricing model (Easy = expensive, Hard = cheap)

๐Ÿ”’ Question Ownership Lock

  • Only winning teams can view full problem statements
  • Exclusive solving rights per question
  • No question sharing between teams

๐Ÿ’ป Code Evaluation

  • Monaco Editor (VS Code-like experience)
  • C, C++, Java, Python support
  • Hidden test case validation
  • Instant feedback on submissions

๐Ÿ“Š Real-time Leaderboard

  • Live score updates
  • Tie-breaker rules:
    1. Total Score (highest wins)
    2. Coins Remaining (more = better)
    3. Questions Purchased (fewer = better)

๐Ÿ› ๏ธ Admin Panel

  • Create/Edit/Delete teams
  • Manage question bank
  • Control auctions
  • Start/Pause/Reset events
  • Configure event settings

๐Ÿ“ Project Structure

โ”œโ”€โ”€ prisma/
โ”‚   โ”œโ”€โ”€ schema.prisma      # Database schema
โ”‚   โ””โ”€โ”€ seed.js            # Sample data seeder
โ”‚
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ api/           # REST API routes
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth/      # Login/logout/session
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auctions/  # Auction management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ questions/ # Question CRUD
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ submissions/ # Code evaluation
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ leaderboard/ # Rankings
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ teams/     # Team management
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ event/     # Event control
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”œโ”€โ”€ admin/         # Admin dashboard
โ”‚   โ”‚   โ”œโ”€โ”€ auctions/      # Auction browser
โ”‚   โ”‚   โ”œโ”€โ”€ dashboard/     # Team dashboard
โ”‚   โ”‚   โ”œโ”€โ”€ leaderboard/   # Public leaderboard
โ”‚   โ”‚   โ”œโ”€โ”€ login/         # Authentication
โ”‚   โ”‚   โ”œโ”€โ”€ rules/         # Event rules
โ”‚   โ”‚   โ””โ”€โ”€ solve/[id]/    # Code editor
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ lib/
โ”‚       โ”œโ”€โ”€ auth.ts        # JWT authentication
โ”‚       โ”œโ”€โ”€ evaluator.ts   # Code evaluation
โ”‚       โ”œโ”€โ”€ prisma.ts      # Database client
โ”‚       โ”œโ”€โ”€ store.ts       # Zustand state
โ”‚       โ”œโ”€โ”€ types.ts       # TypeScript types
โ”‚       โ””โ”€โ”€ utils.ts       # Helper functions
โ”‚
โ”œโ”€โ”€ CREDENTIALS.txt        # Login credentials
โ”œโ”€โ”€ TECH_STACK.txt         # Technology details
โ””โ”€โ”€ QUESTIONS_LOGIC.txt    # Question bank info

๐Ÿ—„๏ธ Database Models

Model Description
Team Team info, credentials, coins, score
Question Problems with test cases
QuestionPurchase Team ownership records
Auction Live auctions
Bid Auction bids
Submission Code submissions
EventConfig Global settings
AdminUser Admin credentials

๐Ÿ’Ž Pricing Model

Difficulty Base Price Reward Points
๐ŸŸข Easy 400-500 ยข 100-150 pts
๐ŸŸก Medium 250-350 ยข 250-300 pts
๐Ÿ”ด Hard 100-200 ยข 450-600 pts

๐Ÿ”ง Configuration

Environment Variables

# .env.local
DATABASE_URL="file:./dev.db"
JWT_SECRET="your-super-secret-key"

# Optional: Judge0 API for real code execution
JUDGE0_API_URL=https://judge0-ce.p.rapidapi.com
JUDGE0_API_KEY=your-api-key

Event Settings

Configure via Admin Panel or directly in database:

  • Initial coins per team
  • Minimum bid increment
  • Auction duration
  • Allow multiple submissions

๐Ÿ“œ API Endpoints

Authentication

  • POST /api/auth/login - Login
  • POST /api/auth/logout - Logout
  • GET /api/auth/me - Current session

Questions

  • GET /api/questions - List all questions
  • GET /api/questions/[id] - Get question details
  • POST /api/questions - Create question (admin)
  • PUT /api/questions/[id] - Update question (admin)
  • DELETE /api/questions/[id] - Delete question (admin)

Auctions

  • GET /api/auctions - List active auctions
  • POST /api/auctions - Start auction (admin)
  • POST /api/auctions/[id]/bid - Place bid
  • POST /api/auctions/[id]/end - End auction (admin)

Submissions

  • POST /api/submissions - Submit code
  • GET /api/submissions - Submission history

Leaderboard

  • GET /api/leaderboard - Current rankings

Teams

  • GET /api/teams - List teams (admin)
  • POST /api/teams - Create team (admin)
  • PUT /api/teams/[id] - Update team (admin)
  • DELETE /api/teams/[id] - Delete team (admin)

Event

  • GET /api/event - Event status
  • POST /api/event - Control event (admin)

๐ŸŽฎ How to Run an Event

  1. Setup - Run npm run db:seed to create teams and questions
  2. Admin Login - Go to /login, select Admin, use credentials
  3. Start Event - Click "Start Event" in admin panel
  4. Start Auctions - Go to Questions tab, click "Start Auction" on a question
  5. Teams Bid - Teams login and bid on the Auctions page
  6. Solve Questions - Winning teams solve their purchased questions
  7. Monitor - Watch the leaderboard update in real-time
  8. End Event - Stop event from admin panel

๐Ÿ›ก๏ธ Security Features

  • JWT tokens with HTTP-only cookies
  • Password hashing with bcrypt
  • Session-based authentication
  • Role-based access control
  • API route protection

๐Ÿ“ฆ Tech Stack

  • Frontend: Next.js 14, React 18, Tailwind CSS
  • Backend: Next.js API Routes, Prisma ORM
  • Database: SQLite (swappable to PostgreSQL)
  • Auth: JWT (jose), bcryptjs
  • Editor: Monaco Editor
  • State: Zustand

๐Ÿ“„ License

MIT License - Built for competitive coding events.


ยฉ 2026 Code Auction

About

This project originated as an idea for a club event round and was later developed into a working Code Auction System prototype. The objective was to simulate an auction-based environment where participants bid on coding challenges using virtual currency, encouraging strategic thinking along with technical skills.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors