Skip to content

H-sharma63/Code-Shield

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

47 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ Code Shield β€” AI-Based Code Reviewer

An intelligent, full-stack web platform for AI-powered code analysis, debugging, and real-time execution β€” built for developers who want instant, actionable feedback on their code.


πŸ“Œ Overview

Code Shield is a full-stack web application that lets developers write, upload, analyze, and execute code directly in the browser. It integrates large language models (via OpenRouter/OpenAI) for code review and debugging, and uses Judge0 for real-time multi-language code execution β€” all inside a Monaco-powered editor.

The platform also includes a separate Admin Dashboard for monitoring live users, tracking activity, and viewing error reports via Sentry.


✨ Features

πŸ‘¨β€πŸ’» Developer Features

  • Monaco Editor β€” Professional VS Code-like code editing experience
  • AI Code Review β€” Get explanations, suggestions, and best practices from an LLM
  • AI Debugging β€” Paste broken code and get targeted fix suggestions
  • Code Execution β€” Run code in 10+ languages with stdin support via Judge0
  • Project Management β€” Upload, save, rename, and reload code projects
  • Language Detection β€” Automatically detects code language on upload
  • In-Editor Search β€” Search within the active file
  • Google & GitHub Login β€” Secure OAuth authentication via NextAuth.js

πŸ” Admin Features

  • Admin Dashboard β€” Protected route with admin-only Google OAuth
  • User Monitoring β€” View registered users pulled from Google Sheets
  • Live User Count β€” Real-time online user tracking via Pusher
  • Error Monitoring β€” Integrated Sentry dashboard link for production errors

πŸ› οΈ Tech Stack

Layer Technology
Framework Next.js 15 (App Router)
Language TypeScript
Styling Tailwind CSS + MUI
Editor Monaco Editor (@monaco-editor/react)
Authentication NextAuth.js v4 (Google, GitHub OAuth)
Database PostgreSQL via Neon (serverless)
ORM Drizzle ORM
File Storage Vercel Blob
AI / LLM OpenRouter SDK + OpenAI SDK
Code Execution Judge0 API
Real-time Pusher (presence channels)
Error Tracking Sentry
Deployment Vercel

πŸ—‚οΈ Project Structure

β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ analyze-code/       # AI code analysis endpoint
β”‚   β”‚   β”œβ”€β”€ run-code/           # Judge0 execution endpoint
β”‚   β”‚   β”œβ”€β”€ save-project/       # Save project to DB + Blob
β”‚   β”‚   β”œβ”€β”€ get-projects/       # Fetch all projects
β”‚   β”‚   β”œβ”€β”€ get-project-details/# Fetch single project + blob content
β”‚   β”‚   β”œβ”€β”€ get-users/          # Admin: fetch users from Google Sheets
β”‚   β”‚   β”œβ”€β”€ pusher/presence/    # Pusher auth for presence channel
β”‚   β”‚   └── auth/[...nextauth]/ # NextAuth.js handler
β”‚   β”œβ”€β”€ admin/
β”‚   β”‚   β”œβ”€β”€ login/              # Admin login page
β”‚   β”‚   β”œβ”€β”€ dashboard/          # Admin overview
β”‚   β”‚   └── user-monitoring/    # Live user list + count
β”‚   β”œβ”€β”€ editor/                 # Main editor page
β”‚   └── components/
β”‚       β”œβ”€β”€ editor/
β”‚       β”‚   β”œβ”€β”€ Analysis.tsx    # AI review panel
β”‚       β”‚   β”œβ”€β”€ Debug.tsx       # AI debug panel
β”‚       β”‚   β”œβ”€β”€ FileExplorer.tsx# Project file tree
β”‚       β”‚   β”œβ”€β”€ Output.tsx      # Execution output
β”‚       β”‚   β”œβ”€β”€ Terminal.tsx    # Terminal with stdin
β”‚       β”‚   └── Search.tsx      # In-file search
β”‚       β”œβ”€β”€ LoginCard.tsx
β”‚       β”œβ”€β”€ Navbar.tsx
β”‚       β”œβ”€β”€ ProjectContext.tsx
β”‚       └── PusherProvider.tsx
β”œβ”€β”€ types/                      # Shared TypeScript types
β”œβ”€β”€ public/                     # Static assets
β”œβ”€β”€ drizzle.config.ts
└── package.json

πŸ—„οΈ Database Schema

The database uses PostgreSQL on Neon, managed via Drizzle ORM.

// app/lib/schema.ts
export const projects = pgTable('projects', {
  id: serial('id').primaryKey(),
  projectName: varchar('project_name', { length: 256 }),
  fileName: varchar('file_name', { length: 256 }).notNull(),
  blobUrl: varchar('blob_url', { length: 256 }).notNull(),
});
  • id β€” Auto-incrementing primary key
  • projectName β€” User-defined project name
  • fileName β€” Original filename of the uploaded code
  • blobUrl β€” URL pointing to the file content stored in Vercel Blob

βš™οΈ Getting Started

Prerequisites

  • Node.js 18+
  • A Neon PostgreSQL database
  • Vercel account (for Blob storage)
  • Judge0 API key (RapidAPI)
  • OpenRouter or OpenAI API key
  • Google & GitHub OAuth apps
  • Pusher account
  • Sentry project

Installation

# Clone the repository
git clone https://github.com/H-sharma63/Minor-Project.git
cd Minor-Project

# Install dependencies
npm install

Environment Variables

Create a .env.local file in the root:

# Database
DATABASE_URL=your_neon_postgres_url

# NextAuth
NEXTAUTH_SECRET=your_secret
NEXTAUTH_URL=http://localhost:3000

# Google OAuth (User)
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret

# Google OAuth (Admin)
ADMIN_GOOGLE_CLIENT_ID=your_admin_google_client_id
ADMIN_GOOGLE_CLIENT_SECRET=your_admin_google_client_secret

# GitHub OAuth
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret

# AI
OPENROUTER_API_KEY=your_openrouter_key

# Code Execution
JUDGE0_API_KEY=your_judge0_rapidapi_key

# Vercel Blob
BLOB_READ_WRITE_TOKEN=your_blob_token

# Pusher
PUSHER_APP_ID=your_pusher_app_id
PUSHER_KEY=your_pusher_key
PUSHER_SECRET=your_pusher_secret
PUSHER_CLUSTER=your_pusher_cluster

# Sentry
SENTRY_DSN=your_sentry_dsn

Run Locally

npm run dev

Open http://localhost:3000 in your browser.

Database Migrations

# Push schema to Neon DB
npx drizzle-kit push

πŸ”„ How It Works

User writes/uploads code
        ↓
  Monaco Editor (frontend)
        ↓
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚   User triggers action:     β”‚
  β”‚  β€’ Analyze β†’ /api/analyze-code β†’ OpenRouter β†’ Analysis Panel  β”‚
  β”‚  β€’ Debug   β†’ /api/analyze-code β†’ OpenRouter β†’ Debug Panel     β”‚
  β”‚  β€’ Run     β†’ /api/run-code     β†’ Judge0     β†’ Terminal Output β”‚
  β”‚  β€’ Save    β†’ /api/save-project β†’ Neon DB + Vercel Blob        β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ” Authentication Flow

  • Users log in via Google or GitHub OAuth through NextAuth.js
  • Admins use a separate Google OAuth provider with restricted access
  • Sessions are JWT-based and validated on protected routes

πŸ“Š System Architecture

Browser (Next.js Client)
        ↕
Vercel (Next.js Server / API Routes)
        ↕
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Neon DB β”‚  Vercel   β”‚OpenRouterβ”‚  Judge0  β”‚  Pusher  β”‚
β”‚(Postgres)β”‚   Blob    β”‚  (LLM)   β”‚ (Run Code)β”‚(Realtime)β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🀝 Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you'd like to change.


πŸ“„ License

This project is for academic and portfolio purposes.


πŸ‘€ Author

Harshit Sharma GitHub

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors