Skip to content

Built a full-stack coding assistant using React.js and Flask that leverages OpenAI GPT for code generation and debugging. Integrated LangChain agents for multi-step reasoning, FAISS for Retrieval-Augmented Generation (RAG), and OpenAI Function Calling to extract structured metadata like difficulty and tags.

Notifications You must be signed in to change notification settings

Shivang139/CodeWhisper-AI-Powered-Coding-Assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

CodeWhisper - AI-Powered Coding Assistant

License: MIT React Node.js TypeScript Express.js OpenAI LangChain

An intelligent full-stack coding assistant built with React and a Node.js/TypeScript backend that uses the power of OpenAI GPT and LangChain for advanced code generation, debugging, and analysis.

🌟 Introduction

CodeWhisper is a full-stack AI-powered coding assistant built to enhance developer productivity by offering intelligent code generation, explanation, and debugging capabilities. Designed with a clean, chat-based interface, it transforms natural language prompts into functional code while helping users understand and fix errors effectively.

The system leverages OpenAI's GPT-4 for core reasoning, LangChain agents for multi-step problem-solving, and FAISS-based Retrieval-Augmented Generation (RAG) to provide relevant, context-aware responses based on historical prompts and solutions. With a strong focus on both backend orchestration and frontend usability, CodeWhisper blends modern GenAI techniques with robust software engineering.

✨ Key Features

Smart Code Generation

Generate accurate code snippets across languages using natural language queries powered by GPT-4.

Intelligent Debugging

Paste faulty code and receive detailed analysis along with corrected versions and explanations.

Multi-Step Reasoning with LangChain

Employs LangChain agents to deconstruct complex prompts and deliver logical, step-by-step solutions.

Retrieval-Augmented Generation (RAG)

Integrates a FAISS vector database to retrieve semantically similar historical queries, improving context awareness in responses.

Structured Metadata Extraction

Uses OpenAI Function Calling to extract metadata such as programming language, difficulty level, and key concepts from generated content.

Full-Stack Architecture

Built with a responsive React.js frontend and a Python Flask backend, ensuring seamless communication between user inputs and AI processing.

Interactive Chat Interface

A modern, chat-style UI allows users to interact naturally with the assistant, enhancing usability and developer experience.

⚙️ How It Works - The Architecture

CodeWhisper operates on a classic client-server model but with a highly intelligent backend.

  1. Frontend (React.js): The user interacts with the React application, submitting requests for code generation or debugging. The UI is designed to be intuitive and manage the conversation state.
  2. Backend (Node.js & Express.js): The Node.js/Express server acts as the brain of the operation. It receives requests from the frontend via a REST API and orchestrates the AI functionalities.
  3. LangChain Agents: For complex queries, the backend uses langchain.js to create a chain-of-thought process. The agent can decide to use different tools (like the RAG system or the base GPT model) to fulfill the request.
  4. RAG with FAISS: When a query requires specific context, the system uses the FAISS vector index to find the most relevant documents or code snippets. This information is then "augmented" to the prompt sent to the language model.
  5. OpenAI GPT: The core generative power comes from an OpenAI GPT model. It receives the final, context-rich prompt and generates the code or debugging explanation.
  6. OpenAI Function Calling: After a response is generated, a separate call is made using OpenAI Function Calling to analyze the text and return structured JSON data (e.g., {"language": "Python", "difficulty": "Intermediate", "tags": ["data-processing", "pandas"]}).
  7. Response: The final, complete response (generated code + metadata) is sent back to the React frontend to be displayed to the user.

🛠️ Tech Stack

  • Frontend: React.js, CSS3
  • Backend: Node.js, TypeScript, Express.js
  • Core AI: OpenAI GPT-3.5/4
  • Orchestration Framework: LangChain.js
  • Vector Store / RAG: FAISS (Facebook AI Similarity Search)
  • API & Metadata: OpenAI Function Calling

🚀 Getting Started

Follow these instructions to get a local copy up and running.

Prerequisites

  • Node.js and npm/yarn installed
  • An OpenAI API Key

Installation & Setup

  1. Clone the repository:

    git clone [https://github.com/Shivang139/CodeWhisper-AI-Powered-Coding-Assistant.git](https://github.com/Shivang139/CodeWhisper-AI-Powered-Coding-Assistant.git)
    cd CodeWhisper-AI-Powered-Coding-Assistant
  2. Backend Setup (Node.js & TypeScript):

    # Navigate to the backend directory (e.g., /api or /backend)
    cd backend
    
    # Install dependencies
    npm install
    
    # Set up your environment variables
    # Create a .env file in the backend folder and add your OpenAI API key
    echo "OPENAI_API_KEY='your_super_secret_key_here'" > .env
    
    # (Optional) If you have a pre-built FAISS index, place it in the designated folder.
  3. Frontend Setup (React):

    # Navigate to the frontend directory from the root
    cd ../frontend
    
    # Install npm packages
    npm install
    
    # Create a .env.local file and add the backend API URL
    # Make sure the port matches the one your Node.js server is using.
    echo "REACT_APP_API_URL=http://localhost:5000/api" > .env.local

Running the Application

  1. Start the Node.js Backend:

    # From the /backend directory
    # This will compile TypeScript and start the server.
    npm run dev

    The backend will typically be running on http://localhost:5000. Check your package.json for the exact command and port.

  2. Start the React Frontend:

    # From the /frontend directory in a new terminal
    npm start

    The application will open in your browser at http://localhost:3000.

Usage

Simply open the application in your browser and start typing!

  • To generate code: Type a clear instruction like, "Write a Python function that takes a list of integers and returns the sum of all even numbers."
  • To debug code: Paste your code snippet along with the error message or a question like, "Why am I getting a TypeError in this JavaScript code?"

The AI will process your request and provide a detailed response, including the generated code and any extracted metadata.

🤝 Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📜 License

Distributed under the MIT License. See the LICENSE file for more information.

👤 Contact

Shivang - shivangagrawal139@gmail.com

Project Link: https://github.com/Shivang139/CodeWhisper-AI-Powered-Coding-Assistant

About

Built a full-stack coding assistant using React.js and Flask that leverages OpenAI GPT for code generation and debugging. Integrated LangChain agents for multi-step reasoning, FAISS for Retrieval-Augmented Generation (RAG), and OpenAI Function Calling to extract structured metadata like difficulty and tags.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published