π Dual-Mode Directory Structure Generator - Create project structures from images using AI or parse text-based directory trees. Two powerful methods, one seamless experience.
PyStructure is a versatile Python desktop application that offers two distinct modes for generating directory structures:
- π€ AI Mode: Upload directory tree images and let Google Gemini Vision AI recreate the structure
- π Text Mode: Paste text-based directory trees and parse them into real folder structures
Perfect for developers, project managers, and anyone who needs to quickly replicate project structures from documentation, screenshots, or text representations.
- Upload screenshots of directory trees from any source
- Powered by Google Gemini 1.5 Flash for accurate structure recognition
- Supports PNG, JPG, JPEG, BMP, and WebP formats
- Automatically ignores tree-drawing characters and comments
- Paste directory tree text directly into the application
- Intelligent parsing of indented structures
- Supports various tree formats and indentation styles
- Works offline - no API required
- Tabbed Interface: Switch seamlessly between modes
- Real-time Logging: Monitor the creation process step-by-step
- Cross-platform: Works on Windows, macOS, and Linux
- Smart Path Handling: Automatic parent directory creation
- Error Recovery: Comprehensive error handling and user feedback
- Python 3.8 or higher
- For Image Mode: Google Gemini API key (Get one here)
-
Clone the repository
git clone https://github.com/LMLK-seal/PyStructure.git cd PyStructure
-
Install dependencies
# For both modes pip install tkinter # For Image Mode (optional) pip install google-generativeai pillow
-
Run the application
python PyStructure.py
- Switch to "From Image (AI)" tab
- π Enter API Key: Input your Google Gemini API key
- πΈ Select Image: Choose an image containing a directory tree
- π Choose Destination: Select where you want the structure created
βΆοΈ Generate: Click "Generate Structure" and watch the AI work!
- Switch to "From Text" tab
- π Paste Structure: Copy and paste your directory tree text
- π Choose Destination: Select the destination folder
βΆοΈ Generate: Click "Generate Structure" - no API needed!
project/
βββ src/
β βββ main.py
β βββ utils/
β β βββ helpers.py
β βββ models/
β βββ __init__.py
βββ tests/
β βββ test_main.py
β βββ conftest.py
βββ docs/
β βββ README.md
βββ .gitignore
βββ requirements.txt
Both modes create the exact same real directory structure in your chosen destination folder!
- GUI Framework: Tkinter with modern ttk styling
- Threading: Background processing for responsive UI
- Path Handling: Cross-platform compatibility with pathlib
- Error Handling: Graceful degradation and user-friendly messages
- Model: Google Gemini 1.5 Flash Latest
- Vision Processing: PIL (Pillow) for image handling
- Smart Parsing: Ignores visual artifacts and focuses on structure
- Intelligent Indentation: Auto-detects indentation patterns
- Flexible Format Support: Handles various tree drawing styles
- Comment Recognition: Automatically filters out comments
- Robust Error Recovery: Continues processing even with malformed input
# Built-in Python libraries
tkinter (included with Python)
pathlib (included with Python)
threading (included with Python)
google-generativeai>=0.3.0
pillow>=9.0.0
- Image Mode Tab: Clean interface for AI-powered generation
- Text Mode Tab: Simple text area for direct input
- Unified Controls: Shared destination selection and generation controls
- Real-time Logging: Live feedback during structure creation
Contributions are welcome! This project is perfect for adding new features like:
- New Input Formats: Support for JSON, YAML, or XML structure definitions
- Export Options: Save structures as templates
- Batch Processing: Process multiple images or text files
- Custom Templates: Pre-defined project structure templates
This project is licensed under the MIT License - see the LICENSE file for details.
"Libraries for 'From Image' mode not found"
pip install google-generativeai pillow
Note: Text mode will still work without these libraries
"API_KEY_INVALID error"
- Verify your Gemini API key is correct
- Check API key permissions and quota
- Ensure the key is properly entered (no extra spaces)
"The parser did not find any valid paths"
- Check your text formatting and indentation
- Ensure folder names end with
/
- Try using consistent indentation (spaces or tabs, not mixed)
"Permission denied" when creating files
- Ensure the destination folder is writable
- Run with appropriate permissions if needed
- Check if antivirus software is blocking file creation
- Large Structures: For very large directory trees, consider breaking them into smaller chunks
- Image Quality: Use clear, high-contrast images for better AI recognition
- Text Formatting: Consistent indentation improves parsing accuracy
- Standard tree format with
βββ
,βββ
,β
- Simple indented lists
- Mixed indentation styles
- Comments (automatically ignored)
- Auto-indentation: Automatically detects indentation size
- Path Normalization: Converts all paths to forward slashes
- Duplicate Handling: Safely handles existing files/folders
- Google AI for the powerful Gemini Vision API
- Python Community for excellent standard libraries
- Open Source Contributors who help improve this tool
- Tkinter Team for the robust GUI framework
- π Bug Reports: GitHub Issues
- π‘ Feature Requests: GitHub Discussions
- π Show Support: Star this repository if you find it helpful!
β Star this repository if PyStructure helps streamline your development workflow!
Made with β€οΈ by LMLK-seal