Skip to content

QuantumLogicsLabs/HackingTheRepo-Backend

Repository files navigation

HackingTheRepo – Backend

The AI engine that analyzes your codebase, applies smart changes, and creates pull requests automatically.

What This Does

  • Accepts a GitHub repo URL
  • Clones the repo into a local sandbox
  • Analyzes the code using AI
  • Applies smart improvements
  • Automatically opens a Pull Request with the changes
  • Allows the repo owner to guide the AI mid-process via chat

Tech Stack

  • Runtime: Node.js
  • Framework: Express.js
  • Database: MongoDB (Mongoose)
  • Realtime: Socket.io
  • AI: DeepSeek / OpenRouter / Qwen / Puter (fallback order)
  • Vector DB: Pinecone
  • Version Control Automation: GitHub API

Folder Structure

backend/
├── analysis/
│   ├── repoAnalyzer.js      # Reads repo files, saves folder structure as .txt
│   ├── aiEngine.js          # Sends code to AI, gets suggestions
│   └── changeApplier.js     # Applies AI suggestions to code
├── controllers/
│   ├── agentController.js   # Main agent logic
│   └── chatController.js    # Owner guidance/chat logic
├── models/
│   ├── Chat.js              # Chat session data
│   ├── Job.js               # Job tracking
│   ├── Lesson.js            # AI lessons learned
│   ├── Log.js               # Logs for each job
│   └── repoModel.js         # Repo data and analysis status
├── routes/
│   ├── agentRoutes.js       # Agent API routes
│   ├── chatRoutes.js        # Chat API routes
│   └── jobRoutes.js         # Job status routes
├── services/
│   ├── githubService.js     # GitHub API: clone, branch, commit, PR
│   ├── aiService.js         # AI API connection
│   ├── cronService.js       # Scheduled jobs
│   └── vectorService.js     # Pinecone vector DB
├── sandbox/                 # Where repos are cloned and worked on
├── .env                     # Your environment variables
├── .env.example             # Template for .env
└── server.js                # Entry point

Setup Instructions

1. Clone the repo

git clone https://github.com/QuantumLogicsLabs/HackingTheRepo-Backend.git
cd HackingTheRepo-Backend

2. Install dependencies

npm install

3. Set up environment variables

cp .env.example .env

Then fill in your actual keys in .env:

  • GITHUB_TOKEN — GitHub Personal Access Token
  • DEEPSEEK_API_KEY — DeepSeek API Key
  • PINECONE_API_KEY — Pinecone API Key
  • MONGO_URI — MongoDB connection string

4. Run the server

node server.js

Server runs on port 5000 by default.

API Endpoints

Method Endpoint Description
GET /api/status Check if server is running
POST /api/agent/analyze Submit a repo for analysis
POST /api/agent/apply Apply AI suggestions
POST /api/chat Send guidance to AI
GET /api/jobs/:id Get job status

How It Works

Owner submits repo URL
        ↓
AI clones repo into sandbox/
        ↓
repoAnalyzer saves folder structure as .txt
        ↓
aiEngine analyzes code and suggests improvements
        ↓
Owner guides AI via chat if needed
        ↓
changeApplier applies changes
        ↓
githubService opens PR automatically
        ↓
Owner reviews and accepts PR ✅

Team

Built by TeamAlpha — QuantumLogicsLabs

About

HackingTheRepo — Autonomous Code Improvement Agent using Fine-tuned LLM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors