Skip to main content

Code Compiler

Online code compiler

JavaScript

๐ŸŒŒ CodeSphere

CodeSphere React Node.js Gemini

It Doesn't Just Compile, It Comprehends.

An AI-powered multi-language online code compiler with Intent Mirror technology that understands what you meant to code, not just what you wrote.

Features โ€ข Setup โ€ข Usage โ€ข API Keys


๐ŸŽฏ What is Intent Mirror?

Unlike ordinary online compilers, CodeSphere uses Gemini AI to understand your programming intent through natural language comments. It doesn't just find bugs โ€” it finds misaligned intent.

Example:

# intent: sort numbers in ascending order
numbers = [5, 2, 8, 1, 9]
result = sorted(numbers, reverse=True)  # โš ๏ธ Bug!
print(result)

AI Output: "It seems your intent was ascending, but your code sorts descending. Did you mean reverse=False?"


โœจ Features

Core Functionality

  • ๐Ÿš€ Multi-Language Support: Python, Java, C++, JavaScript
  • ๐ŸŽจ Monaco Editor: Professional code editing with syntax highlighting
  • โšก Real-Time Execution: Powered by Judge0 API
  • ๐Ÿค– AI-Powered Suggestions: Gemini 1.5 Pro integration
  • ๐ŸŽฏ Intent Mirror: Detects logic mismatches from intent comments

AI Features

  • ๐Ÿ’ก Explain: Understand what your code does
  • ๐Ÿ”ง Fix: Get intelligent error fixes
  • โšก Optimize: Receive performance improvements
  • ๐ŸŽฏ Intent Analysis: Compare intent vs implementation

UX Features

  • ๐ŸŒ™ Dark Mode First: Beautiful neon-accented dark theme
  • ๐Ÿ’Ž Glassmorphism UI: Modern, elegant design
  • โŒจ๏ธ Keyboard Shortcuts: Ctrl+Enter, Ctrl+I, Ctrl+.
  • ๐Ÿ’พ Auto-Save: LocalStorage session persistence
  • ๐ŸŽฏ Focus Mode: Distraction-free coding
  • ๐Ÿ“Š Separated Output: Clear stdout/stderr/compile output display

๐Ÿš€ Quick Start

Prerequisites

Installation

1๏ธโƒฃ Clone and Install

# Clone the repository
cd "code compiler"

# Install backend dependencies
cd backend
npm install

# Install frontend dependencies
cd ../frontend
npm install

2๏ธโƒฃ Configure Backend

Create backend/.env:

PORT=5000
JUDGE0_URL=https://judge0-ce.p.rapidapi.com
JUDGE0_API_KEY=your_rapidapi_key_here
GEMINI_API_KEY=your_gemini_api_key_here
GEMINI_MODEL=gemini-1.5-pro-latest

3๏ธโƒฃ Start Development Servers

Terminal 1 - Backend:

cd backend
npm run dev

Terminal 2 - Frontend:

cd frontend
npm run dev

Open http://localhost:5173 ๐ŸŽ‰


๐Ÿ”‘ Getting API Keys

Gemini API Key (Free)

  1. Visit Google AI Studio
  2. Sign in with your Google account
  3. Click "Create API Key"
  4. Copy your key to backend/.env

Judge0 API Key (Free Tier Available)

  1. Go to Judge0 on RapidAPI
  2. Sign up and subscribe to the free plan (50 requests/day)
  3. Copy your RapidAPI key
  4. Add to backend/.env

Alternative: Use the free Judge0 CE endpoint (no key required):

JUDGE0_URL=https://ce.judge0.com
# Leave JUDGE0_API_KEY empty

๐Ÿ’ป Usage

Basic Workflow

  1. Select Language: Choose from Python, JavaScript, C++, or Java
  2. Write Code: Use the Monaco editor with syntax highlighting
  3. Add Input: Enter stdin data if needed
  4. Run: Click "Run" or press Ctrl+Enter

Intent Mirror Workflow

  1. Write Intent: Add a comment describing what you want:
    # intent: calculate factorial recursively
    
  2. Write Code: Implement your solution
  3. Analyze: Click "Analyze" or press Ctrl+I
  4. Review: Check AI suggestions for logic mismatches
  5. Apply Fix: Press Ctrl+. to apply suggested fixes

Keyboard Shortcuts

  • Ctrl+Enter - Run code
  • Ctrl+I - Analyze intent
  • Ctrl+. - Apply AI fix

๐Ÿ—๏ธ Project Structure

code compiler/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ index.js              # Express server
โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”‚   โ”œโ”€โ”€ compile.js        # Code execution endpoint
โ”‚   โ”‚   โ””โ”€โ”€ suggest.js        # AI suggestions endpoint
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”œโ”€โ”€ gemini.js         # Gemini API integration
โ”‚   โ”‚   โ””โ”€โ”€ judge0.js         # Judge0 API integration
โ”‚   โ””โ”€โ”€ package.json
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ App.jsx           # Main application
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Editor.jsx    # Monaco editor wrapper
โ”‚   โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ api.js        # API client
โ”‚   โ”‚   โ””โ”€โ”€ styles.css        # Tailwind + custom styles
โ”‚   โ”œโ”€โ”€ vite.config.js
โ”‚   โ”œโ”€โ”€ tailwind.config.js
โ”‚   โ””โ”€โ”€ package.json
โ””โ”€โ”€ README.md

๐ŸŽจ Design Philosophy

CodeSphere follows a dark-mode-first design approach with:

  • Base color: #0B1020 (deep space blue)
  • Accent colors: Neon cyan (#6ee7b7) and blue (#7dd3fc)
  • Glassmorphism panels with backdrop-blur effects
  • Subtle glow effects on interactive elements
  • Smooth animations and transitions

๐Ÿงช Testing

Backend Tests

cd backend
npm test

Manual Testing

  1. Test Python execution with stdin
  2. Test intent analysis with mismatched logic
  3. Test all three AI tabs (Explain, Fix, Optimize)
  4. Test keyboard shortcuts
  5. Test session persistence (refresh page)

๐Ÿš€ Deployment

Backend (Railway/Render)

  1. Connect GitHub repository
  2. Set environment variables in dashboard
  3. Deploy from main branch

Frontend (Vercel)

  1. Connect GitHub repository
  2. Build command: cd frontend && npm run build
  3. Output directory: frontend/dist
  4. Environment: VITE_API_BASE=https://your-backend.com/api
  5. Deploy

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


๐Ÿ“„ License

MIT License - Free for personal and commercial use


๐Ÿ™ Acknowledgments


Built with โค๏ธ by developers, for developers

โญ Star this repo if you find it useful!