# Checklist: Adding a New OWS Endpoint

## 1. Data Layer

- [ ] Write Snowflake SQL query
  - **ows-playlist**: JinjaSQL template in `queries/<domain>/sql/`
  - **ows-charts**: SQLAlchemy model in `models/`
  - **ows-analytics**: Query in `queries/<domain>/`
- [ ] Validate query against Snowflake (integration test or manual)

## 2. Response Schema

- [ ] Create Marshmallow schema in `schemas/`
- [ ] (ows-charts only) Consider Pydantic schema for request validation

## 3. Handler

- [ ] Add Flask route in appropriate `*_handlers.py`
- [ ] Parse and validate request parameters
- [ ] Call query/logic layer
- [ ] Apply Redis caching with `@cache_in_redis(ttl=...)` if appropriate
- [ ] Return response via Marshmallow schema
- [ ] (ows-analytics) Add authorization rule in `access_rules.yml`

## 4. Testing

- [ ] Write unit test in `tests/unit/`
  - Mock Snowflake execution
  - Test happy path + error cases
  - Test parameter validation
- [ ] Run `make test_unit`
- [ ] Run `make lint`
- [ ] Verify coverage >= 80%

## 5. Documentation

- [ ] Update OpenAPI spec in `spec/` (if maintained)

## 6. Downstream Consumer

- [ ] Add connector method in consuming graphql-* service
- [ ] Add Zod validation schema
- [ ] Add DataLoader if batching needed
- [ ] Write connector tests
