LeetCohort is a free coding practice platform focused on Python Solve problems, earn points, and compete on the leaderboard. Built as part of the Axiom YSWS (HackClub) program.
Try it out at LeetCohort and Demo Video DEMO google drive link
- Solve Python coding problems across multiple difficulty levels
- Run code against sample test cases before submission
- Submit solutions and get instant feedback
- Earn points for solving problems
- Compete on the global leaderboard with other users
- Track your progress and solved problems with detailed charts
- OAuth login with Google, GitHub, and Hack Club
- Profile customization with picture upload
- Export your data or delete your account anytime
Frontend
- HTML
- Tailwind CSS via CDN
- Vanilla JavaScript
Backend
- Flask
- SQLite for problem storage
- Firebase Firestore for user data
- Firebase Authentication
- HackClub and GitHub OAuth ()
Hosting
- PythonAnywhere for free hosting
Code Execution
- Piston API for secure code execution
Problem Solving Flow
- Browse Problems - View coding challenges filtered by difficulty and topics
- Write Solution - Use the code editor to write your Python solution
- Test Code - Run against sample test cases to verify basic functionality
- Submit - Your code runs against all test cases including hidden ones
- Get Feedback - Instant results showing which test cases passed or failed
- Earn Points - Successfully passing all test cases awards points based on difficulty
Behind the Scenes
- Your code gets wrapped with a test harness and sent to Piston API for execution
- Multiple test cases run in parallel for faster results
- Output is compared with expected results using smart comparison logic
- Some problems check time complexity to ensure efficient solutions
- All execution happens in isolated sandboxed containers for security
- Points and solved problems sync to your profile automatically
Scoring System
- Easy problems: 10-20 points
- Medium problems: 30-40 points
- Hard problems: 50+ points
- Each test case within a problem can award partial points
- Leaderboard ranks users by total points earned
- Points are given based on various things such as difficulty, time complexity, hints etc.
LeetCohort/
├── app.py # Main Flask application
├── execution.py # Code execution logic
├── requirements.txt # Python dependencies
├── db/
│ ├── createDb.py # Database schema creation
│ ├── insertDb.py # Problem insertion script
│ ├── problems.json # Problem data
│ └── problems.db # SQLite database
├── static/
│ ├── assets/ # Images and logos
│ ├── css/ # Stylesheets
│ ├── js/ # JavaScript files
│ └── uploads/ # User uploaded profile pictures
└── templates/ # HTML templates
- Python 3.12 or higher (I used 3.12.10)
- pip for installing packages
- Firebase project with Firestore and Authentication enabled
- If you want to use HackClub or GitHub OAuth please refer to their respective Docs (Almost same as Google)
- Clone the repository
git clone https://github.com/Rexaintreal/LeetCohort.git
cd LeetCohort-
Create a virtual environment (Recommended)
Windows:
python -m venv venv
.\venv\Scripts\activatemacOS / Linux:
python3 -m venv venv
source venv/bin/activate- Install dependencies
pip install -r requirements.txt-
Set up environment variables
Create a
.envfile in the root directory with:
FLASK_SECRET_KEY=your_secret_key
FIREBASE_API_KEY=your_firebase_api_key
FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
FIREBASE_PROJECT_ID=your_project_id
FIREBASE_STORAGE_BUCKET=your_project.appspot.com
FIREBASE_MESSAGING_SENDER_ID=your_sender_id
FIREBASE_APP_ID=your_app_id
FIREBASE_MEASUREMENT_ID=your_measurement_id
HACKCLUB_CLIENT_ID=your_hackclub_client_id
HACKCLUB_CLIENT_SECRET=your_hackclub_secret
HACKCLUB_REDIRECT_URI=http://localhost:5000/auth/hackclub/callback
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_secret
GITHUB_REDIRECT_URI=http://localhost:5000/auth/github/callback
[email protected]
MAIL_PASSWORD=your_app_password
[email protected]
-
Add Firebase Admin SDK
Download your Firebase Admin SDK JSON file and save it as
firebase-admin-sdk.jsonin the root directory -
Initialize the database
cd db
python createDb.py
python insertDb.py
cd ..- Run the application
python app.py- Open your browser and go to
http://127.0.0.1:5000orlocalhost:500if you've specified that in the OAuth Urls
CREATE TABLE problems (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
slug TEXT UNIQUE NOT NULL,
description TEXT NOT NULL,
input_format TEXT,
output_format TEXT,
difficulty TEXT CHECK(difficulty IN ('Easy', 'Medium', 'Hard')),
topic_tags TEXT,
company_tags TEXT,
constraints TEXT,
boilerplate_code TEXT,
time_complexity TEXT,
space_complexity TEXT,
points INTEGER DEFAULT 10,
order_matters INTEGER DEFAULT 1,
check_complexity INTEGER DEFAULT 0,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);CREATE TABLE test_cases (
id INTEGER PRIMARY KEY AUTOINCREMENT,
problem_id INTEGER NOT NULL,
input TEXT,
expected_output TEXT,
input_json TEXT,
expected_output_json TEXT,
is_sample INTEGER DEFAULT 0,
explanation TEXT,
points INTEGER DEFAULT 10,
display_order INTEGER DEFAULT 0,
FOREIGN KEY (problem_id) REFERENCES problems(id) ON DELETE CASCADE
);CREATE TABLE hints (
id INTEGER PRIMARY KEY AUTOINCREMENT,
problem_id INTEGER NOT NULL,
hint TEXT NOT NULL,
display_order INTEGER DEFAULT 0,
FOREIGN KEY (problem_id) REFERENCES problems(id) ON DELETE CASCADE
);Code Execution
- Sample test cases visible before submission
- Hidden test cases for actual submission
- Time complexity validation for certain problems
- Parallel test case execution for faster results
Scoring System
- Each test case awards points when passed
- Problems have difficulty based total points
- Leaderboard ranks users by total points earned
- Track solved problems by difficulty level
User Accounts
- OAuth login via Google, GitHub, or Hack Club
- Customizable profile with name and picture (we've a cute default avatar for HackClub users)
- View solved problems and statistics
- Export all your data as JSON format
- Delete account and all associated data easily
Landing Page Background - uiverse.io/1k24bytes/hot-cow-99
Problems - GeeksforGeeks DSA Interview Questions
Avatars - Pinterest and Orpheus from Hack Club Summer of Making
- Sorta - A Sorting Algorithm Visualizer
- Ziks - A physics simulator with 21 Simulatons made using vanilla JS
- Eureka - A website to find local spots near you which don't show up on Google Maps
- DawnDuck - USB HID Automation Tool for Morning Routines
- Lynx - OpenCV Image Manipulation WebApp
- Libro Voice - PDF to Audio Converter
- Snippet Vision - YouTube Video Summarizer
- Weather App - Python Weather Forecast App
- Python Screenrecorder - Python Screen Recorder
- Typing Speed Tester - Python Typing Speed Tester
- Movie Recommender - Python Movie Recommender
- Password Generator - Python Password Generator
- Object Tales - Python Image to Story Generator
- Finance Manager - Flask WebApp to Monitor Savings
- Codegram - Social Media for Coders
- Simple Flask Notes - Flask Notes App
- Key5 - Python Keylogger
- Codegram2024 - Modern Codegram Update
- Cupid - Dating Web App for Teenagers
- Gym Vogue - Ecommerce for Gym Freaks
- Confessions - Anonymous Confession Platform
- Syna - Social Music App with Spotify
- Apollo - Minimal Music Player with Dancing Cat
- Eros - Face Symmetry Analyzer
- Notez - Clean Android Notes App
MIT LICENSE
Built by Saurabh Tiwari
- Portfolio: saurabhcodesawfully.pythonanywhere.com
- Email: [email protected]
- Twitter: @Saurabhcodes01
- Instagram: @saurabhcodesawfully
