Skip to content

Edmon02/cognicode-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

1 star

Watchers

0 watching

Forks

Releases

No releases published

Contributors