How shubhs-singh/code---flowchart works
Project Type and Purpose
• This is a web application built with Streamlit that analyzes Python code and generates visual flowcharts.
• It uses Google Gemini (Gemini 1.5 Pro) for code logic analysis, produces a structured JSON flowchart, and visualizes it using Graphviz.
• The application supports features like file upload, sample code demonstration, and downloading DOT files.
Analyzing the File Structure
• The top-level files include:
• README.md – Contains project overview, features, installation, and usage instructions.
• main.py – Likely the entry point for the Streamlit web application, containing both UI and backend logic.
• requirements.txt – Lists dependencies such as Streamlit, Graphviz, python-dotenv, and possibly libraries for the Gemini API integration.
• A single file (main.py) as the entry point means the project is relatively small, but the architecture should still clearly separate concerns despite the minimal file structure.
Key Components to Highlight
a. Frontend/UI Layer:
• Streamlit Interface: Manages user interactions.
• File Upload Widget: Accepts Python files or sample code.
• Areas: For rendering the JSON output and flowchart visualizations.
b. Backend/Processing Layer:
• Python Code Analyzer: Parses the uploaded or provided Python code to identify functions, loops, conditionals, and data flow.
• Gemini API Integration: Sends code to Google Gemini for analysis and receives a JSON-based flowchart.
• Flowchart Generator: Converts the analysis results into a DOT file and leverages Graphviz for visual rendering.
c. Configuration & Environment Management:
• Use of python-dotenv: Loads sensitive configurations such as the GEMINI_API_KEY from a .env file.
d. External Services/Dependencies:
• Google Gemini: Acts as the AI model for in-depth code analysis.
• Graphviz: Handles visualization and generation of flowchart graphics.
Relationships and Interactions
• The user interacts with the frontend (Streamlit UI) to either upload Python code or use sample inputs.
• On submission, the code is sent to a backend process in main.py where initial parsing occurs.
• The parsed code is forwarded to Google Gemini’s API to get a detailed, structured analysis.
• The resulting JSON is then processed to generate a corresponding DOT description.
• Graphviz is used to render the visual flowchart from the DOT file.