Skip to content

mohdshebinnnc/Nexify

Repository files navigation

Nexify - AI Coding Tutor

An AI-powered coding tutor that helps developers and students understand, debug, and improve their code using intelligent explanations and analysis.

This platform allows users to write or paste code and receive:

  • Step-by-step explanations
  • Bug detection
  • Code improvement suggestions
  • Time and space complexity analysis
  • Interview-style coding questions
  • Analysis history saved to a database

The project integrates modern web technologies with artificial intelligence to create an interactive learning environment.


Features

1. Code Explanation

Paste code and receive a detailed explanation.

Example:

Input:

for (let i = 0; i < 5; i++) {
  console.log(i);
}

Output:

The loop runs 5 times.

  • i = 0 prints 0
  • i = 1 prints 1
  • i = 2 prints 2
  • i = 3 prints 3
  • i = 4 prints 4

2. Bug Detection

The AI detects errors and suggests fixes.

Example:

let x = 10
console.log(X)

Response:

Error: JavaScript is case-sensitive. X is different from x.

Correct code:

console.log(x)

3. Code Improvement Suggestions

The AI reviews your code and suggests:

  • Better coding practices and naming
  • Performance improvements
  • Cleaner logic and reduced redundancy
  • A fully rewritten improved version

4. Time and Space Complexity Analysis

The AI analyzes algorithms and returns complexity.

Example:

  • Time Complexity: O(n)
  • Space Complexity: O(1)

5. AI Interview Mode

The AI asks interview-style questions based on the submitted code.

Example:

  • Why did you use this approach?
  • Can this algorithm be optimized?
  • What is the time complexity?

6. Code Playground

Users can write and edit code directly in the browser using a Monaco Editor (VS Code engine) with support for 10 languages: JavaScript, TypeScript, Python, Java, C, C++, Go, Rust, HTML, and CSS.

Switching languages loads a language-specific sample code snippet.

7. Analysis History

All analyses are automatically saved to a PostgreSQL database. Users can:

  • View past analyses on the /history page
  • Expand entries to see the original code and AI response
  • Delete entries they no longer need

Tech Stack

Frontend

  • Next.js 16 - React framework for building full-stack applications
  • React 19 - UI library
  • Tailwind CSS 4 - Utility-first styling framework
  • Monaco Editor - Code editor component (VS Code engine)
  • react-markdown - Markdown rendering for AI responses

Backend

  • Next.js API Routes - Server-side logic

Artificial Intelligence

  • Google Gemini API - AI-powered code analysis (gemini-2.5-flash with fallback chain)

Database

  • PostgreSQL - Relational database
  • Neon Serverless Database - Cloud-hosted PostgreSQL

System Architecture

User
  |
  v
Frontend (Next.js + Monaco Editor)
  |
  v
API Routes (/api/explain, /api/debug, /api/improve, /api/complexity, /api/interview)
  |
  v
Gemini AI API (gemini-2.5-flash)
  |
  v
PostgreSQL Database (Neon) -- saves analysis history

Flow:

  1. User writes or pastes code in the Monaco Editor
  2. User selects a mode (Explain, Debug, Improve, Complexity, Interview)
  3. Frontend sends code + language to the corresponding API route
  4. API sends a language-aware prompt to Gemini AI
  5. Gemini generates the response
  6. Response is saved to PostgreSQL (Neon)
  7. Response is returned and rendered as Markdown in the UI

Project Structure

nexify
|
├── app
│   ├── layout.tsx              # Root layout with Navbar
│   ├── page.tsx                # Main page (editor + AI response)
│   ├── globals.css             # Global styles and theme variables
│   ├── history
│   │   └── page.tsx            # Analysis history page
│   └── api
│       ├── explain
│       │   └── route.ts        # Code explanation endpoint
│       ├── debug
│       │   └── route.ts        # Bug detection endpoint
│       ├── improve
│       │   └── route.ts        # Code improvement endpoint
│       ├── complexity
│       │   └── route.ts        # Complexity analysis endpoint
│       ├── interview
│       │   └── route.ts        # Interview questions endpoint
│       ├── history
│       │   └── route.ts        # History CRUD endpoint (GET/DELETE)
│       └── init-db
│           └── route.ts        # Database table initialization
│
├── components
│   ├── CodeEditor.tsx          # Monaco Editor wrapper with language selector
│   ├── AIResponse.tsx          # Markdown-rendered AI response panel
│   └── Navbar.tsx              # Navigation bar with Editor/History links
│
├── lib
│   ├── gemini.ts               # Gemini API client with model fallback
│   └── db.ts                   # Neon PostgreSQL connection and queries
│
├── .env.local                  # Environment variables (not committed)
└── README.md

Installation

1. Clone the repository

git clone https://github.com/yourusername/nexify.git
cd nexify

2. Install dependencies

npm install

3. Setup environment variables

Create a .env.local file:

GEMINI_API_KEY=your_gemini_api_key
DATABASE_URL=your_neon_postgresql_url

4. Initialize the database

Start the dev server and visit:

http://localhost:3000/api/init-db

This creates the analysis_history table in your Neon database.

5. Run the project

npm run dev

Application runs on: http://localhost:3000


API Endpoints

POST /api/explain

Request:

{
  "code": "for (let i = 0; i < 5; i++) console.log(i)",
  "language": "javascript"
}

Response:

{
  "explanation": "This loop runs 5 times and prints numbers from 0 to 4."
}

POST /api/debug

Returns { "analysis": "..." } with bug detection and fixes.

POST /api/improve

Returns { "suggestions": "..." } with code improvement suggestions and rewritten code.

POST /api/complexity

Returns { "analysis": "..." } with Big-O time and space complexity.

POST /api/interview

Returns { "questions": "..." } with 5 interview-style questions and answers.

GET /api/history

Returns { "history": [...] } with all saved analyses.

DELETE /api/history

Request: { "id": 1 }

Deletes a history entry by ID.

GET /api/init-db

Initializes the database table. Run once on first setup.


Future Improvements

  • VS Code extension integration
  • Code execution sandbox
  • Authentication system
  • AI pair programming mode
  • Learning analytics dashboard

Use Cases

This platform helps:

  • Students learning programming
  • Developers debugging code
  • Interview preparation
  • Understanding algorithms
  • Practicing coding problems

Contributing

Contributions are welcome.

Steps:

  1. Fork the repository
  2. Create a feature branch
  3. Commit changes
  4. Submit a pull request

License

This project is licensed under the MIT License.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors