|
| 1 | +# Copilot Instructions |
| 2 | + |
| 3 | +This file provides guidance to GitHub Copilot when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +**pyplots** is an AI-powered platform for Python data visualization that automatically discovers, generates, tests, and maintains plotting examples. The platform is specification-driven: every plot starts as a library-agnostic Markdown spec, then AI generates implementations for all supported libraries. |
| 8 | + |
| 9 | +**Supported Libraries** (8 total): |
| 10 | +- matplotlib, seaborn, plotly, bokeh, altair, plotnine, pygal, highcharts |
| 11 | + |
| 12 | +**Core Principle**: Community proposes plot ideas via GitHub Issues → AI generates code → Multi-LLM quality checks → Deployed. |
| 13 | + |
| 14 | +## Development Setup |
| 15 | + |
| 16 | +```bash |
| 17 | +# Install dependencies (uses uv - fast Python package manager) |
| 18 | +uv sync --all-extras |
| 19 | + |
| 20 | +# Run all tests |
| 21 | +uv run pytest |
| 22 | + |
| 23 | +# Check code formatting and linting |
| 24 | +uv run ruff check . |
| 25 | + |
| 26 | +# Auto-fix issues |
| 27 | +uv run ruff check . --fix |
| 28 | + |
| 29 | +# Format code |
| 30 | +uv run ruff format . |
| 31 | +``` |
| 32 | + |
| 33 | +### Frontend Development |
| 34 | + |
| 35 | +```bash |
| 36 | +cd app |
| 37 | +yarn install |
| 38 | +yarn dev # Development server |
| 39 | +yarn build # Production build |
| 40 | +``` |
| 41 | + |
| 42 | +## Architecture |
| 43 | + |
| 44 | +### Specification-First Design |
| 45 | + |
| 46 | +Every plot follows this flow: |
| 47 | +``` |
| 48 | +specs/{spec-id}.md → plots/{library}/{plot-type}/{spec-id}/default.py |
| 49 | +``` |
| 50 | + |
| 51 | +Example: |
| 52 | +``` |
| 53 | +specs/scatter-basic.md → plots/matplotlib/scatter/scatter-basic/default.py |
| 54 | + → plots/seaborn/scatterplot/scatter-basic/default.py |
| 55 | + → plots/plotly/scatter/scatter-basic/default.py |
| 56 | + → (and 5 more libraries...) |
| 57 | +``` |
| 58 | + |
| 59 | +### Spec ID Naming Convention |
| 60 | + |
| 61 | +**Format:** `{plot-type}-{variant}-{modifier}` (all lowercase, hyphens only) |
| 62 | + |
| 63 | +Examples: `scatter-basic`, `scatter-color-mapped`, `bar-grouped-horizontal`, `heatmap-correlation` |
| 64 | + |
| 65 | +### Directory Structure |
| 66 | + |
| 67 | +- **`specs/`**: Library-agnostic plot specifications (Markdown) |
| 68 | +- **`plots/{library}/{plot_type}/{spec_id}/{variant}.py`**: Library-specific implementations |
| 69 | +- **`core/`**: Shared business logic (database, repositories, config) |
| 70 | +- **`api/`**: FastAPI backend (routers, schemas, dependencies) |
| 71 | +- **`app/`**: Next.js frontend (React + TypeScript + Vite + MUI) |
| 72 | +- **`rules/`**: Versioned rules for AI code generation and quality evaluation |
| 73 | +- **`tests/unit/`**: Unit tests mirroring source structure |
| 74 | +- **`docs/`**: Architecture and workflow documentation |
| 75 | + |
| 76 | +## Code Standards |
| 77 | + |
| 78 | +### Python Style |
| 79 | + |
| 80 | +- **Linter/Formatter**: Ruff (enforces PEP 8) |
| 81 | +- **Line Length**: 120 characters |
| 82 | +- **Type Hints**: Required for all functions |
| 83 | +- **Docstrings**: Google style for all public functions |
| 84 | +- **Import Order**: Standard library → Third-party → Local |
| 85 | + |
| 86 | +### Testing Standards |
| 87 | + |
| 88 | +- **Coverage Target**: 90%+ |
| 89 | +- **Test Structure**: Mirror source structure in `tests/unit/` |
| 90 | +- **Naming**: `test_{what_it_does}` |
| 91 | +- **Fixtures**: Use pytest fixtures in `tests/conftest.py` |
| 92 | + |
| 93 | +### Plot Implementation Template |
| 94 | + |
| 95 | +Every implementation file should: |
| 96 | +1. Start with docstring describing spec ID, library, variant |
| 97 | +2. Define `create_plot()` function with type hints |
| 98 | +3. Validate inputs first (empty data, missing columns) |
| 99 | +4. Use sensible defaults (`figsize=(10, 6)`, `alpha=0.8`) |
| 100 | +5. Include grid for readability |
| 101 | +6. Return the Figure object |
| 102 | + |
| 103 | +### Anti-Patterns to Avoid |
| 104 | + |
| 105 | +- No `preview.png` files in repository (use GCS) |
| 106 | +- No `quality_report.json` files (use GitHub Issues) |
| 107 | +- No hardcoded API keys (use environment variables) |
| 108 | + |
| 109 | +## Tech Stack |
| 110 | + |
| 111 | +- **Backend**: FastAPI, SQLAlchemy (async), PostgreSQL, Python 3.10+ |
| 112 | +- **Frontend**: Next.js 14, TypeScript, Tailwind CSS, MUI 7 |
| 113 | +- **Package Manager**: uv (Python), yarn (Node.js) |
| 114 | +- **Linting**: Ruff (Python) |
| 115 | + |
| 116 | +## Acceptance Criteria |
| 117 | + |
| 118 | +Before completing any task: |
| 119 | +1. All tests pass: `uv run pytest` |
| 120 | +2. Code passes linting: `uv run ruff check .` |
| 121 | +3. Code is properly formatted: `uv run ruff format --check .` |
| 122 | +4. Type hints are included for all new functions |
| 123 | +5. Docstrings follow Google style for public functions |
0 commit comments