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.
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
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)The AI reviews your code and suggests:
- Better coding practices and naming
- Performance improvements
- Cleaner logic and reduced redundancy
- A fully rewritten improved version
The AI analyzes algorithms and returns complexity.
Example:
- Time Complexity: O(n)
- Space Complexity: O(1)
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?
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.
All analyses are automatically saved to a PostgreSQL database. Users can:
- View past analyses on the
/historypage - Expand entries to see the original code and AI response
- Delete entries they no longer need
- 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
- Next.js API Routes - Server-side logic
- Google Gemini API - AI-powered code analysis (gemini-2.5-flash with fallback chain)
- PostgreSQL - Relational database
- Neon Serverless Database - Cloud-hosted PostgreSQL
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:
- User writes or pastes code in the Monaco Editor
- User selects a mode (Explain, Debug, Improve, Complexity, Interview)
- Frontend sends code + language to the corresponding API route
- API sends a language-aware prompt to Gemini AI
- Gemini generates the response
- Response is saved to PostgreSQL (Neon)
- Response is returned and rendered as Markdown in the UI
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
git clone https://github.com/yourusername/nexify.git
cd nexifynpm installCreate a .env.local file:
GEMINI_API_KEY=your_gemini_api_key
DATABASE_URL=your_neon_postgresql_url
Start the dev server and visit:
http://localhost:3000/api/init-db
This creates the analysis_history table in your Neon database.
npm run devApplication runs on: http://localhost:3000
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."
}Returns { "analysis": "..." } with bug detection and fixes.
Returns { "suggestions": "..." } with code improvement suggestions and rewritten code.
Returns { "analysis": "..." } with Big-O time and space complexity.
Returns { "questions": "..." } with 5 interview-style questions and answers.
Returns { "history": [...] } with all saved analyses.
Request: { "id": 1 }
Deletes a history entry by ID.
Initializes the database table. Run once on first setup.
- VS Code extension integration
- Code execution sandbox
- Authentication system
- AI pair programming mode
- Learning analytics dashboard
This platform helps:
- Students learning programming
- Developers debugging code
- Interview preparation
- Understanding algorithms
- Practicing coding problems
Contributions are welcome.
Steps:
- Fork the repository
- Create a feature branch
- Commit changes
- Submit a pull request
This project is licensed under the MIT License.