# Voter Register Room - API Pack (PHP)

## Install
1. Copy `API/voter-register/*` into your server under `/API/voter-register/`
2. Ensure you already have `/API/conn.php` (same one used by your other endpoints)
3. Run `voter_register_helper_tables.sql` on your database (recommended)

## Endpoints (v1)
- GET  /API/voter-register/get__counties.php?cycle=2027
- GET  /API/voter-register/get__constituencies.php?county_code=047&cycle=2027
- GET  /API/voter-register/get__wards.php?const_code=xxx&cycle=2027
- GET  /API/voter-register/get__stations.php?ward_id=12&cycle=2027

- PATCH /API/voter-register/update__station.php
- PATCH /API/voter-register/update__rollup.php

- GET  /API/voter-register/compare.php?base=2022&target=2027&level=ward&const_code=xxx
- GET  /API/voter-register/trend.php?level=ward&caw_code=xxx

- GET  /API/voter-register/analytics__overview.php?cycle=2027&county_code=047
- GET  /API/voter-register/analytics__heatmap.php?cycle=2027&level=ward&county_code=047
- GET  /API/voter-register/analytics__anomalies.php?base=2022&target=2027&level=ward&threshold_pct=30

- POST /API/voter-register/import__create_batch.php
- POST /API/voter-register/import__upload.php?batch_id=123&cycle=2027   (multipart/form-data file key=file)
- GET  /API/voter-register/import__validate.php?batch_id=123
- POST /API/voter-register/import__commit.php?batch_id=123&mode=merge

- POST /API/voter-register/predictions__run.php?cycle=2027&level=ward&county_code=047
- GET  /API/voter-register/predictions.php?cycle=2027&level=ward&metric=turnout_prediction
- GET  /API/voter-register/predictions__explain.php?id=1

- GET  /API/voter-register/audit.php?cycle=2027
- POST /API/voter-register/export.php  (streams CSV)

## Notes
- These endpoints prefer `voter_register_snapshots` when present.
- If helper tables are missing, update endpoints will ask you to run the SQL.
