Skip to content
vudigapranavPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

49 Commits

Folders and files

Repository files navigation

CBIT College Programming Laboratory Management Platform

An enterprise-grade, full-stack College Programming Laboratory Management & Code Execution Platform designed specifically for Chaitanya Bharathi Institute of Technology (CBIT).

Built with Next.js (App Router, TypeScript), Tailwind CSS, Prisma ORM, Monaco Editor, and a Native Multi-Language Compiler Engine (C, C++, Java, JavaScript).


OctoCounts

πŸ“‹ Table of Contents

  1. Project Overview
  2. Folder Structure
  3. Software Prerequisites
  4. Installation Guide
  5. Environment Variables
  6. Database Setup & Seeding
  7. Running the Application
  8. Online Compiler Engine Setup
  9. Troubleshooting & Common Fixes
  10. Production Deployment Guide

1. Project Overview

The CBIT Laboratory Management Platform provides a role-based environment for managing computer science laboratory courses, student roll number allocations, assessment submissions, and automated code execution.

Key Roles & Functionality

πŸ›‘οΈ System Administrator (admin@cbit.in / admin@123)

  • Faculty Management: Create lecturer accounts (username@cbit.in), edit details, set student capacity limits, delete faculty, and reset passwords.
  • Roll Number Allocation: Define authorized student Roll Number ranges (e.g., 160125000001 to 160125000120) and assign them to specific lecturers.
  • Registered Students Inspection: View all registered students across departments, automatically sorted by Roll Number in ascending order.
  • System Metrics & Evaluation Reports: View total submissions, grading completion rates, and performance statistics across faculty members.

🏫 Faculty Lecturer (username@cbit.in)

  • Year & Section Management: Create, rename, edit, and delete sections for 1st, 2nd, 3rd, and 4th-year students (e.g., CSE-1, CSE-2, CIC-1).
  • Student View: View enrolled section students, always sorted by Roll Number ascending.
  • Lab Assessment Authoring: Create lab tasks, write problem statements, set due dates, and specify input/output constraints.
  • Submission Viewer & Code Runner: Inspect multi-file student code submissions, execute student code live, and download source files.
  • Evaluation & Grading: Award marks (0–100), write feedback remarks, set evaluation status (APPROVED, REJECTED, NEEDS_CORRECTION), reopen workspaces for student corrections, and toggle instant grade publishing.

πŸŽ“ Student (Roll Number + Password)

  • Controlled Self-Registration: Registration requires a valid 12-digit 1601XXXXXXXX Roll Number within an Admin-authorized range. Prevents duplicate registrations and filters out full faculty members.
  • Monaco Online IDE: Tabbed multi-file editor with syntax highlighting for C (.c), C++ (.cpp), Java (.java), and JavaScript (.js).
  • Anti-Cheat Protection: Suppresses copy, paste, cut, context menu (right click), keyboard shortcuts (Ctrl+C, Ctrl+V, Ctrl+X, Shift+Insert), and drag-and-drop text transfers.
  • Single Submission Locking: Workspaces lock read-only upon submission unless reopened by the lecturer.
  • Real-Time Grade View: Access published marks, evaluation status, and faculty remarks immediately.

2. Folder Structure

LabSubmit/
β”œβ”€β”€ Dockerfile                      # Production Docker container definition
β”œβ”€β”€ docker-compose.yml              # Production Docker Compose stack
β”œβ”€β”€ package.json                    # Project dependencies & scripts
β”œβ”€β”€ tsconfig.json                   # TypeScript compiler configuration
β”œβ”€β”€ tailwind.config.js              # Custom theme tokens (Olive Green & Blue)
β”œβ”€β”€ postcss.config.js               # PostCSS configuration
β”œβ”€β”€ next.config.mjs                 # Next.js build setup
β”œβ”€β”€ .env                            # Environment variables (Database & JWT)
β”œβ”€β”€ README.md                       # Complete production documentation
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ schema.prisma               # Relational database schema
β”‚   └── seed.ts                     # Database initialization script
β”œβ”€β”€ public/
β”‚   └── cbit-logo.png               # Official CBIT logo asset
└── src/
    β”œβ”€β”€ app/
    β”‚   β”œβ”€β”€ layout.tsx              # Root HTML layout & AppProvider wrapper
    β”‚   β”œβ”€β”€ page.tsx                # Institutional landing page
    β”‚   β”œβ”€β”€ globals.css             # Global styles & theme CSS variables
    β”‚   β”œβ”€β”€ login/
    β”‚   β”‚   └── page.tsx            # Unified login portal (Student/Lecturer/Admin)
    β”‚   β”œβ”€β”€ register/
    β”‚   β”‚   └── page.tsx            # Student self-registration page
    β”‚   β”œβ”€β”€ admin/
    β”‚   β”‚   └── page.tsx            # Administrator control panel
    β”‚   β”œβ”€β”€ lecturer/
    β”‚   β”‚   └── page.tsx            # Faculty lecturer workspace & grading drawer
    β”‚   β”œβ”€β”€ student/
    β”‚   β”‚   β”œβ”€β”€ page.tsx            # Student dashboard & lab status
    β”‚   β”‚   └── lab/[id]/
    β”‚   β”‚       └── page.tsx        # Online IDE lab assessment page
    β”‚   └── api/
    β”‚       β”œβ”€β”€ admin/              # Admin APIs (lecturers, ranges, stats, students)
    β”‚       β”œβ”€β”€ auth/               # Auth APIs (login, register, me, available lecturers)
    β”‚       β”œβ”€β”€ compile/run/        # Real multi-language execution API
    β”‚       β”œβ”€β”€ lecturer/           # Lecturer APIs (sections, labs, submissions, evaluate)
    β”‚       β”œβ”€β”€ profile/            # Profile & theme persistence APIs
    β”‚       └── student/            # Student APIs (labs, workspace, grades)
    β”œβ”€β”€ components/
    β”‚   β”œβ”€β”€ Navbar.tsx              # CBIT Header with theme toggle & user badge
    β”‚   β”œβ”€β”€ OnlineIDE.tsx           # Monaco Code Editor & Terminal output panel
    β”‚   β”œβ”€β”€ AntiCheatWrapper.tsx    # Anti-cheat event interceptor
    β”‚   └── ProfileModal.tsx        # Account settings & password change modal
    β”œβ”€β”€ context/
    β”‚   └── AppContext.tsx          # Global authentication & theme state manager
    └── lib/
        β”œβ”€β”€ db.ts                   # Prisma Client singleton
        β”œβ”€β”€ jwt.ts                  # JWT token signing & verification
        β”œβ”€β”€ auth.ts                 # Role-based API route guard middleware
        └── compiler.ts             # Native C/C++/Java/JS code execution engine

3. Software Prerequisites

Before installing and running the application, ensure the following software tools are installed on your machine:

Software Required Version Purpose Command to Check
Node.js v18.0.0+ or v20.0.0+ JavaScript runtime environment node -v
npm v9.0.0+ or v10.0.0+ Node package manager npm -v
GCC Any recent version C compiler (gcc) gcc --version
G++ Any recent version C++ compiler (g++) g++ --version
Java JDK OpenJDK 11+ or 17+ Java compiler (javac) & runtime (java) javac -version
PostgreSQL (Optional) v14+ or v15+ Relational database (SQLite used by default for zero setup) psql --version
Docker (Optional) v20+ Containerized production deployment docker --version

4. Installation Guide

Follow these commands step-by-step to set up the codebase on your machine.

Step 1: Open Terminal & Navigate to Project Directory

cd /path/to/LabSubmit

Step 2: Install Project Dependencies

Run the package installation command:

npm install

5. Environment Variables

Create a file named .env in the root directory of the project (same directory as package.json).

DATABASE_URL="postgresql://username:password@localhost:5432/labsubmit_dev?schema=public"
JWT_SECRET="<paste the output of: openssl rand -base64 48>"
NODE_ENV="development"
PORT=3000

Explanation of Environment Variables

  • DATABASE_URL: PostgreSQL connection string for Prisma. Required β€” the project is PostgreSQL-only (SQLite is not supported).
  • JWT_SECRET: Secret used to sign and verify login tokens. Required. Generate a random value (openssl rand -base64 48); never reuse an example value. The server refuses to start if it is missing or set to the old published default, and warns if it is shorter than 32 characters. Must be identical on the Vercel and Railway hosts.
  • NODE_ENV: Application environment state (development or production).
  • PORT: Network port on which the Next.js server listens (default: 3000).

6. Database Setup & Seeding

The platform uses Prisma ORM. Follow these steps to synchronize the database schema and initialize the System Administrator account.

Step 1: Push Database Schema

Synchronize the Prisma DSL schema with the database file:

npx prisma db push

Step 2: Generate Prisma Client

Build the type-safe Prisma client:

npx prisma generate

Step 3: Seed Database (Fresh Installation)

Initialize the system with the single System Administrator account:

npm run db:seed

Important

Initial System Administrator Credentials:

  • Email: admin@cbit.in
  • Password: admin@123

The database is initialized cleanly without dummy lecturers or students. Log in as Admin to create lecturers, roll number ranges, and sections.


7. Running the Application

Running in Development Mode

To start the local development server with hot-reloading:

npm run dev
  1. Open your browser and navigate to: http://localhost:3000
  2. Terminal output will confirm: β–² Next.js 14.2.10 - Local: http://localhost:3000

Running in Production Mode

To test the optimized production build locally:

# Build the production bundle
npm run build

# Start the production server
npm start

8. Online Compiler Engine Setup

The platform features a native multi-language code execution engine. It compiles and runs student code directly using compilers installed on your operating system.

Language Compiler Mapping

  • .c extension $\rightarrow$ gcc -O2 source.c -o a.out -lm
  • .cpp / .cc extension $\rightarrow$ g++ -O2 source.cpp -o a.out -std=c++17
  • .java extension $\rightarrow$ javac Main.java followed by java -cp . Main
  • .js extension $\rightarrow$ node main.js

Operating System Compiler Setup Guide

On Ubuntu / Debian Linux:

sudo apt update
sudo apt install -y build-essential openjdk-17-jdk nodejs

On macOS:

# Install Xcode Command Line Tools for gcc and g++
xcode-select --install

# Install Java JDK via Homebrew if needed
brew install openjdk

On Windows:

  1. Install MinGW-w64 (or GCC via MSYS2) and add its bin directory to your System PATH environment variable.
  2. Install OpenJDK (version 17+) and add javac / java to System PATH.
  3. Install Node.js (v20+).

Execution Timeout & Process Isolation

  • Executed programs run in isolated temporary workspace directories (/tmp/labsubmit_exec_...).
  • Processes are capped at a 5-second execution timeout (SIGKILL) to kill infinite loops.
  • Temporary files are automatically purged after execution.

9. Troubleshooting & Common Fixes

Issue 1: Port 3000 is already in use

Cause: Another process or previous dev server is using port 3000.
Solution:

  • On Linux/macOS: Run lsof -i :3000 and kill the PID with kill -9 <PID>.
  • Or specify a different port in .env: PORT=3001 or run PORT=3001 npm run dev.

Issue 2: PrismaClientKnownRequestError or SQLite Database Lock

Cause: Database file is corrupted or opened by another process.
Solution: Reset and re-seed the database:

npx prisma db push --force-reset
npm run db:seed

Issue 3: gcc / g++ / javac is not recognized as an internal or external command

Cause: C, C++, or Java compilers are not installed or not in your system's PATH.
Solution: Install GCC, G++, and Java OpenJDK as outlined in Section 8 and ensure their binary directories are listed in system PATH.

Issue 4: Module not found or Missing Node Packages

Cause: Dependencies were not fully installed.
Solution: Clean node_modules and re-install:

rm -rf node_modules package-lock.json
npm install

Issue 5: [STARTUP ERROR] JWT_SECRET ... or Authentication Failure

Cause: .env is missing, not in the project root, has no JWT_SECRET, or uses the old published example secret.
Solution: Ensure .env exists next to package.json with JWT_SECRET set to a fresh random value (openssl rand -base64 48). Changing the secret logs every user out once; it does not change any password.


10. Production Deployment Guide

Deployment via Docker Compose (Recommended for Production)

The repository includes a production Dockerfile and docker-compose.yml.

# 1. Build and start the container in detached mode
docker-compose up -d --build

# 2. Push database schema inside the container
docker-compose exec app npx prisma db push

# 3. Seed initial Admin account inside the container
docker-compose exec app npm run db:seed

# 4. Check container status
docker-compose ps

The application will be accessible at http://your-server-ip:3000.


πŸŽ“ License & Ownership

Developed for Chaitanya Bharathi Institute of Technology (CBIT). All rights reserved.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages