Skip to content

CogniCode Agent: A privacy-first, AI-powered web tool for real-time code analysis, refactoring, and unit test generation. Built with Next.js, TypeScript, Flask, and PyTorch, it uses local open-source AI models to enhance developer productivity.

License

Notifications You must be signed in to change notification settings

Edmon02/cognicode-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

CogniCode Agent 🧠

Multi-agent AI system for real-time code analysis, refactoring, and test generation

MIT License Next.js Flask AI Powered

CogniCode Agent is a privacy-first, AI-powered development tool that provides real-time code analysis, intelligent refactoring suggestions, and automated unit test generation. Built for Hackathon 2025 with a focus on developer productivity and code quality.

CogniCode Agent Dashboard

✨ Features

  • πŸ” Real-time Code Analysis: Instant bug detection, style checks, and performance insights
  • ⚑ Intelligent Refactoring: AI-powered suggestions to improve code quality and performance
  • πŸ§ͺ Automated Test Generation: Comprehensive unit test creation with edge cases
  • πŸ”’ Privacy-First: All AI processing runs locally - your code never leaves your machine
  • 🌐 Multi-language Support: JavaScript, TypeScript, Python, Java, and more
  • πŸ“Š Code Metrics: Complexity analysis, maintainability scores, and quality insights
  • 🎨 Beautiful UI: Modern, responsive design with real-time updates

πŸš€ Quick Start

Prerequisites

  • Node.js 16+ and npm
  • Python 3.8+ and pip
  • 4GB+ RAM (8GB+ recommended for AI models)
  • 5GB+ free disk space for AI models

Automated Setup

# Clone the repository
git clone https://github.com/Edmon02/cognicode-agent.git
cd cognicode-agent

# Run the setup script
chmod +x setup.sh
./setup.sh

# Start the full application
./run-dev.sh

Manual Setup

Click to expand manual setup instructions

Frontend Setup

npm install

Backend Setup

cd server
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt

Download AI Models (Optional)

cd server
python scripts/download_models.py

Start Services

# Terminal 1 - Backend
cd server && source venv/bin/activate && python app.py

# Terminal 2 - Frontend  
npm run dev

πŸ“– Documentation

πŸ“š Complete Documentation - Comprehensive guides and references

Quick Links

πŸ“– Quick Usage

  1. Open the Application: Navigate to http://localhost:3000
  2. Write/Paste Code: Use the Monaco editor to input your code
  3. Select Language: Choose from JavaScript, TypeScript, Python, Java, etc.
  4. Analyze Code: Click "Analyze" to run AI-powered analysis
  5. Review Results: Check the Analysis, Refactor, and Tests tabs
  6. Apply Suggestions: Click "Apply" on refactoring suggestions
  7. Download Tests: Export generated unit tests

πŸ‘‰ Detailed Usage Guide

Example Workflow

// Paste this code and click "Analyze"
function fibonacci(n) {
    if (n <= 1) return n;
    return fibonacci(n - 1) + fibonacci(n - 2);
}

console.log(fibonacci(10));

The AI will detect:

  • ⚠️ Performance issue (exponential time complexity)
  • πŸ’‘ Refactoring suggestion (memoization)
  • πŸ§ͺ Generated unit tests with edge cases

πŸ—οΈ Architecture

Multi-Agent System

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Linter Agent  β”‚    β”‚ Refactor Agent     β”‚    β”‚ TestGen Agent   β”‚
β”‚                 β”‚    β”‚                    β”‚    β”‚                 β”‚
β”‚ β€’ Bug Detection β”‚    β”‚ β€’ Code Optimizationβ”‚    β”‚ β€’ Unit Tests    β”‚
β”‚ β€’ Style Analysisβ”‚    β”‚ β€’ Pattern Improve. β”‚    β”‚ β€’ Edge Cases    β”‚
β”‚ β€’ Security Checkβ”‚    β”‚ β€’ Performance Tune β”‚    β”‚ β€’ Integration   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Code Service   β”‚
                    β”‚                 β”‚
                    β”‚ β€’ Result        β”‚
                    β”‚   Processing    β”‚
                    β”‚ β€’ Caching       β”‚
                    β”‚ β€’ Coordination  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tech Stack

Frontend

  • Next.js 13+ (App Router)
  • React 18 with TypeScript
  • Tailwind CSS + shadcn/ui
  • Monaco Editor
  • Socket.IO Client
  • Framer Motion

Backend

  • Flask + Flask-SocketIO
  • PyTorch + Transformers
  • CodeBERT (Analysis)
  • CodeT5 (Refactoring)
  • Multi-agent Architecture

AI Models

  • microsoft/codebert-base - Code analysis and bug detection
  • Salesforce/codet5-small - Code generation and refactoring
  • Local execution for privacy

πŸ”§ Configuration

Environment Variables

Frontend (.env.local)

NEXT_PUBLIC_BACKEND_URL=http://localhost:5000
NEXT_PUBLIC_APP_NAME=CogniCode Agent

Backend (server/.env)

FLASK_ENV=development
PORT=5000
MODELS_PATH=./models
USE_DEMO_MODE=true
LOG_LEVEL=INFO

Model Configuration

Models are automatically downloaded to server/models/. For custom models:

# server/agents/base_agent.py
CUSTOM_MODELS = {
    'linter': 'your-custom/codebert-model',
    'refactor': 'your-custom/codet5-model',
    'testgen': 'your-custom/test-model'
}

πŸš€ Deployment

Local Development

./run-dev.sh

Production with Docker

# Build and run with Docker Compose
docker-compose up --build

# Or build individual services
docker build -t cognicode-frontend .
docker build -t cognicode-backend ./server

Cloud Deployment

Frontend (Vercel)

# Deploy to Vercel
npm run build
vercel --prod

Backend (Docker/Cloud)

# Build production image
docker build -t cognicode-backend ./server

# Deploy to your preferred cloud provider
# (AWS ECS, Google Cloud Run, Azure Container Instances, etc.)

πŸ§ͺ Testing

Frontend Tests

npm test
npm run test:watch

Backend Tests

cd server
source venv/bin/activate
pytest
pytest --coverage

Integration Tests

# Start both services and run E2E tests
npm run test:e2e

πŸ“Š Performance

Benchmarks

Operation Time Memory
Code Analysis <500ms ~200MB
Refactor Generation <1s ~300MB
Test Generation <1.5s ~250MB
Model Loading ~10s ~1GB

Optimization Tips

  • CPU: Use quantized models for faster inference
  • Memory: Enable model caching and batch processing
  • Storage: Models require 2-5GB disk space
  • Network: All processing is local (no API calls)

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

# Fork and clone the repository
git clone https://github.com/Edmon02/cognicode-agent.git

# Create a feature branch
git checkout -b feature/amazing-feature

# Make your changes and test
npm test
cd server && pytest

# Commit and push
git commit -m "Add amazing feature"
git push origin feature/amazing-feature

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ† Hackathon 2025

CogniCode Agent was built for Hackathon 2025, targeting these challenges:

  • πŸ€– AI Innovation: Multi-agent architecture with local AI models
  • ⚑ Real-time Applications: WebSocket-based live code analysis
  • πŸ”’ Privacy-First Solutions: All processing runs locally
  • πŸ› οΈ Developer Tools: Productivity-focused development experience

Awards Targeting

  • Best Use of AI
  • Best Solo Project
  • Most Innovative Solution
  • Best Developer Tool

πŸ”— Links

πŸ“ž Support


Built with ❀️ for developers by developers

⭐ Star this repo | 🍴 Fork it | πŸ“ Contribute

About

CogniCode Agent: A privacy-first, AI-powered web tool for real-time code analysis, refactoring, and unit test generation. Built with Next.js, TypeScript, Flask, and PyTorch, it uses local open-source AI models to enhance developer productivity.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Contributors 2

  •  
  •