From 0bfbdfe9790dcd9195be260ad2a2c5c12980aff0 Mon Sep 17 00:00:00 2001 From: William Valentin Date: Wed, 6 Aug 2025 09:56:06 -0700 Subject: [PATCH] feat: Add AI coding guidelines and project overview to documentation --- .github/instructions/copilot.instructions.md | 83 ++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 .github/instructions/copilot.instructions.md diff --git a/.github/instructions/copilot.instructions.md b/.github/instructions/copilot.instructions.md new file mode 100644 index 0000000..00dafdf --- /dev/null +++ b/.github/instructions/copilot.instructions.md @@ -0,0 +1,83 @@ +--- +applyTo: '**' +--- +--- +applyTo: '**' +--- +# AI Coding Guidelines for TheChart Project + +## Project Overview +- **Project Name:** TheChart (Medication Tracker) +- **Purpose:** Desktop application for tracking medications and pathologies. +- **Tech Stack:** Python 3.x, Tkinter, Pandas, modular architecture. +- **Key Features:** + - Add/edit/delete daily medication and pathology entries + - Visual graphs and charts + - Data export + - Keyboard shortcuts + - Theming support + +## Coding Guidelines + +### 1. Code Style +- Follow PEP8 for Python code (indentation, naming, spacing). +- Use type hints for all function signatures and variables where possible. +- Use docstrings for all public methods and classes. +- Prefer f-strings for string formatting. +- Use snake_case for variables/functions, CamelCase for classes. +- Keep lines under 88 characters. +- Use descriptive names for variables and functions to enhance readability. +- Avoid global variables; use class attributes or method parameters instead. +- Use logging for debug/info messages instead of print statements. +- Use .venv/bin/activate.fish as the virtual environment activation script. +- The package manager is uv. +- Use ruff for linting and formatting. + +### 2. Architecture & Structure +- Maintain separation of concerns: UI, data management, and business logic in their respective modules. +- Use manager classes (e.g., DataManager, UIManager, ThemeManager) for encapsulating related functionality. +- UI elements and data columns must be generated dynamically based on current medicines/pathologies. +- New medicines/pathologies should not require changes to main logic—use dynamic lists and keys. + +### 3. Error Handling +- Use try/except for operations that may fail (file I/O, data parsing). +- Show user-friendly error messages via messagebox dialogs. +- Log errors and important actions using the logger. + +### 4. User Experience +- Always update the status bar and provide feedback for user actions. +- Use confirmation dialogs for destructive actions (e.g., deleting entries). +- Support keyboard shortcuts for all major actions. +- Keep the UI responsive and avoid blocking operations in the main thread. + +### 5. Data Handling +- Use Pandas DataFrames for all data manipulation. +- Always check for duplicate dates before adding new entries. +- Store medicine doses as a string (e.g., "time:dose|time:dose") for each medicine. +- Support dynamic addition/removal of medicines and pathologies. + +### 6. Testing & Robustness +- Validate all user input before saving. +- Ensure all UI elements are updated after data changes. +- Use batch operations for updating UI elements (e.g., clearing and repopulating the table). + +### 7. Documentation +- Keep code well-commented and maintain clear docstrings. +- Document any non-obvious logic, especially dynamic UI/data handling. + +### 8. Performance +- Use efficient methods for updating UI elements (e.g., batch delete/insert for Treeview). +- Avoid unnecessary data reloads or UI refreshes. + +## When Generating or Reviewing Code +- Respect the modular structure—add new logic to the appropriate manager or window class. +- Do not hardcode medicine/pathology names—always use dynamic keys from the managers. +- Preserve user feedback (status bar, dialogs) for all actions. +- Maintain keyboard shortcut support for new features. +- Ensure compatibility with the existing UI and data model. +- Write clear, concise, and maintainable code with proper type hints and docstrings. + +--- + +**Summary:** +This project is a modular, extensible Tkinter application for tracking medication and pathology data. Code should be clean, dynamic, user-friendly, and robust, following PEP8 and the architectural patterns already established. All new features or changes should integrate seamlessly with the existing managers and UI paradigms.