Transform any codebase into interactive tutorials and analyze code quality with AI-powered insights
CodeSensei is an intelligent web-based platform that helps developers understand and document complex codebases. Using advanced AI and machine learning techniques, it automatically generates interactive tutorials, detects security vulnerabilities, analyzes code quality, and provides intelligent Q&A capabilities.
Perfect for: New developers onboarding to a codebase, code reviews, documentation generation, and security audits.
- Automated Documentation: Generate interactive Markdown tutorials with Mermaid diagrams in under 10 minutes
- Smart Analysis: AI identifies core abstractions and architectural patterns
- Multi-language Support: Process Python, JavaScript, TypeScript, Java, Go, and more
- Beginner-Friendly: Explanations with code examples and visual diagrams
- Complexity Analysis: Detect cyclomatic complexity hotspots using Radon
- Dead Code Detection: Identify orphan functions and unused code via NetworkX call graphs
- Code Similarity Clustering: Find duplicate patterns using CodeBERT embeddings and K-means clustering
- Pattern Mining: Extract common coding patterns using AST analysis
- Vulnerability Detection: Scan for SQL injection, XSS, insecure authentication, and 15+ vulnerability types using Bandit
- Detailed Reports: Get exact file paths and line numbers with HTML/JSON export
- Severity Classification: High, Medium, Low severity categorization
- Semantic Search: Function-level code chunking with intelligent retrieval
- Context-Aware Q&A: Ask questions about codebase architecture and implementation
- Source Tracking: Get exact file and line references for every answer
- Technologies: ChromaDB (HNSW + cosine similarity) with all-MiniLM-L6-v2 embeddings
- Python 3.8 or higher
- Google Gemini API Key (or compatible LLM provider)
# Clone the repository
git clone https://github.com/prabhuanantht/CodeSensei.git
cd CodeSensei_streamlit
# Install dependencies
pip install -r requirements.txt
# Set up API key
cp env_example.txt .env
# Edit .env and add your GEMINI_API_KEY# Using the run script
./run_app.sh # Unix/Mac
# or
run_app.bat # Windows
# Or directly with Streamlit
streamlit run app.pyOpen your browser at http://localhost:8501
- Navigate to the Tutorial Generation tab
- Enter a GitHub repository URL or local directory path
- Configure settings (language, max abstractions)
- Click "Generate Tutorial"
- Wait for completion (typically 5-15 minutes)
- Download the generated tutorial as a ZIP file
- Load your codebase (same as tutorial generation)
- Navigate to Code Intelligence tab
- Run individual analyses:
- Complexity Analysis: View cyclomatic complexity metrics
- Orphan Detection: Find dead code
- Pattern Mining: Discover common patterns
- Review detailed results with file locations
- In the Security tab, select severity and confidence filters
- Click "Run Security Scan"
- Review vulnerabilities organized by severity
- Download HTML/JSON reports
- In the Chat tab, click "Index Codebase for Chat"
- Wait for indexing to complete
- Ask questions about the codebase
- Get AI-powered answers with source citations
CodeSensei Platform
├── Frontend (Streamlit)
│ ├── Tutorial Generation UI
│ ├── Intelligence Analysis UI
│ ├── Security Scanner UI
│ └── RAG Chatbot UI
├── Core Analyzers
│ ├── CodeIntelligenceAnalyzer (CodeBERT, NetworkX, Radon)
│ ├── SecurityAnalyzer (Bandit)
│ └── CodebaseRAG (ChromaDB, sentence-transformers)
└── Backend Integration
└── PocketFlow Workflow Engine
- Streamlit: Modern web framework for Python apps
- Python 3.8+: Main programming language
- Google Gemini: LLM for content generation and Q&A
- CodeBERT (microsoft/codebert-base): Code embeddings for similarity analysis
- Transformers: Hugging Face transformers library
- NetworkX: Graph analysis for call graphs
- Radon: Code complexity metrics
- Bandit: Security vulnerability scanning
- scikit-learn: Clustering and similarity analysis
- ChromaDB: HNSW indexing with cosine similarity
- sentence-transformers: all-MiniLM-L6-v2 embeddings
- ChromaDB: Vector database for semantic search
- Mermaid: Diagram generation
- Pandas: Data manipulation and analysis
| Module | Functionality | Technologies |
|---|---|---|
| Tutorial Generation | AI-powered documentation with diagrams | Gemini, Mermaid, AST parsing |
| Complexity Analysis | Cyclomatic complexity & maintainability | Radon, NetworkX |
| Orphan Detection | Dead code identification | NetworkX, AST |
| Pattern Mining | Code pattern extraction | AST, NetworkX |
| Code Similarity | Duplicate code detection | CodeBERT, K-means, scikit-learn |
| Security Scanning | Vulnerability detection | Bandit, AST |
| RAG Chatbot | Semantic Q&A | ChromaDB, sentence-transformers, Gemini |
CodeSensei_streamlit/
├── app_new.py # Main Streamlit application
├── intelligence_analyzer.py # Code intelligence analysis
├── security_analyzer.py # Security vulnerability scanning
├── rag_chatbot.py # RAG chatbot implementation
├── requirements.txt # Python dependencies
├── .env # API keys (not in repo)
├── output/ # Generated tutorials
├── cache/ # Cached repositories
└── logs/ # Application logs
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Ananth Prabhu T
- Shreedhar A Sherlekar
- Chandan K Vasista
Made with ❤️ for the developer community