Skip to main content

AI-Powered Code Diagram Generator - MCP Server

Project description

๐Ÿ”ฎ DiageniX - AI-Powered Code Diagram Generator

Your codebase, visualized instantly

DiageniX is a production-ready MCP (Model Context Protocol) server that analyzes local codebases and generates intelligent diagrams on-demand using Google Gemini Pro API.

Python 3.11+ License: MIT MCP

โœจ Features

  • ๐ŸŽฏ 6 Diagram Types: Flowcharts, Class Diagrams, Database Schemas, API Maps, Architecture, and Project Structure
  • ๐Ÿค– AI-Powered: Uses Google Gemini Pro for intelligent diagram generation
  • ๐Ÿ” Multi-Language Support: Python, JavaScript, TypeScript, and more
  • ๐Ÿ“Š Mermaid Output: Industry-standard diagram syntax
  • ๐Ÿš€ Fast Analysis: Optimized code scanning and caching
  • ๐Ÿ”Œ MCP Compatible: Works with Claude Desktop, VS Code, and other MCP clients
  • ๐ŸŽจ Smart Detection: Automatically detects frameworks, ORMs, and tech stacks

๐Ÿ“‹ Table of Contents

๐Ÿš€ Installation

Prerequisites

  • Python 3.11 or higher
  • Google Gemini API key (Get one here)

Install from Source

# Clone the repository
git clone https://github.com/diagenix/diagenix.git
cd diagenix

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -e .

# Set up environment variables
cp .env.example .env
# Edit .env and add your GEMINI_API_KEY

Install from PyPI (Coming Soon)

pip install diagenix

โšก Quick Start

1. Set Up API Key

export GEMINI_API_KEY="your_api_key_here"

2. Run the Server

python -m diagenix

3. Use with Claude Desktop

Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "diagenix": {
      "command": "python",
      "args": ["-m", "diagenix"],
      "env": {
        "GEMINI_API_KEY": "your_api_key_here"
      }
    }
  }
}

Restart Claude Desktop and start using DiageniX!

๐Ÿ› ๏ธ Available Tools

1. analyze_project

Analyzes project structure and detects technology stack.

Parameters:

  • project_path (required): Absolute path to project root

Example:

Analyze the project at /Users/username/my-project

Output:

  • Project overview with file statistics
  • Detected languages and frameworks
  • Technology stack summary
  • Project structure diagram

2. generate_flowchart

Generates a flowchart for a specific function, class, or process.

Parameters:

  • project_path (required): Absolute path to project root
  • target (required): Function name, class name, or process description
  • file_path (optional): Specific file to analyze

Example:

Generate a flowchart for the 'process_payment' function in /Users/username/my-project

Output:

  • Mermaid flowchart showing logic flow
  • Decision points and branches
  • Function calls and operations

3. generate_database_schema

Generates database schema diagram from models/migrations.

Parameters:

  • project_path (required): Absolute path to project root
  • orm_type (optional): ORM framework (auto, sqlalchemy, django, prisma, sequelize)

Example:

Generate database schema for /Users/username/my-project

Output:

  • ER diagram with tables and relationships
  • Primary and foreign keys
  • Column types and constraints

4. generate_api_diagram

Maps all API endpoints and their relationships.

Parameters:

  • project_path (required): Absolute path to project root
  • framework (optional): Web framework (auto, fastapi, flask, express, django)

Example:

Generate API diagram for /Users/username/my-api

Output:

  • API endpoint map with HTTP methods
  • Route groupings and dependencies
  • Request/response flows

5. generate_architecture

Creates high-level system architecture diagram.

Parameters:

  • project_path (required): Absolute path to project root
  • diagram_type (optional): Architecture style (c4, component, deployment)

Example:

Generate component architecture for /Users/username/my-project

Output:

  • System component diagram
  • Service interactions
  • Technology stack per component

6. generate_class_diagram

Generates UML class diagram for OOP code.

Parameters:

  • project_path (required): Absolute path to project root
  • module_path (optional): Specific module/package to diagram

Example:

Generate class diagram for /Users/username/my-project/src/models

Output:

  • UML class diagram
  • Inheritance and composition relationships
  • Methods and attributes

โš™๏ธ Configuration

Environment Variables

Create a .env file in your project root:

# Required
GEMINI_API_KEY=your_api_key_here

# Optional
MAX_FILE_SIZE_MB=10
CACHE_ENABLED=true
LOG_LEVEL=INFO

YAML Configuration

Edit config/config.yaml for advanced settings:

analysis:
  max_file_size_mb: 10
  ignore_directories:
    - node_modules
    - venv
    - __pycache__

diagrams:
  default_theme: "default"
  max_nodes: 100

llm:
  model: "gemini-pro"
  temperature: 0.3
  max_tokens: 4096

๐Ÿ’ก Usage Examples

Example 1: Analyze a Django Project

I want to understand the structure of my Django project at /Users/me/django-blog

DiageniX will:

  1. Scan the project structure
  2. Detect Django framework and dependencies
  3. Generate a project overview diagram
  4. List all models, views, and URLs

Example 2: Generate Flowchart for a Function

Create a flowchart for the 'authenticate_user' function in /Users/me/auth-service

DiageniX will:

  1. Find the function in the codebase
  2. Analyze the logic flow
  3. Generate a Mermaid flowchart
  4. Show decision points and error handling

Example 3: Database Schema from SQLAlchemy Models

Generate database schema for /Users/me/flask-app using SQLAlchemy

DiageniX will:

  1. Find all SQLAlchemy models
  2. Extract table definitions and relationships
  3. Generate an ER diagram
  4. Show foreign keys and constraints

๐Ÿ”Œ IDE Integration

Claude Desktop

See Quick Start for configuration.

VS Code

Install the DiageniX extension (coming soon) or use the MCP extension with this config:

{
  "diagenix.mcpServerPath": "python -m diagenix",
  "diagenix.autoAnalyze": true,
  "diagenix.geminiApiKey": "${env:GEMINI_API_KEY}"
}

Bob IDE

Add to your Bob IDE MCP configuration:

{
  "mcp": {
    "servers": {
      "diagenix": {
        "command": "python",
        "args": ["-m", "diagenix"],
        "env": {
          "GEMINI_API_KEY": "your_api_key_here"
        }
      }
    }
  }
}

๐Ÿงช Development

Running Tests

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run with coverage
pytest --cov=diagenix --cov-report=html

Code Quality

# Format code
black src/

# Lint
ruff check src/

# Type checking
mypy src/

Project Structure

diagenix/
โ”œโ”€โ”€ src/diagenix/
โ”‚   โ”œโ”€โ”€ server.py           # MCP server
โ”‚   โ”œโ”€โ”€ tools/              # MCP tool implementations
โ”‚   โ”œโ”€โ”€ analyzers/          # Code analyzers
โ”‚   โ”œโ”€โ”€ llm/                # Gemini integration
โ”‚   โ””โ”€โ”€ utils/              # Utilities
โ”œโ”€โ”€ config/                 # Configuration files
โ”œโ”€โ”€ examples/               # Example configs
โ”œโ”€โ”€ tests/                  # Test suite
โ””โ”€โ”€ README.md

๐Ÿ› Troubleshooting

Common Issues

Issue: "GEMINI_API_KEY not found"

# Solution: Set the environment variable
export GEMINI_API_KEY="your_key_here"

Issue: "No module named 'mcp'"

# Solution: Install dependencies
pip install -e .

Issue: "Permission denied"

# Solution: Check file permissions
chmod +x venv/bin/python

Debug Mode

Enable debug logging:

export LOG_LEVEL=DEBUG
python -m diagenix

๐Ÿค Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 style guide
  • Add tests for new features
  • Update documentation
  • Use type hints
  • Write clear commit messages

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support


Made with โค๏ธ by the DiageniX Team

Your codebase, visualized instantly ๐Ÿ”ฎ

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diagenix-0.1.0.tar.gz (39.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

diagenix-0.1.0-py3-none-any.whl (46.2 kB view details)

Uploaded Python 3

File details

Details for the file diagenix-0.1.0.tar.gz.

File metadata

  • Download URL: diagenix-0.1.0.tar.gz
  • Upload date:
  • Size: 39.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for diagenix-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6b2717d8ab18daa9e4112f8ab916d470d577c633bbebcb5af7ee65aabd365a5b
MD5 ab2af64f8d688e53f15cc61f94f42604
BLAKE2b-256 5936c14d227dc5e56a92e97d008b3bc6e932487d419f8b67c2e5e283b2db6145

See more details on using hashes here.

File details

Details for the file diagenix-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: diagenix-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 46.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for diagenix-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 44f9023c332f015e5fcc039136193714645358ae266bc082e64dd15507655a06
MD5 069a146c47b1805c69cae51d33e91222
BLAKE2b-256 553df53183af7ff67e9334f054275ce3588e1e70384eb782db1296f0edd41529

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page