Skip to content

patelmegh1234/Code-Review-Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Autonomous Code Explainer Agent

An autonomous, low-latency AI agent engineered to ingest raw source code, perform architectural logic extraction, and transform highly technical codebases into clean, jargon-free documentation. Designed for seamless execution within standalone automation workflows or enterprise onboarding pipelines.


System Architecture & Workflow Pipeline

This agent functions as a high-reasoning, standalone execution pipeline that decouples technical complexity from user-facing documentation.

       [ Raw Source Code Input ] 
                   │
                   ▼
┌──────────────────────────────────────┐
│       Step 1: Input Ingestion        │ -> Syntax Detection & Boundary Mapping
└──────────────────────────────────────┘
                   │
                   ▼
┌──────────────────────────────────────┐
│   Step 2: Semantic Logic Parsing     │ -> Token Isolation & Algorithmic Profiling
└──────────────────────────────────────┘
                   │
                   ▼
┌──────────────────────────────────────┐
│  Step 3: Jargon Translation Engine   │ -> Maps concepts to Plain English (MVP Blueprint)
└──────────────────────────────────────┘
                   │
                   ▼
┌──────────────────────────────────────┐
│ Step 4: Strict Markdown Enforcement  │ -> Validates Contract Shape (No Raw JSON)
└──────────────────────────────────────┘
                   │
                   ▼
       [ Production Documentation ]


Deep-Dive Technical Implementation

Core Mechanics

  • Orchestration Framework: Built using CrewAI to maintain atomic state isolation and task encapsulation.
  • Underlying Engine: Powered by gemini/gemini-2.5-flash for high-speed abstract reasoning and context processing.
  • Abstractions Matrix: Transforms abstract object-oriented parameters into plain-English equivalents (e.g., mapping "class instantiation" to "creating a blueprint").

Resilience & Edge Case Resolution

  • Strict Output Typing: Enforces an absolute string-based Markdown schema to prevent the LLM from outputting unstructured JSON formatting—ensuring subsequent agents can read the data.
  • Malformed Snippet Handling: Built-in validation steps in task.py intercept partial or syntactically broken code blocks, preventing infinite validation loops and returning clean error contexts instead of failing silently.

Architecture Objects & Topology

Object Reference Instance Identity Operational Scope / Stack
Agent Object code_explainer Principal Developer Advocate & Technical Educator
Task Object code_explanation_task Structural Logic Parsing & Structural Normalization
Base Engine gemini/gemini-2.5-flash Global LLM Context Provider
Source Tracks agent.py, task.py Implementation Blueprints

Quickstart & Zero-Friction Setup

1. Environment Isolation

Configure a clean, isolated environment using Python venv:

python -m venv venv
source venv/bin/activate  # On Windows use: venv\Scripts\activate

2. Dependency Ingestion

Install all required framework dependencies and core extensions:

pip install crewai python-dotenv

3. Environment Variables Configuration

Create a .env file in the root subdirectory to securely initialize upstream keys:

GEMINI_API_KEY=your_production_api_key_here

4. Direct Execution

Launch the orchestration pipeline via main.py:

python main.py

When prompted by \n--- ENTER CODE SNIPPET ---, provide the targeted code payload.


Operational Contract & Definition of Done

The agent strictly adheres to the following deterministic output schema. Any variation in formatting violates the system's runtime contract:

## WHAT IT DOES
[1-2 sentence plain-English summary of what the code achieves]

## HOW IT WORKS (Step-by-Step)
- [Step 1 explained simply without technical jargon]
- [Step 2 explained simply without technical jargon]

## EXPECTED OUTPUT
[Clear, highly detailed description of the final result when executed]

Engineering Maintainability Guidelines

  • Modifying Capabilities: To adjust persona bounds or upgrade models, edit configurations exclusively inside agent.py.
  • Altering Output Contracts: Operational instructions and strict formatting constraints are isolated in task.py.
  • State Integrity: Maintain consistent placeholder mappings ({code}) across the execution chain to prevent runtime key errors inside parent workflows.

About

Autonomous AI code review agent that analyzes Python projects, flags issues, and suggests improvements using multi-agent orchestration and structured feedback loops. Focused on developer productivity, code quality, and repeatable review workflows.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages