|
2 | 2 |
|
3 | 3 | This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
4 | 4 |
|
| 5 | +## Project Architecture |
| 6 | + |
| 7 | +BirdXplorer is a multi-module Python project for exploring X (formerly Twitter) community notes data: |
| 8 | + |
| 9 | +- **api/**: FastAPI web API (`birdxplorer_api`) |
| 10 | +- **common/**: Shared library with models, settings, storage (`birdxplorer_common`) |
| 11 | +- **etl/**: Data extraction, transformation, loading (`birdxplorer_etl`) |
| 12 | +- **migrate/**: Alembic database migrations |
| 13 | + |
| 14 | +### Dependencies |
| 15 | +- All modules use `birdxplorer_common` as foundation |
| 16 | +- API and ETL modules depend on `common` |
| 17 | +- PostgreSQL 15.4 for data storage |
| 18 | +- FastAPI for web API with auto-generated Swagger docs at `/docs` |
| 19 | + |
5 | 20 | ## Commands |
6 | | -- **Test**: `tox` (runs format, lint, test, type check) |
| 21 | + |
| 22 | +### Development Environment |
| 23 | +- **Setup env**: `cp .env.example .env` (sets `BX_STORAGE_SETTINGS__PASSWORD=birdxplorer`) |
| 24 | +- **Install module**: `pip install -e "./[module][dev]"` (e.g., `pip install -e "./api[dev]"`) |
| 25 | +- **Docker dev**: `docker-compose up -d` (starts PostgreSQL + FastAPI on :8000) |
| 26 | + |
| 27 | +### Testing & Quality |
| 28 | +- **Test all**: `tox` (from module directory - runs format, lint, test, type check) |
| 29 | +- **Test with data**: `BX_DATA_DIR=data/20230924 tox` (for community notes data testing) |
7 | 30 | - **Run single test**: `python -m pytest path/to/test_file.py::TestClass::test_method -v` |
8 | 31 | - **Format**: `black <directory> && isort <directory>` |
9 | 32 | - **Lint**: `pflake8 <directory>` |
10 | 33 | - **Type check**: `mypy <directory> --strict` |
11 | 34 |
|
| 35 | +### Database |
| 36 | +- **Migrate**: `cd migrate && alembic upgrade head` |
| 37 | +- **New migration**: `cd migrate && alembic revision --autogenerate -m "description"` |
| 38 | + |
| 39 | +### Module-Specific Tox |
| 40 | +Run from project root, then cd to module: |
| 41 | +- **common**: `cd common && tox` |
| 42 | +- **api**: `cd api && tox` |
| 43 | +- **etl**: `cd etl && tox` |
| 44 | +- **migrate**: `cd migrate && tox` |
| 45 | + |
12 | 46 | ## Code Style |
13 | 47 | - **Line length**: 120 characters |
14 | 48 | - **Python version**: 3.10+ |
15 | 49 | - **Formatting**: Black (opinionated) |
16 | 50 | - **Imports**: isort with Black profile, groups: standard, third-party, first-party |
| 51 | +- **First party modules**: `birdxplorer_api`, `birdxplorer_common`, `birdxplorer_etl` |
17 | 52 | - **Type hints**: Required, use strict mypy checking |
18 | 53 | - **Naming**: Snake case for functions/variables, PascalCase for classes |
19 | 54 | - **Error handling**: Custom exceptions inherit from BaseError |
|
0 commit comments