Skip to content

pranav-dp/codeindark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

22 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Code In The Dark - Points System

A modern points system platform with points, lifelines, gambling games, and real-time admin monitoring.

๐Ÿš€ Features

For Players:

  • Authentication System - Secure login/register
  • Points System - Earn and spend points
  • Lifelines - Use helpful lifelines with points
  • Gambling Games - Slot machine & dice games
  • Leaderboard - Compete with other players
  • Transaction History - Track all your activity

For Admins:

  • Real-time Monitoring - Live activity feed
  • User Management - Manage users and points
  • Analytics Dashboard - System statistics
  • User-wise Analysis - Individual user tracking

๐Ÿ› ๏ธ Tech Stack

  • Frontend: Next.js 15, React, TypeScript, Tailwind CSS
  • Backend: Next.js API Routes, MongoDB
  • Authentication: JWT tokens with httpOnly cookies
  • Animations: Framer Motion
  • UI Components: Radix UI, Shadcn/ui

๐Ÿ“ฆ Installation

  1. Clone the repository

    git clone <your-repo-url>
    cd codedark
  2. Install dependencies

    npm install
  3. Set up environment variables

    cp .env.example .env.local

    Fill in your MongoDB connection string and JWT secret:

    MONGODB_CONNECTION_URI=mongodb+srv://...
    JWT_SECRET=your-super-secret-key
    BCRYPT_ROUNDS=12
  4. Run the development server

    npm run dev

๐Ÿš€ Deployment

Vercel (Recommended)

  1. Push to GitHub

    git add .
    git commit -m "Ready for deployment"
    git push origin main
  2. Deploy to Vercel

    • Go to vercel.com
    • Import your GitHub repository
    • Add environment variables in Vercel dashboard
    • Deploy!

Environment Variables for Production:

MONGODB_CONNECTION_URI=your-mongodb-atlas-connection
JWT_SECRET=your-production-jwt-secret
BCRYPT_ROUNDS=12
NODE_ENV=production

๐ŸŽฎ Usage

Game Rules:

  • Slot Machine: 10 points per spin, various payouts
  • Dice Game: Variable betting, multipliers based on dice result
  • Lifelines: Different costs, limited uses per user

๐Ÿ”ง Development

Project Structure:

codedark/
โ”œโ”€โ”€ app/                          # Next.js 15 App Router
โ”‚   โ”œโ”€โ”€ api/                      # API Routes
โ”‚   โ”‚   โ”œโ”€โ”€ auth/                 # Authentication endpoints
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ login/route.ts    # User login
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ register/route.ts # User registration
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ logout/route.ts   # User logout
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ me/route.ts       # Get current user
โ”‚   โ”‚   โ”œโ”€โ”€ admin/                # Admin-only endpoints
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ users/route.ts    # User management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ analytics/route.ts# System analytics
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ activity/route.ts # Real-time activity
โ”‚   โ”‚   โ”œโ”€โ”€ gambling/             # Gaming endpoints
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ slot/route.ts     # Slot machine game
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ dice/route.ts     # Dice roll game
โ”‚   โ”‚   โ”œโ”€โ”€ lifelines/            # Lifeline system
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ route.ts          # Get user lifelines
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ use/route.ts      # Use a lifeline
โ”‚   โ”‚   โ”œโ”€โ”€ user/                 # User data endpoints
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ history/route.ts  # Transaction history
โ”‚   โ”‚   โ””โ”€โ”€ leaderboard/route.ts  # User rankings
โ”‚   โ”œโ”€โ”€ admin/                    # Admin dashboard
โ”‚   โ”‚   โ””โ”€โ”€ page.tsx              # Real-time monitoring
โ”‚   โ”œโ”€โ”€ dashboard/                # User dashboard
โ”‚   โ”‚   โ””โ”€โ”€ page.tsx              # Main user interface
โ”‚   โ”œโ”€โ”€ gambling/                 # Gaming pages
โ”‚   โ”‚   โ””โ”€โ”€ page.tsx              # Slot machine & dice
โ”‚   โ”œโ”€โ”€ lifelines/                # Lifelines system
โ”‚   โ”‚   โ””โ”€โ”€ page.tsx              # Use lifelines
โ”‚   โ”œโ”€โ”€ history/                  # Transaction history
โ”‚   โ”‚   โ””โ”€โ”€ page.tsx              # User activity log
โ”‚   โ”œโ”€โ”€ leaderboard/              # Rankings
โ”‚   โ”‚   โ””โ”€โ”€ page.tsx              # User leaderboard
โ”‚   โ”œโ”€โ”€ globals.css               # Global styles
โ”‚   โ”œโ”€โ”€ layout.tsx                # Root layout
โ”‚   โ””โ”€โ”€ page.tsx                  # Landing/login page
โ”œโ”€โ”€ components/                   # Reusable components
โ”‚   โ”œโ”€โ”€ ui/                       # UI components
โ”‚   โ”‚   โ”œโ”€โ”€ button.tsx            # Button component
โ”‚   โ”‚   โ”œโ”€โ”€ input.tsx             # Input component
โ”‚   โ”‚   โ”œโ”€โ”€ select.tsx            # Select component
โ”‚   โ”‚   โ”œโ”€โ”€ loading.tsx           # Loading spinners
โ”‚   โ”‚   โ””โ”€โ”€ toast.tsx             # Toast notifications
โ”‚   โ”œโ”€โ”€ authentication-card.tsx  # Login/register form
โ”‚   โ””โ”€โ”€ error-boundary.tsx       # Error handling
โ”œโ”€โ”€ contexts/                     # React contexts
โ”‚   โ””โ”€โ”€ AuthContext.tsx          # Authentication state
โ”œโ”€โ”€ lib/                          # Utility libraries
โ”‚   โ”œโ”€โ”€ mongodb.ts               # Database connection
โ”‚   โ”œโ”€โ”€ auth.ts                  # JWT & password utils
โ”‚   โ””โ”€โ”€ utils.ts                 # Helper functions
โ”œโ”€โ”€ .env.local                   # Environment variables
โ”œโ”€โ”€ .env.example                 # Environment template
โ”œโ”€โ”€ next.config.js               # Next.js configuration
โ”œโ”€โ”€ tailwind.config.js           # Tailwind CSS config
โ”œโ”€โ”€ package.json                 # Dependencies
โ””โ”€โ”€ README.md                    # This file

Key Components:

Authentication System (contexts/AuthContext.tsx)

  • JWT token management
  • User session persistence
  • Login/logout functionality
  • Admin role detection

Database Layer (lib/mongodb.ts)

  • MongoDB connection pooling
  • Database operations
  • Error handling

API Architecture (app/api/)

  • RESTful endpoints
  • JWT authentication middleware
  • Admin authorization checks
  • Input validation & sanitization

Gaming Engine (app/gambling/)

  • Slot machine with configurable payouts
  • Dice game with multiplier system
  • Real-time point updates
  • Animation system with Framer Motion

Admin Dashboard (app/admin/)

  • Real-time activity monitoring
  • User management interface
  • System analytics
  • Live data updates (3-second intervals)

UI Components (components/ui/)

  • Consistent design system
  • Accessible components
  • Loading states
  • Error boundaries
  • Toast notifications

๐Ÿ“Š Database Schema

Users Collection:

{
  _id: String,
  username: String,
  email: String,
  password: String (hashed),
  points: Number,
  isActive: Boolean,
  isAdmin: Boolean,
  lifelines: Array,
  history: Object,
  createdAt: Date,
  updatedAt: Date
}

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

๐Ÿ“„ License

This project is licensed proprietary software for Code In The Dark Event for Invente.

Built by Pranav ๐Ÿฅท

About

A real-time points management platform for competitive coding events, featuring gambling mini-games, lifelines, and a live admin monitoring dashboard.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors