# Locations and BS calendar (Prompt 2A)

`LocationService` reads through `LocationRepositoryInterface` and
`CachedLocationRepository`, cached forever with the `geo` tag. `LocationsSeeder`
runs provinces, districts, local levels and generated wards in hierarchy order,
then invalidates the cache. All seeders upsert by their natural keys and record
`seed_versions`.

The files currently contain 7 provinces, 77 districts, 753 local levels (6
metropolitan, 11 sub-metropolitan, 276 municipalities and 460 rural municipalities)
and 6,743 generated wards. `users.home_province_id`, `home_district_id` and
`home_local_level_id` have foreign keys. Counts and Sudurpaschim membership are
covered by feature tests; source verification remains open in [geo-todo.md](geo-todo.md).

| Public endpoint (prefix `/api/v1/public`) | Query |
| --- | --- |
| `GET geo/provinces` | — |
| `GET geo/districts` | Optional province slug `province=sudurpaschim` |
| `GET geo/local-levels` | Optional district slug `district=kailali` |
| `GET geo/wards` | Required local-level slug `local_level=dhangadhi` |
| `GET calendar/convert` | Exactly one of `ad=2026-04-14` or `bs=2083-01-01` |

These routes are public, rate limited, and send ETag and public Cache-Control.
Locations expose slugs and names, without numeric database identifiers.
Invalid filters and unsupported dates return the standard 422 error envelope.

`BsCalendar` uses month lengths from `bs_months`, cached forever with tag
`calendar`, with the committed JSON as its bootstrap fallback. It exposes `toBs`,
`toAd`, Nepali/English month names, Nepali formatting, and fiscal years running
Shrawan 1 through Asar end. Kathmandu determines the displayed day. Tests cover
2083-01-01 BS = 2026-04-14 AD, reverse conversion and Nepali digits.

The current table covers BS 2000–2099; 2084 onward is explicitly provisional.
BS 2100 requires an approved source. Conversion responses include `provisional`.
Dates whose complete fiscal year falls outside the table return 422 rather than
500. `BsCalendarSeeder` flushes the calendar cache after reseeding.

Geographic coordinates/boundaries and official district/local-level codes remain
nullable in the existing data. No values have been invented to fill them.
