Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ak3847/codebase-analyzer

A python-script to analyze your GitHub repository via ChatGPT LLM for code improvements, bug fixes etc.
https://github.com/ak3847/codebase-analyzer

chatgpt chatgpt-api github-automation llm

Last synced: about 2 months ago
JSON representation

A python-script to analyze your GitHub repository via ChatGPT LLM for code improvements, bug fixes etc.

Awesome Lists containing this project

README

        

# Codebase-Analyzer 🤖
A python-script to analyze your github repository via ChatGPT LLM for code improvements,bug fixes etc.
- [How to use?](https://github.com/AK3847/Codebase-Analyzer/edit/main/README.md#how-to-use)
- [How it works?](https://github.com/AK3847/Codebase-Analyzer/tree/main#how-it-works)
- [Python Modules used](https://github.com/AK3847/Codebase-Analyzer/tree/main?tab=readme-ov-file#python-modules-used)
## How to use? 🚀
- First clone or download & unzip this repository.

```terminal
git clone https://github.com/AK3847/Codebase-Analyzer.git
```
- Navgiate to `Codebase-Analyzer` folder and run the following command to install all the python module requirements:
```terminal
pip install -r requirements
```
- Then run the following command in the terminal to start the script:

```terminal
python main.py
```
- You will get an ouput like below in the terminal:

![Screenshot 2024-01-09 023242](https://github.com/AK3847/Codebase-Analyzer/assets/94222544/7310c561-f2d8-4397-83bc-06fd8728edea)


- Kindly provide a _GITHUB Authorization Token_ ( you can get one from [here](https://github.com/settings/tokens) )

- Next chose either one of the option :

![image](https://github.com/AK3847/Codebase-Analyzer/assets/94222544/779e8e3b-6d69-49f4-9dbe-f06302c091fa)


- Now the script will download all the files from repository in the `repo-downloads` folder

![image](https://github.com/AK3847/Codebase-Analyzer/assets/94222544/56a675ff-c045-4492-ac4a-9e336a7d08c9)


- Next provide _OpenAI API Key_ ( register here to start with initial free credits):

![Screenshot 2024-01-09 024135](https://github.com/AK3847/Codebase-Analyzer/assets/94222544/a1f12ace-8ea2-4c4d-a0ef-2cf9bee29c38)

- Now the LLM will start to analyze code files one-by-one and output is shown in terminal:

![image](https://github.com/AK3847/Codebase-Analyzer/assets/94222544/bd5c1ef3-49e8-472a-a1e5-49b1083ea18c)

- At last all the suggestions will be stored in `suggestions.txt` file:

![image](https://github.com/AK3847/Codebase-Analyzer/assets/94222544/c2f84f8d-7d89-4cc9-ad1b-07880fc41a43)

## How it works? ✨
- First using the provided Github authorization token we fetch the repository using `Github` module of python, this is done in github_fetch.py
- Next we download all the files such as c,c++,java,python,html,css etc from the repository into our `repo-downlaods` local folder.
> The file extensions to be selected can be modified via utils.py

> In case the folder is not empty, the tool automatically clears all the folder content to avoid file-mismatch.
- We connect with the Eden AI which in turn provides us free access to ChatGPT 3.5 turbo via API.
- Then all files are sent to LLM one by one via `requests` module of python with a `prompt`, this is done in analyze_codeabase.py
> The prompt can be modified via utils.py
- All suggestions are stored in `suggestions.txt` file for later use.

## Python Modules used: 🐍
```
os
json
requets
shutil
json
re
openai
github
rich
pwinput
tiktoken
```
- _All of this are imported in_ `utils.py`

## Contribution 🤝
- Any and all contribution are welcome for this project, you can raise issue with headings as:
1. New Feature Suggestion
1. Bug Fix
1. Code quality/efficiency Improvement
1. Other..
- Features/Functionalities to be added soon:
- By pass the token-limit (_4096 right now_) to analyze larger code files ;)
- Improve the UI/UX in terminal
- Storing the API-Key more securely

_(Raise an issue if you can help me achieve above features ^\_^ )_