|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is `supabase-py`, a Python monorepo containing all official Supabase client libraries for Python. The repository uses a workspace structure managed by `uv` with the following packages: |
| 8 | + |
| 9 | +- `supabase` - Main Supabase client library |
| 10 | +- `realtime` - Realtime subscriptions client |
| 11 | +- `supabase_functions` - Edge Functions client |
| 12 | +- `storage3` - Storage client |
| 13 | +- `postgrest` - PostgREST client |
| 14 | +- `supabase_auth` - Authentication client |
| 15 | + |
| 16 | +## Development Setup |
| 17 | + |
| 18 | +### Prerequisites |
| 19 | +- `uv` for Python project management |
| 20 | +- `make` for command running |
| 21 | +- `docker` for test containers (postgrest, auth) |
| 22 | +- `supabase-cli` for test containers (storage, realtime) |
| 23 | + |
| 24 | +### Environment Setup |
| 25 | +```bash |
| 26 | +# Create and activate virtual environment |
| 27 | +uv venv supabase-py |
| 28 | +source supabase-py/bin/activate |
| 29 | +uv sync |
| 30 | +``` |
| 31 | + |
| 32 | +### Alternative: Nix |
| 33 | +If you have Nix installed, use the development shell: |
| 34 | +```bash |
| 35 | +nix develop |
| 36 | +``` |
| 37 | + |
| 38 | +## Common Commands |
| 39 | + |
| 40 | +### Testing |
| 41 | +```bash |
| 42 | +# Run all tests for all packages |
| 43 | +make ci |
| 44 | + |
| 45 | +# Run tests in parallel (faster but messy output) |
| 46 | +make ci -j |
| 47 | + |
| 48 | +# Run tests for specific package |
| 49 | +make realtime.tests |
| 50 | +make supabase.tests |
| 51 | +make storage.tests |
| 52 | +# etc. |
| 53 | +``` |
| 54 | + |
| 55 | +### Linting and Formatting |
| 56 | +```bash |
| 57 | +# Run pre-commit hooks (ruff lint/format, trailing whitespace, etc.) |
| 58 | +make pre-commit |
| 59 | + |
| 60 | +# Run type checking for specific package |
| 61 | +make realtime.mypy |
| 62 | +``` |
| 63 | + |
| 64 | +### Infrastructure Management |
| 65 | +```bash |
| 66 | +# Start all test containers |
| 67 | +make start-infra |
| 68 | + |
| 69 | +# Stop all test containers |
| 70 | +make stop-infra |
| 71 | +``` |
| 72 | + |
| 73 | +### Cleanup |
| 74 | +```bash |
| 75 | +# Clean all cache files and coverage reports |
| 76 | +make clean |
| 77 | + |
| 78 | +# Clean specific package |
| 79 | +make realtime.clean |
| 80 | +``` |
| 81 | + |
| 82 | +### Building |
| 83 | +```bash |
| 84 | +# Build all packages |
| 85 | +make publish |
| 86 | + |
| 87 | +# Build specific package |
| 88 | +make supabase.build |
| 89 | +``` |
| 90 | + |
| 91 | +## Architecture |
| 92 | + |
| 93 | +### Monorepo Structure |
| 94 | +The codebase uses a `uv` workspace with each package in `src/` having its own: |
| 95 | +- `pyproject.toml` - Package configuration and dependencies |
| 96 | +- `Makefile` - Package-specific commands |
| 97 | +- `README.md` - Package documentation |
| 98 | + |
| 99 | +### Async/Sync Pattern |
| 100 | +The `supabase` package maintains both async and sync versions: |
| 101 | +- `src/supabase/_async/` - Async implementations |
| 102 | +- `src/supabase/_sync/` - Auto-generated sync versions using `unasync` |
| 103 | + |
| 104 | +The sync versions are generated via: |
| 105 | +```bash |
| 106 | +make supabase.unasync |
| 107 | +make supabase.build-sync |
| 108 | +``` |
| 109 | + |
| 110 | +### Testing Infrastructure |
| 111 | +- Tests require containers for services (PostgreSQL, Supabase services) |
| 112 | +- Each package with external dependencies has `start-infra`/`stop-infra` targets |
| 113 | +- Uses `pytest` with coverage reporting |
| 114 | +- Type checking with `mypy` where applicable |
| 115 | + |
| 116 | +### Code Quality |
| 117 | +- `ruff` for linting and formatting |
| 118 | +- `pre-commit` hooks for automated checks |
| 119 | +- `commitizen` for conventional commits |
| 120 | +- Coverage reporting with `pytest-cov` |
| 121 | + |
| 122 | +## Package-Specific Notes |
| 123 | + |
| 124 | +### Realtime |
| 125 | +- Requires Supabase CLI containers for testing |
| 126 | +- Has mypy type checking |
| 127 | + |
| 128 | +### Storage |
| 129 | +- Requires Supabase CLI containers for testing |
| 130 | + |
| 131 | +### Auth & PostgREST |
| 132 | +- Require Docker containers for testing |
| 133 | + |
| 134 | +### Functions |
| 135 | +- Standalone package with minimal infrastructure needs |
| 136 | + |
| 137 | +### Supabase (Main Client) |
| 138 | +- Aggregates all other packages |
| 139 | +- Has special async/sync build process |
| 140 | +- Most complex package with full integration tests |
0 commit comments