An educational tool that combines algorithmic static analysis with Large Language Model intelligence to automatically grade student C++ code against customizable style guidelines.
The Code Style Grader is a web-based application designed to help educators efficiently grade student C++ assignments by automatically detecting style violations. The system uses a two-tier analysis architecture:
-
Tier 1: Built-in Algorithmic Checks (Fast, Deterministic)
- Indentation validation (mixed tabs/spaces, incorrect nesting)
- Line length enforcement
- Missing braces on control structures
- Memory leak detection (new/delete matching)
- Naming conventions (camelCase, PascalCase)
- NULL vs nullptr usage
-
Tier 2: LLM Semantic Analysis (Intelligent, Context-Aware)
- Comment quality assessment
- Complex semantic issues
- Code structure analysis
- Speed: Algorithmic checks are instant (~0.5 seconds)
- Accuracy: Rule-based checks have 100% precision
- Intelligence: LLM adds contextual understanding for nuanced issues
- Privacy: All analysis runs locally - no cloud APIs, no data transmission
- Cost: Zero API fees - uses local Ollama + CodeLlama 7B
β Analysis Capabilities:
- Many violation types detected automatically
- Color-coded severity levels (π΄ CRITICAL, π WARNING, π΅ MINOR)
- Customizable style guidelines via plain-text files
β User Interface:
- Monaco Editor (same as VS Code) with syntax highlighting
- Violation highlighting with hover tooltips
- File tree for navigating submissions
- Detailed violation panel with line references
Verify you have the required software:
# Check Python version (3.11+ required)
python --version
# Check Node.js version (16+ required)
node --version
# Check npm version (8+ required)
npm --versionIf any are missing or outdated, install them first:
- Python 3.11+: https://www.python.org/downloads/
- Node.js 16+: https://nodejs.org/
Ollama provides the local LLM infrastructure for semantic analysis.
- Download Ollama from https://ollama.com/download
- Run the installer (OllamaSetup.exe)
- Open Command Prompt or PowerShell
- Pull the CodeLlama model:
ollama pull codellama:7b
- Verify installation:
You should see
ollama list
codellama:7bin the list (~3.8GB download)
cd C:\Users\YourUsername\Desktop # or your preferred directory
git clone <repository-url>
cd CSCI598-Semester-Project# Navigate to backend directory
cd backend
# Create virtual environment
python -m venv venv
# Activate virtual environment
venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt# Navigate to frontend directory
cd frontend
# Install dependencies
npm installYou'll need THREE terminal windows to run all services:
ollama serveLeave this running. You should see:
Ollama is running on http://localhost:11434
# Navigate to backend
cd backend
# Activate virtual environment
venv\Scripts\activate
# Start backend
uvicorn app.main:app --reload --host 127.0.0.1 --port 8000Leave this running. You should see:
INFO: Uvicorn running on http://127.0.0.1:8000
# Navigate to frontend
cd frontend
# Start React development server
npm startYour browser should automatically open to http://localhost:3000
Once all three services are running, follow these steps:
- Click the Style Guide dropdown in the top control bar
- Select "π Upload New Style Guide..."
- Navigate to
$(project_directory)/semantic_style_guide.txt - Upload the file
- The dropdown should now show "semantic_style_guide.txt" as selected
- Click "π Upload Files" in the left sidebar
- Important: You must select a folder, not individual files
- Navigate to and select the
test_files/folder - All
.cppfiles will appear in the file tree on the left
- Click on any file in the tree (e.g.,
test_algorithmic.cpp) - The file content will appear in the Monaco editor (center panel)
- Click the "Run Analysis" button in the top control bar
- Wait 1-2 seconds for analysis to complete
- View Results:
- Violations appear in the right panel with severity levels
- Code highlights appear in the editor:
- π΄ Red background = CRITICAL
- π Amber background = WARNING
- π΅ Blue background = MINOR
- Hover over highlighted lines to see violation details
- Click on violations in the right panel to jump to that line
The test_files/ directory contains examples demonstrating a breadth of capabilities:
| File | Demonstrates |
|---|---|
test_algorithmic.cpp |
Mixed tabs/spaces, missing braces |
test_semantic.cpp |
Memory leaks, naming conventions, NULL vs nullptr |
test_comment_quality.cpp |
Improper indentation detection |
test_clean.cpp |
Clean code example (gold standard) |
test_no_comments.cpp |
Missing comments violation |
Recommended Test Sequence:
- Start with
test_algorithmic.cpp(basic formatting checks) - Try
test_semantic.cpp(LLM-detected memory leaks) - Test
test_clean.cpp(clean code example) - Experiment with
test_no_comments.cpp(CRITICAL severity)
If the browser doesn't open automatically:
- Manually navigate to http://localhost:3000
If you see connection errors:
- Verify all three terminals are still running
- Check Ollama: http://localhost:11434 (should show "Ollama is running")
- Check Backend: http://127.0.0.1:8000/docs (should show API documentation)
- Check Frontend: http://localhost:3000 (should show the application)
If analysis is slow (>10 seconds):
- This is normal due to Ollama response time
For detailed documentation:
- See
GRADING_GUIDE.mdfor a 10-minute walkthrough with expected outputs - See
PROJECT_SUMMARY.mdfor comprehensive technical details - See
test_files/TEST_DOCUMENTATION.mdfor detailed test file explanations
CSCI598-Semester-Project/
βββ backend/ # FastAPI Python backend
β βββ app/
β β βββ main.py # API endpoints
β β βββ models.py # Data models
β β βββ parsers/ # Algorithmic analyzers
β β βββ llm/ # LLM integration
β βββ requirements.txt # Python dependencies
βββ frontend/ # React TypeScript frontend
β βββ src/
β β βββ App.tsx # Main application
β β βββ components/ # UI components
β β βββ services/ # API client
β βββ package.json # Node dependencies
βββ style_guides/ # Style guide files
β βββ semantic_style_guide.txt
βββ test_files/ # Test C++ files
βββ test_algorithmic.cpp
βββ test_semantic.cpp
βββ test_comment_quality.cpp
βββ test_clean.cpp
βββ test_no_comments.cpp
Built with: FastAPI, React, TypeScript, Monaco Editor, Ollama, CodeLlama 7B
License: Educational use - CSCI 598 Semester Project