This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Create virtual environment and install dependencies
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt
# Copy environment file and configure
cp .env.sample .env
# Edit .env with proper values for TAS_USER, TAS_SECRET, etc.# Start database only
docker compose -f docker-compose.dev.yml up -d db
# Run database migrations
alembic upgrade head
# Create new migration
alembic revision --autogenerate -m "description"
# Rollback last migration
alembic downgrade -1# Run development server (requires database running)
fastapi dev app/main.py
# Or run with Docker (full stack)
docker compose -f docker-compose.dev.yml up -d# Run tests
pytest
# Run tests with coverage
pytest --cov=app --cov-report=term-missing
# Type checking
mypy app
# Code formatting
black .
isort .
# Linting
flake8
# Run pre-commit hooks
pre-commit run --all-files- FastAPI Application: Main API server with versioned endpoints (
/api/v1/) - Database Models: SQLAlchemy models with PostGIS geometry support
- Repository Pattern: Data access layer in
app/db/repositories/ - Service Layer: Business logic in
app/services/ - API Routes: Organized by domain in
app/api/v1/routes/
Database Models (app/db/models/):
Campaign: Main organizing entity for data collection effortsStation: Data collection locations (static or mobile)Sensor: Individual measurement devicesMeasurement: Time-series sensor data with geospatial supportSensorStatistics: Aggregated sensor data
API Organization:
- Campaigns:
/api/v1/campaigns/ - Stations:
/api/v1/campaigns/{campaign_id}/stations/ - Sensors:
/api/v1/campaigns/{campaign_id}/stations/{station_id}/sensors/ - Measurements:
/api/v1/campaigns/{campaign_id}/stations/{station_id}/sensors/{sensor_id}/measurements/
- Uses TACC Authentication Service (TAS) via JWT tokens
- Configuration in
app/api/dependencies/auth.py - PyTAS integration in
app/pytas/
- PostgreSQL with PostGIS extension for geospatial data
- Alembic for database migrations
- GeoAlchemy2 for spatial queries
- Connection configuration in
app/db/session.py
- Geospatial data support (GeoJSON, PostGIS)
- CSV file upload processing
- Time-series data with LTTB downsampling
- Campaign-based data organization
- Mobile and static station support
Tests are organized in tests/ directory matching the app structure:
conftest.py: Test configuration and fixtures- API tests:
tests/api/ - Service tests:
tests/test_*_service.py - Repository tests:
tests/test_*_repository.py
Environment variables (.env file):
DATABASE_URL: PostgreSQL connection stringTAS_USER/TAS_SECRET: TACC authentication credentialsJWT_SECRET: JWT signing secretENVIRONMENT: Environment identifier (dev/prod)
- Code follows black formatting (88 char line length)
- Type hints enforced with mypy (strict mode)
- Pre-commit hooks ensure code quality
- API documentation auto-generated at
/docsendpoint - Database migrations should be reviewed before applying