Skip to content

StarBlasto/Python-README.mb-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

# 🚀 AI-Powered Project README Generator

![Python 3.x](https://img.shields.io/badge/Python-3.x-blue?logo=python&logoColor=white)
![Gemini API](https://img.shields.io/badge/Powered%20by-Gemini%20API-purple?logo=google&logoColor=white)
![License](https://img.shields.io/badge/License-MIT-green)

## Project Overview

Tired of manually crafting project READMEs, especially for new repositories or evolving codebases? This innovative tool leverages Google's powerful Gemini AI to automatically generate comprehensive and high-quality `README.md` files for your Python projects. Simply point it to your codebase, and let AI distill your project's essence into professional, structured documentation, freeing you to focus on development.

## Key Features

*   **AI-Driven Documentation**: Harnesses the power of Google's Gemini API to analyze your Python codebase and articulate its purpose, features, and structure into a complete `README.md`.
*   **Recursive Project Scanning**: Automatically traverses entire project directories, intelligently identifying and collecting all relevant Python source files.
*   **Contextual Code Aggregation**: Systematically compiles code from multiple files into a coherent context, ensuring the AI has a holistic understanding of your project.
*   **Smart File & Directory Filtering**: Skips irrelevant files (non-`.py`) and common ignored directories (e.g., `.git`, `__pycache__`, dotfiles) to maintain focus on your core logic.
*   **Intuitive User Interface**: Features an `easygui`-powered dialog for effortless selection of your target project directory.
*   **Automated Output**: Generates and saves the `README.md` file directly within your chosen project's root directory.

## Installation & Usage

### Prerequisites

*   **Python 3.8+**: Ensure you have a compatible Python version installed.
*   **Google Gemini API Key**: Obtain one from [Google AI Studio](https://makersuite.google.com/app/apikey).

### Installation

1.  **Clone the repository**:
    ```bash
    git clone https://github.com/your-username/ai-readme-generator.git # Replace with actual repo URL
    cd ai-readme-generator
    ```

2.  **Install dependencies**:
    ```bash
    pip install python-dotenv google-generativeai easygui
    ```

3.  **Set up your Gemini API Key**:
    Create a file named `.env` in the root of this project (where `app.py` is located) and add your API key:
    ```
    AI_KEY="YOUR_GEMINI_API_KEY_HERE"
    ```
    Replace `"YOUR_GEMINI_API_KEY_HERE"` with your actual Gemini API key.

### Usage

1.  **Run the script**:
    ```bash
    python app.py
    ```

2.  **Select your project directory**:
    An `easygui` dialog box will appear. Navigate to and select the root directory of the Python project for which you want to generate a README.

3.  **README Generation**:
    The script will then analyze your project. Upon successful completion, it will print a confirmation message indicating where the `README.md` file has been saved. You'll find the newly generated `README.md` in the root of the project directory you selected.

## Technical Architecture

The `app.py` script orchestrates a straightforward yet powerful workflow:

1.  **Initialization**: It begins by loading the Gemini API key from the `.env` file and initializing the `gemini-2.5-flash` model, ready for AI interaction.
2.  **Directory Selection**: Using the `easygui` library, the user is presented with an intuitive dialog to interactively select the target Python project directory for documentation.
3.  **Code Traversal & Collection**: The script performs a recursive walk through the selected directory using `os.walk()`. During this traversal, it intelligently filters out non-Python files and common irrelevant directories (like `.git` or `__pycache__`). All identified Python file contents are then concatenated into a single string, prefixed with `"-- File: filename --"` markers. This structured `codeCollection` forms a comprehensive context representing the entire codebase.
4.  **AI Prompt Construction**: A detailed instruction prompt, explicitly asking for a GitHub README and embedding the collected codebase, is formulated and sent to the configured Gemini model.
5.  **README Output**: The AI's generated response (the complete README content) is then written to a `README.md` file. This file is placed directly in the root of the user-selected project directory, concluding the automation process. Robust error handling is included to catch potential issues during API communication or file operations.

## Future Roadmap

*   **Multi-Language Support**: Extend file scanning and AI prompting to support the analysis and documentation of projects written in other popular programming languages (e.g., JavaScript, Java, Go, C++).
*   **Customizable Output Options**: Introduce command-line arguments or a configuration file to allow users to specify README sections to include/exclude, target output filename, desired tone, or even provide custom prompts for the AI.
*   **Enhanced Token Management**: Implement more sophisticated token estimation and chunking strategies to handle extremely large codebases efficiently, ensuring generation stays within API rate limits and optimizing cost.
*   **Advanced CLI & GUI**: Develop a more robust Command Line Interface (CLI) for headless operation and an advanced Graphical User Interface (GUI) for granular control over file selection, generation parameters, and output previews.
*   **Correct Output Extension**: Ensure the output file consistently uses the `.md` extension instead of `.mb` for standard Markdown compatibility.

## Contributing

Contributions are welcome! Please feel free to open an issue to report bugs or suggest features, or submit a pull request with your enhancements.

About

A small project experimenting with use of google.generativeai mixed with file manipulation. The system aims to create a README.mb based on the file you selected and the python code within. Currently only runs for python files.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages