Skip to content

Latest commit

Β 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” CodeSense AI

Autonomous multi-agent code intelligence platform β€” 6 specialized AI agents review every pull request in parallel, automatically.

CI Self-Review Python 3.11+ FastAPI LangGraph License: MIT


What It Does

CodeSense AI runs 6 specialized agents in parallel on every GitHub pull request:

Agent What it checks
πŸ”’ Security OWASP Top 10, SQL injection, XSS, hardcoded secrets, insecure functions
⚑ Performance Big-O complexity, N+1 queries, memory leaks, blocking I/O in async code
πŸ—οΈ Architecture SOLID principles, God classes, design pattern opportunities, coupling
πŸ§ͺ Tests Coverage gaps, missing edge cases, generates ready-to-run test files
πŸ“ Docs Missing docstrings, outdated comments, missing type hints β€” auto-generates them
πŸ”§ AutoFix Generates a unified diff with all fixes applied β€” paste-ready code

Results appear as a structured comment directly on the PR β€” automatically, without you doing anything.


Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      CodeSense AI Platform                   β”‚
β”‚                                                              β”‚
β”‚   INPUT LAYER                                                β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”‚
β”‚   β”‚ Streamlit   β”‚   β”‚  FastAPI    β”‚   β”‚  GitHub      β”‚      β”‚
β”‚   β”‚ Web UI      β”‚   β”‚  REST API   β”‚   β”‚  Webhook     β”‚      β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜      β”‚
β”‚          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚
β”‚                             β”‚                                β”‚
β”‚   ORCHESTRATION LAYER (LangGraph StateGraph)                 β”‚
β”‚                             β–Ό                                β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”          β”‚
β”‚   β”‚Securityβ”‚ β”‚ Perf β”‚ β”‚ Arch β”‚ β”‚ Tests β”‚ β”‚ Docs β”‚          β”‚
β”‚   β”‚ Agent  β”‚ β”‚Agent β”‚ β”‚Agent β”‚ β”‚ Agent β”‚ β”‚Agent β”‚          β”‚
β”‚   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”˜ β””β”€β”€β”¬β”€β”€β”€β”˜ β””β”€β”€β”¬β”€β”€β”€β”˜ β””β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”¬β”€β”€β”€β”˜          β”‚
β”‚        β””β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β”‚
β”‚                             β”‚ fan-in (all 5 complete)        β”‚
β”‚                             β–Ό                                β”‚
β”‚                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                       β”‚
β”‚                    β”‚  AutoFix Agent  β”‚                       β”‚
β”‚                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                       β”‚
β”‚                             β”‚                                β”‚
β”‚   STORAGE LAYER              β–Ό                               β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚   β”‚  Evolution Tracker (SQLite)                          β”‚   β”‚
β”‚   β”‚  PR #1: 67/100 β†’ PR #10: 82/100 β†’ PR #25: 94/100   β”‚   β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tech stack: FastAPI Β· LangGraph Β· Groq (llama-3.3-70b) Β· LangSmith Β· Streamlit Β· SQLite Β· Docker Β· GitHub Actions


GitHub Webhook β€” Set It and Forget It

Set up once; every PR gets reviewed automatically in ~15 seconds.

5-step setup

1. Get a GitHub token Settings β†’ Developer settings β†’ Personal access tokens β†’ New token Scopes: repo, write:discussion

2. Generate a webhook secret

python3 -c "import secrets; print(secrets.token_hex(32))"

3. Add secrets to your repo Settings β†’ Secrets and variables β†’ Actions:

  • GROQ_API_KEY β€” get free at console.groq.com
  • GITHUB_WEBHOOK_SECRET β€” generated above
  • GITHUB_TOKEN β€” your personal access token

4. Deploy the backend (see Deployment) and note the URL

5. Add webhook in your GitHub repo Settings β†’ Webhooks β†’ Add webhook:

  • Payload URL: https://your-backend.render.com/webhook/github
  • Content type: application/json
  • Secret: your generated secret
  • Events: Pull requests only βœ“

That's it. Open a PR and watch the review appear automatically.


GitHub Self-Review

The meta-feature: CodeSense AI reviews its own pull requests using itself.

The .github/workflows/self-review.yml workflow:

  1. Spins up the FastAPI backend in the CI runner
  2. Fetches the PR diff (Python, JS, TS, Java, Go, Rust files)
  3. Runs all 6 agents via the local API
  4. Posts a full structured review comment on the PR

This activates automatically on every PR to main. Add GROQ_API_KEY as a GitHub Actions secret to enable it.


Evolution Dashboard

Track code quality across pull requests over time:

Score
100 β”‚                              ●──●
 90 β”‚              ●──●──●
 80 β”‚    ●──●──●
 70 β”‚ ●
 60 β”‚
    └────────────────────────────────▢ PRs over time
    PR1  PR5  PR10  PR15  PR20  PR25

Every webhook-triggered PR review is saved to SQLite. The πŸ“Š Evolution page in the Streamlit sidebar shows:

  • Overall score trend with colour-coded bands (Excellent / Good / Needs Work / Critical)
  • Per-agent score breakdown (Security, Performance, Architecture, Docs)
  • Critical issues per review (stacked bar chart)
  • Full review history table

API endpoints:

GET /evolution/repos          β€” list all tracked repos
GET /evolution/history        β€” full history (filter by ?repo=owner/repo)

LangSmith Tracing (Optional)

Full observability for every agent call β€” token usage, latency, and traces in LangSmith:

LANGSMITH_API_KEY=your_key_here
LANGSMITH_PROJECT=codesense-ai
LANGSMITH_TRACING_ENABLED=true

When configured, every LangGraph node execution is traced automatically. If not set, tracing is silently skipped β€” zero overhead.


Quick Start

Prerequisites

1. Clone & install

git clone https://github.com/DadaMastan-code/codesense-ai.git
cd codesense-ai
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

2. Configure

cp .env.example .env
# Edit .env β€” add your GROQ_API_KEY at minimum

3. Run

# Terminal 1: Backend
uvicorn backend.main:app --reload

# Terminal 2: Frontend
streamlit run frontend/app.py

Open http://localhost:8501 β€” paste code, click Analyse.

Docker Compose

docker compose -f docker/docker-compose.yml up

API Reference

Interactive docs: http://localhost:8000/docs

Endpoint Method Description
/analyze POST Full 6-agent analysis (parallel via LangGraph)
/analyze/stream POST Server-Sent Events β€” results agent by agent
/fix POST AutoFix only β€” pass issue list
/generate-tests POST Test generation only
/webhook/github POST GitHub PR webhook handler
/evolution/history GET Quality score history
/evolution/repos GET List tracked repositories
/health GET Health check

Example request

curl -X POST http://localhost:8000/analyze \
  -H "Content-Type: application/json" \
  -d '{
    "code": "query = f\"SELECT * FROM users WHERE id={user_id}\"",
    "language": "python",
    "context": "auth handler"
  }'

Deployment

Backend β†’ Render (free tier)

  1. New Web Service on render.com β€” connect this repo
  2. Build: pip install -r requirements.txt
  3. Start: uvicorn backend.main:app --host 0.0.0.0 --port $PORT
  4. Env vars: GROQ_API_KEY, GITHUB_WEBHOOK_SECRET, GITHUB_TOKEN

Frontend β†’ Streamlit Cloud (free)

  1. share.streamlit.io β€” connect this repo
  2. Main file: frontend/app.py
  3. Update API_BASE in frontend/app.py to your Render URL

Project Structure

codesense-ai/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ agents/
β”‚   β”‚   β”œβ”€β”€ security_agent.py       # OWASP Top 10 checker
β”‚   β”‚   β”œβ”€β”€ performance_agent.py    # Big-O + memory analyzer
β”‚   β”‚   β”œβ”€β”€ architecture_agent.py   # SOLID + design patterns
β”‚   β”‚   β”œβ”€β”€ test_agent.py           # Coverage + test generator
β”‚   β”‚   β”œβ”€β”€ doc_agent.py            # Docstring generator
β”‚   β”‚   └── fix_agent.py            # AutoFix diff generator
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ github_webhook.py       # GitHub PR webhook + comment bot
β”‚   β”‚   └── evolution_route.py      # Quality history endpoints
β”‚   β”œβ”€β”€ evolution/
β”‚   β”‚   └── tracker.py              # SQLite per-PR quality tracking
β”‚   β”œβ”€β”€ pipelines/
β”‚   β”‚   └── orchestrator.py         # LangGraph StateGraph (parallel fan-out)
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ llm_client.py           # Groq / OpenAI client with fallback
β”‚   β”‚   β”œβ”€β”€ tracing.py              # LangSmith tracing (optional no-op)
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ models/schemas.py           # Pydantic v2 schemas
β”‚   β”œβ”€β”€ config.py                   # Settings (pydantic-settings)
β”‚   └── main.py                     # FastAPI app
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ app.py                      # Main analyzer UI
β”‚   └── pages/
β”‚       └── πŸ“Š_Evolution.py         # Evolution dashboard
β”œβ”€β”€ tests/
β”œβ”€β”€ docker/
β”‚   β”œβ”€β”€ Dockerfile.backend
β”‚   β”œβ”€β”€ Dockerfile.frontend
β”‚   └── docker-compose.yml
β”œβ”€β”€ .github/workflows/
β”‚   β”œβ”€β”€ ci.yml                      # Test β†’ lint β†’ mypy β†’ docker build
β”‚   └── self-review.yml             # CodeSense reviews its own PRs ✨
└── requirements.txt

What Makes This Different

Basic Code Linters CodeSense AI
Rule-based checks only AI reasoning about context and intent
One dimension (style OR security) 6 dimensions simultaneously in parallel
No explanation of WHY Detailed reasoning + OWASP references for every finding
Manual trigger only Automatic on every GitHub PR via webhook
No memory across PRs Evolution tracking β€” sees quality patterns over time
Static suggestions Auto-fix with unified diff β€” paste-ready

License

MIT β€” see LICENSE


Built with FastAPI Β· LangGraph Β· Groq (llama-3.3-70b) Β· Streamlit
⭐ Star this repo if it helped you

About

πŸ” Multi-agent AI platform that reviews code like a senior engineering team β€” security, performance, architecture, tests & docs in parallel

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages