DiagramFlow Backend is a powerful codebase analysis service that intelligently extracts and processes information from Python repositories. Built with FastAPI, it provides RESTful endpoints for cloning Git repositories, parsing Python code structures, and generating interactive insights through an AI-powered chat interface.
Screencast.from.23-03-25.12_59_03.PM.IST.mp4
- 🔍 Intelligent Code Analysis: Automatically parses Python files to extract classes, functions, and dependencies
- 📊 Structured Data Export: Generates comprehensive JSON reports of codebase structure
- 🤖 AI-Powered Chat Interface: Query your codebase using natural language through ChromaDB integration
- 🌐 Git Repository Integration: Clone and analyze repositories directly from Git URLs
- ⚡ Fast API Backend: High-performance REST API built with FastAPI
- 🐳 Docker Ready: Containerized deployment for easy scaling
server.py
: FastAPI application server with health checks and main endpointsgitCloner.py
: Git repository cloning and directory management utilitiesparser_pyfile.py
: Python AST-based code parsing and analysis engineChatInterface.py
: AI-powered natural language interface for codebase queriespushToChromaDB.py
&fetchFromChromaDB.py
: Vector database integration for semantic code searchmain.py
: Core directory traversal and analysis orchestration
- Repository Ingestion: Clone Git repositories or process local directories
- Code Parsing: Extract structural information using Python AST
- Vector Storage: Store code snippets in ChromaDB for semantic search
- API Exposure: Serve analysis results and chat functionality via REST endpoints
- Python 3.10
- Git (for repository cloning)
-
Create and activate virtual environment:
python3.10 -m venv .venv source .venv/bin/activate # On macOS/Linux # or .venv\Scripts\activate # On Windows
-
Install dependencies:
pip install -r requirements.txt
-
Start the server:
fastapi run server.py
The API will be available at http://localhost:8000
with interactive documentation at http://localhost:8000/docs
.
For production deployment or if you prefer containerized environments:
-
Build the Docker image:
docker build -t diagramflow-backend .
-
Run the container:
docker run -p 8000:8000 diagramflow-backend
GET /health
Returns the service status.
POST /generate
Content-Type: application/json
{
"question": "How does the authentication work in this codebase?"
}
POST /clonerepo
Content-Type: application/json
{
"url": "https://github.com/username/repository.git"
}
formats/codebase.json
: Comprehensive structural analysis of the codebasechromadb/
: Vector database containing code embeddings for semantic searchlogs/app.log
: Application logs and analysis details
DiagramFlow-Backend/
├── server.py # FastAPI application
├── gitCloner.py # Git operations
├── parser_pyfile.py # Code analysis
├── ChatInterface.py # AI chat interface
├── pushToChromaDB.py # Vector DB operations
├── fetchFromChromaDB.py # Vector DB queries
├── main.py # Core orchestration
├── requirements.txt # Python dependencies
├── Dockerfile # Container configuration
└── formats/ # Output directory
└── codebase.json # Analysis results
The included Dockerfile provides a lightweight, production-ready container:
# Creating from Python 3.10 image
FROM python:3.10
WORKDIR /app
COPY . .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Expose the port
EXPOSE 8000
# Run FastAPI using Uvicorn
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8000"]
This project is licensed under the MIT License - see the LICENSE file for details.
We welcome contributions! Please feel free to submit a Pull Request.