# ChefSystem - AI Prompt Template Manager A desktop application for managing and organizing AI prompt templates with output tracking. ![License](https://img.shields.io/badge/license-Personal%20Use-blue) ![Python](https://img.shields.io/badge/python-3.10%2B-blue) ![PyQt6](https://img.shields.io/badge/PyQt6-6.6.0%2B-green) ## 📋 Table of Contents - [Overview](#overview) - [Features](#features) - [Installation](#installation) - [Usage](#usage) - [Keyboard Shortcuts](#keyboard-shortcuts) - [Examples](#examples) - [Troubleshooting](#troubleshooting) - [Development](#development) - [Architecture](#architecture) - [License](#license) ## 🎯 Overview ChefSystem helps you manage AI prompt templates (called "recipes") and track their generated outputs. Perfect for users who work frequently with AI tools and want to organize and reuse their best prompts. **Current Phase**: Manual workflow (copy/paste) **Future Phases**: Direct API integration with Anthropic Claude ## ✨ Features ### Core Functionality - ✅ **Recipe Management**: Create, edit, delete, and organize prompt templates - ✅ **Search & Filter**: Find recipes by name, description, notes, or tags - ✅ **Tag System**: Categorize recipes with comma-separated tags - ✅ **Output Tracking**: Save and organize output files for each recipe - ✅ **Clipboard Integration**: One-click copy of prompts - ✅ **File Organization**: Automatic directory structure (outputs/recipe_{id}/) ### User Experience - ✅ **Keyboard Shortcuts**: Fast navigation with Ctrl+N, Ctrl+E, Ctrl+C, Delete - ✅ **Tooltips**: Helpful hints on all buttons - ✅ **Status Bar**: Real-time feedback on operations - ✅ **Window Geometry**: Remembers size and position between sessions - ✅ **Resizable Panels**: Adjust recipe list and details panel split ## 🚀 Installation ### Quick Start (Recommended) ```bash # Clone or navigate to the project directory cd /mnt/ssd/data/python-lab/ChefSystem # Run the setup script ./setup.sh # Activate virtual environment source venv/bin/activate # Launch the application python src/main.py ``` ### Manual Installation #### Prerequisites - Python 3.10 or higher - pip (Python package installer) #### Steps 1. **Create virtual environment** ```bash python3 -m venv venv ``` 2. **Activate virtual environment** ```bash source venv/bin/activate ``` 3. **Install dependencies** ```bash pip install -r requirements.txt ``` 4. **Initialize database** ```bash PYTHONPATH=. python3 -c "from src.database.db_manager import DatabaseManager; db = DatabaseManager('database/chef.db'); db.init_database(); db.close()" ``` 5. **(Optional) Create test recipes** ```bash python create_test_recipes.py ``` ## 📖 Usage ### Starting the Application ```bash # Activate virtual environment (if not already active) source venv/bin/activate # Run the application python src/main.py ``` ### Basic Workflow 1. **Create a Recipe** - Click "New Recipe" (or press `Ctrl+N`) - Enter name (required, must be unique) - Add tags (comma-separated, e.g., `python,code-review,quality`) - Write description (brief overview) - Enter prompt text (required) - Add notes (optional usage tips) - Click "Save" 2. **Search and Filter** - Use search box to find recipes by name, description, or notes - Use tag filter dropdown to filter by specific tags - Combine search and tag filter for precise results 3. **Use a Prompt** - Select recipe from list - Click "Copy Prompt" (or press `Ctrl+C`) - Paste into your AI tool - Generate output 4. **Track Outputs** - Click "Manage Outputs" (or press `Ctrl+O`) - Click "Add Output" - Select the output file from your computer - Add execution notes (optional) - File is automatically copied to `outputs/recipe_{id}/` 5. **Organize and Maintain** - Edit recipes with `Ctrl+E` - Delete recipes with `Delete` key - Double-click outputs to open them ## ⌨️ Keyboard Shortcuts | Shortcut | Action | |----------|--------| | `Ctrl+N` | Create new recipe | | `Ctrl+E` | Edit selected recipe | | `Ctrl+C` | Copy prompt to clipboard | | `Ctrl+O` | Manage outputs for selected recipe | | `Delete` | Delete selected recipe | | `Tab` | Navigate between form fields | | `Enter` | Confirm dialogs | | `Esc` | Cancel dialogs | ## 💡 Examples ### Example 1: Code Review Recipe **Name**: Python Code Review Prompt **Tags**: `python,code-review,quality` **Description**: A comprehensive code review prompt for Python code **Prompt Text**: ``` Please review the following Python code for: 1. Code quality and PEP 8 compliance 2. Potential bugs or edge cases 3. Performance improvements 4. Security vulnerabilities 5. Best practices and idioms [PASTE CODE HERE] Provide specific, actionable feedback with code examples where applicable. ``` ### Example 2: Documentation Writer **Name**: Technical Documentation Writer **Tags**: `documentation,technical-writing,tutorial` **Description**: Generate structured technical documentation **Prompt Text**: ``` Create comprehensive technical documentation for the following code/feature: [PASTE CODE OR DESCRIPTION HERE] Include: - Overview and purpose - Installation/setup instructions - Usage examples with code snippets - API reference (if applicable) - Common troubleshooting scenarios - Best practices Format as markdown. ``` ### Example 3: SQL Optimizer **Name**: SQL Query Optimizer **Tags**: `sql,database,optimization,performance` **Description**: Optimize SQL queries for better performance **Prompt Text**: ``` Analyze and optimize this SQL query: [PASTE SQL QUERY HERE] Provide: 1. Performance analysis 2. Optimized version with explanation 3. Index recommendations 4. Query execution plan insights 5. Estimated performance improvement ``` ## 🔧 Troubleshooting ### Application won't start **Problem**: `ModuleNotFoundError: No module named 'PyQt6'` **Solution**: Make sure virtual environment is activated and dependencies are installed: ```bash source venv/bin/activate pip install -r requirements.txt ``` ### Database errors **Problem**: `sqlite3.OperationalError: database is locked` **Solution**: Close any other instances of ChefSystem and try again. **Problem**: `sqlite3.IntegrityError: UNIQUE constraint failed` **Solution**: Recipe names must be unique. Choose a different name. ### File operations fail **Problem**: Cannot open output files **Solution**: Ensure `xdg-open` is installed (Linux): ```bash sudo apt-get install xdg-utils ``` ### Window geometry issues **Problem**: Window appears off-screen **Solution**: Delete settings and restart: ```bash rm -rf ~/.config/QtProject.conf ``` ### Search not working **Problem**: Search doesn't find recipes **Solution**: Search is case-insensitive and searches name, description, and notes. Verify the text exists in one of these fields. ## 🛠️ Development ### Running Tests ```bash # All pytest tests (32 tests) pytest tests/ -v # Specific test file pytest tests/test_database.py -v # Search and filter tests python test_search_filter.py # CRUD tests python test_crud.py # Output management tests python test_output_management.py ``` ### Project Structure ``` ChefSystem/ ├── src/ │ ├── main.py # Application entry point │ ├── database/ │ │ ├── db_manager.py # Database connection (singleton) │ │ └── models.py # Recipe and Output models │ ├── ui/ │ │ ├── main_window.py # Main application window │ │ ├── recipe_editor.py # Recipe create/edit dialog │ │ └── output_manager.py # Output management dialog │ ├── services/ │ │ ├── recipe_service.py # Recipe business logic │ │ └── output_service.py # Output business logic │ └── utils/ │ └── file_utils.py # File operations ├── config/ │ └── settings.json # Application configuration ├── database/ │ └── chef.db # SQLite database ├── outputs/ │ └── recipe_{id}/ # Output files by recipe ├── tests/ │ └── test_database.py # Comprehensive database tests ├── setup.sh # Automated setup script ├── requirements.txt # Python dependencies └── README.md # This file ``` ### Code Style - **PEP 8**: All code follows PEP 8 guidelines - **Type Hints**: Complete type annotations on all functions - **Docstrings**: Google-style docstrings for all public methods - **Logging**: Comprehensive logging at INFO/DEBUG/ERROR levels - **Error Handling**: Try/except with user-friendly error messages ### Adding New Features 1. Plan the feature (database changes, UI changes, service layer) 2. Update models if needed (src/database/models.py) 3. Add service methods (src/services/) 4. Create/update UI components (src/ui/) 5. Add comprehensive tests 6. Update documentation ## 🏗️ Architecture ### Layered Architecture ``` ┌─────────────────────────────────────────┐ │ UI Layer (PyQt6) │ │ main_window.py, recipe_editor.py, etc. │ ├─────────────────────────────────────────┤ │ Service Layer │ │ recipe_service.py, output_service.py │ ├─────────────────────────────────────────┤ │ Data Layer │ │ db_manager.py, models.py │ ├─────────────────────────────────────────┤ │ Database (SQLite) │ │ chef.db │ └─────────────────────────────────────────┘ ``` ### Design Patterns - **Singleton**: DatabaseManager ensures single database connection - **MVC-like**: Separation of UI, business logic, and data - **Service Layer**: Clean API between UI and data access - **Repository Pattern**: Models handle their own CRUD operations ### Database Schema #### recipes Table ```sql CREATE TABLE recipes ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL UNIQUE, prompt_text TEXT NOT NULL, tags TEXT, description TEXT, notes TEXT, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); ``` #### outputs Table ```sql CREATE TABLE outputs ( id INTEGER PRIMARY KEY AUTOINCREMENT, recipe_id INTEGER NOT NULL, filename TEXT NOT NULL, filepath TEXT NOT NULL, file_type TEXT, file_size INTEGER, execution_notes TEXT, generated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (recipe_id) REFERENCES recipes(id) ON DELETE CASCADE ); ``` ## 📚 Additional Documentation - **PROJECT_STATUS.md**: Detailed milestone progress and technical decisions - **Bootstrap.md**: Complete project specifications and requirements - **Test files**: test_crud.py, test_search_filter.py, test_output_management.py ## 🔮 Future Enhancements (Phase 2+) - Direct Anthropic Claude API integration - Automated prompt execution - Prompt version control - Recipe templates with placeholders - Export/import recipes (JSON, CSV) - Statistics and usage analytics - Multi-user support - Cloud sync ## 📄 License This project is for personal use. ## 👤 Author Developed with assistance from Claude AI (Anthropic). ## 🙏 Acknowledgments - PyQt6 for the excellent GUI framework - SQLite for reliable data storage - The Python community for amazing tools --- **Version**: 0.1.0 **Status**: Phase 1 Complete ✅ **Last Updated**: 2025-12-08