Skip to content

vineetp6/CodeGenAI

Repository files navigation

CodeGenius: Agentic Text-to-Code Generation

CodeGenius is an AI-powered application that generates high-quality code from natural language descriptions. It supports multiple programming languages, provides live syntax validation, and offers debugging assistance.

Features

  • Contextual Intent Recognition: Understands your requirements in natural language
  • Multi-Language Code Generation: Supports JavaScript, TypeScript, Python, Java, C#, Go, Ruby, and more
  • Live Syntax & Semantic Validation: Checks your code for errors and suggests improvements
  • Interactive Debugging Support: Helps troubleshoot issues in your code
  • Version Control Integration: Track your code changes
  • Code Snippet Library & Templates: Store reusable code snippets for quick access
  • Automated Unit Test Generation: Creates tests for your code automatically
  • Security & Compliance Checks: Identifies potential security vulnerabilities
  • Customizable AI Agent Workflows: Configure how the AI generates your code

Prerequisites

  • Node.js 20.x or higher
  • npm 9.x or higher
  • Hugging Face API Key (for AI features)

Setup and Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/codegenius.git
    cd codegenius
  2. Install dependencies:

    npm install
  3. Set up environment variables: Create a .env file in the root directory with the following:

    HUGGINGFACE_API_TOKEN=your_huggingface_api_token
    
  4. Start the development server:

    npm run dev
  5. Open your browser and navigate to http://localhost:5000

Running in Production

To run the application in production mode:

npm run build
npm start

Packaging the Application

For Windows

  1. Install electron and electron-builder:

    npm install --save-dev electron electron-builder
  2. Create an electron entry file (electron.js) in the root directory:

    const { app, BrowserWindow } = require('electron');
    const path = require('path');
    const express = require('express');
    const server = require('./server/index.js');
    
    let mainWindow;
    
    function createWindow() {
      mainWindow = new BrowserWindow({
        width: 1200,
        height: 800,
        webPreferences: {
          nodeIntegration: true,
          contextIsolation: false
        }
      });
    
      mainWindow.loadURL('http://localhost:5000');
      mainWindow.on('closed', () => mainWindow = null);
    }
    
    app.on('ready', createWindow);
    
    app.on('window-all-closed', () => {
      if (process.platform !== 'darwin') app.quit();
    });
    
    app.on('activate', () => {
      if (mainWindow === null) createWindow();
    });
  3. Update your package.json with electron configuration:

    {
      "main": "electron.js",
      "scripts": {
        "electron": "electron .",
        "package-win": "electron-builder --win --x64"
      },
      "build": {
        "appId": "com.yourdomain.codegenius",
        "productName": "CodeGenius",
        "win": {
          "target": "nsis",
          "icon": "assets/icon.ico"
        }
      }
    }
  4. Build the Windows installer:

    npm run package-win

    The installer will be available in the dist folder.

For Android

To package the application for Android, we'll use Capacitor:

  1. Install Capacitor:

    npm install --save @capacitor/core @capacitor/android
    npm install --save-dev @capacitor/cli
  2. Initialize Capacitor in your project:

    npx cap init CodeGenius com.yourdomain.codegenius --web-dir dist
  3. Build your web application:

    npm run build
  4. Add Android platform:

    npx cap add android
  5. Update the Android configuration:

    npx cap copy android
    npx cap sync android
  6. Open Android Studio to build and run:

    npx cap open android
  7. In Android Studio:

    • Build -> Build Bundle(s) / APK(s) -> Build APK(s)
    • Or Build -> Generate Signed Bundle/APK for release version

API Documentation

Code Generation API

POST /api/code/generate
Content-Type: application/json

{
  "prompt": "Create a function that calculates the Fibonacci sequence",
  "language": "javascript",
  "generateTests": true
}

Code Validation API

POST /api/code/validate
Content-Type: application/json

{
  "code": "function example() { console.log('Hello') }",
  "language": "javascript"
}

Generate Tests API

POST /api/code/generate-tests
Content-Type: application/json

{
  "code": "function sum(a, b) { return a + b; }",
  "language": "javascript"
}

Architecture

The application uses a client-server architecture:

  • Frontend: React with TypeScript, using tailwind CSS and shadcn components for the UI
  • Backend: Express.js server with Qdrant for storage
  • AI Model: Hugging Face models for code generation, validation, and test generation

License

MIT

Contributing

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin feature/my-new-feature
  5. Submit a pull request

About

AI Code generator App - Skeleton Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages