Skip to content

raftywate/BitSmith

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

81 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Compylr

A full-stack competitive programming platform β€” write, run, and judge code in 5 languages, directly in your browser.

πŸ”— Live: bit-smith-kappa.vercel.app Β |Β  API: compylr-backend.onrender.com


Screenshots

Problems List Problem Workspace
Problems List Workspace
User Profile Login
User Profile Login

Features

  • πŸ§‘β€πŸ’» Multi-language judge β€” Submit solutions in Python, C++23, Java, C, and C#
  • 🐳 Docker sandbox β€” Every submission runs in an isolated container (no network, 512 MB RAM, 1.5 vCPU, 128 PID limit, 5-second TLE)
  • ⚑ Warm containers β€” Persistent sandbox containers eliminate cold-start overhead on repeated submissions
  • πŸ“ Monaco Editor β€” VS Code's editor engine, with per-language syntax highlighting and a resizable Golden Layout workspace
  • πŸ” JWT Auth β€” Register, verify email with OTP, and log in; invite-code-gated Admin role
  • πŸ“Š User profiles β€” Solved count by difficulty, daily activity calendar, current streak
  • 🧩 225+ problems β€” Auto-seeded from a curated dataset of LeetCode-style problems for learning and practice
  • πŸ’¬ Solutions & comments β€” Write editorial solutions, comment, and vote
  • πŸ“… Problem of the Day β€” Admin-configurable daily featured problem
  • πŸ”’ Rate limiting β€” 5 req/min on auth/submit, 100 req/hr on content posting

Tech Stack

Layer Technology
Frontend Angular 20, Monaco Editor, Golden Layout, KaTeX, TailwindCSS
Backend ASP.NET Core 8, Entity Framework Core, Npgsql
Database PostgreSQL (Supabase)
Judge Engine Docker (Python 3.10, GCC 13 / C++23, Eclipse Temurin 21, .NET SDK 8)
Auth JWT (HMAC-SHA256), BCrypt, SMTP OTP
Deployment Vercel (frontend), Render (backend), Supabase (database)

Project Structure

BitSmithApp/
β”œβ”€β”€ angularBitSmith/        # Angular 20 SPA
β”‚   β”œβ”€β”€ src/app/
β”‚   β”‚   β”œβ”€β”€ auth/           # Login, Register, OTP verification
β”‚   β”‚   β”œβ”€β”€ problems/       # Problem list, detail, solution editor
β”‚   β”‚   β”œβ”€β”€ profile/        # User profile & stats
β”‚   β”‚   β”œβ”€β”€ admin/          # Admin dashboard, problem creator, POTD
β”‚   β”‚   β”œβ”€β”€ workspace/      # Monaco + Golden Layout dockable IDE
β”‚   β”‚   └── services/       # HTTP services, auth guards
β”‚   └── vercel.json
β”œβ”€β”€ dotnetBitSmith/         # ASP.NET Core 8 REST API
β”‚   β”œβ”€β”€ Controllers/        # 8 controllers (Auth, Problem, Submission, User, ...)
β”‚   β”œβ”€β”€ Services/           # 12 services including DockerCompilationService
β”‚   β”œβ”€β”€ Entities/           # 11 EF Core entities
β”‚   β”œβ”€β”€ Data/               # ApplicationDbContext, indexes
β”‚   β”œβ”€β”€ Middlewares/        # Global exception handling
β”‚   β”œβ”€β”€ Helpers/            # ProblemSeeder
β”‚   └── problems.json       # 2,828-problem dataset
β”œβ”€β”€ docker-compose.yml      # Full local stack
└── vercel.json

Architecture

Browser (Angular SPA)
        β”‚
        β–Ό HTTP / REST
ASP.NET Core 8 API
   β”œβ”€β”€ Auth (JWT + OTP)
   β”œβ”€β”€ Rate Limiter (ASP.NET Core built-in)
   β”œβ”€β”€ Problem / Solution / Comment / Vote endpoints
   β”œβ”€β”€ Submission endpoint ──► Channel<Guid> Queue (cap: 1,000)
   β”‚                                   β”‚
   β”‚                    BackgroundService Worker
   β”‚                                   β”‚
   β”‚                     DockerCompilationService
   β”‚                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚                     β”‚  docker exec (warm)  OR  β”‚
   β”‚                     β”‚  docker run  (cold)       β”‚
   β”‚                     β”‚  --network none           β”‚
   β”‚                     β”‚  --memory 512m            β”‚
   β”‚                     β”‚  --cpus 1.5               β”‚
   β”‚                     β”‚  --pids-limit 128         β”‚
   β”‚                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
   └── IMemoryCache (1-hr TTL on problem details)
        β”‚
        β–Ό
   PostgreSQL (Supabase)

Local Development

Prerequisites


1. Clone the repo

git clone https://github.com/raftywate/BitSmith.git
cd BitSmith

2. Backend setup

Create dotnetBitSmith/appsettings.Development.json (this file is git-ignored):

{
  "ConnectionStrings": {
    "connectionString": "Host=localhost;Database=BitSmithDb;Username=postgres;Password=YOUR_PG_PASSWORD"
  },
  "JwtSettings": {
    "Key": "YOUR_JWT_SECRET_MIN_32_CHARS_LONG"
  },
  "AdminSettings": {
    "InviteCode": "YOUR_ADMIN_INVITE_CODE"
  },
  "SmtpSettings": {
    "Host": "smtp.gmail.com",
    "Port": "587",
    "Username": "your@gmail.com",
    "Password": "your-gmail-app-password",
    "FromEmail": "your@gmail.com"
  }
}

Note: For Gmail, generate an App Password (requires 2FA). If SMTP is not configured, the app auto-verifies accounts as a fallback.

Start the backend:

cd dotnetBitSmith
dotnet run

The API starts on http://localhost:5000. On first run it:

  1. Auto-creates all database tables
  2. Seeds 225 problems (75 Easy / 100 Medium / 50 Hard) from problems.json if the DB is empty
  3. Creates composite indexes for query performance

3. Start sandbox containers (required for code execution)

The judge engine uses Docker containers as sandboxes. Start the warm containers:

docker compose up sandbox-python sandbox-gcc sandbox-java sandbox-csharp -d

Without these, submissions will fall back to cold docker run (slower, but still functional as long as Docker is running).


4. Frontend setup

cd angularBitSmith
npm install
npm start

The Angular dev server starts on http://localhost:4200.

The dev environment points to http://localhost:5000/api. To change this, edit src/environments/environment.ts.


5. Full stack with Docker Compose (alternative)

To run the entire stack (database + backend + frontend + sandboxes) in Docker:

docker compose up --build

Access the app at http://localhost:80.


Environment Variables (Production / Render)

Set these in your Render backend service environment:

Variable Description
ConnectionStrings__connectionString PostgreSQL connection string (use Supabase pooler URL)
JwtSettings__Key JWT signing secret (min 32 chars)
AdminSettings__InviteCode Secret code that grants Admin role on registration
SmtpSettings__Host SMTP host (e.g. smtp.gmail.com)
SmtpSettings__Port SMTP port (e.g. 587)
SmtpSettings__Username SMTP username / email
SmtpSettings__Password SMTP password / app password
SmtpSettings__FromEmail From address for outgoing emails
HOST_TEMP_RUNS_PATH Host path for temp run directories (Docker volume mount)

Seeding Problems

The app auto-seeds on startup if the database is empty. To manually trigger a full re-seed:

cd dotnetBitSmith
dotnet run -- --import-leetcode

This runs the full ProblemSeeder against problems.json with verbose logging.


Admin Access

On the Register page, enter the configured InviteCode in the invite code field to create an Admin account. Admins get access to:

  • /admin β€” Dashboard with stats
  • /admin/problem β€” Create / edit problems with test cases
  • /admin/pod β€” Set the Problem of the Day

API Overview

Method Endpoint Description
POST /api/auth/register Register a new user
POST /api/auth/login Login and receive JWT
POST /api/auth/verify-otp Verify email OTP
GET /api/problems Paginated problem list with filters
GET /api/problems/{slug} Problem detail with test cases
POST /api/submissions Submit a solution for judging
GET /api/submissions/{id} Poll submission result
POST /api/submissions/run Run against sample test cases
POST /api/submissions/run-code Run arbitrary code with custom stdin
GET /api/users/{username} Public user profile & stats
GET /api/solutions/{problemId} Community solutions for a problem

Full Swagger docs available at /swagger when running locally.


Deployment

Frontend β†’ Vercel

  1. Connect your GitHub repo to Vercel
  2. Set Root Directory to the repo root
  3. Vercel uses vercel.json at the root to build and route the SPA

Backend β†’ Render

  1. Create a new Web Service on Render
  2. Set Root Directory to dotnetBitSmith
  3. Use the existing Dockerfile
  4. Set all environment variables listed above
  5. Mount Docker socket if using warm containers (requires a Docker-capable host)

Disclaimer

The problems included in this project are sourced from LeetCode and are used purely for educational and learning purposes. This is a non-commercial, personal project built to practice full-stack development. All problem content, titles, and descriptions remain the intellectual property of LeetCode. If you are the rights holder and have concerns, please open an issue.


License

MIT


Built by @raftywate

About

Full-stack online judge platform with secure Docker-based code execution, automated testing, and scalable backend architecture.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors