docs use cases uc 004 search municipality - AlexandreZanata/Abastevo GitHub Wiki
UC-004 — Search Municipality
| Field | Value |
|---|---|
| ID | UC-004 |
| Name | Search Municipality |
| Actors | End User |
| Layer | UI → Application |
Goal
Find a municipality quickly by typing its name instead of browsing by state.
Preconditions
- Municipality catalog seeded (BR-016) or at least one
SurveyWeekimported (BR-005) during v1→v2 transition. - FTS index populated from
municipality_catalog(v2) oraverage_pricetable (v1).
Main flow
- User focuses search field on home or dedicated search screen.
- User types query string.
- WHEN query length < 2 characters (BR-007)
THEN show hint, no search executed. - WHEN query length ≥ 2
THEN system queries FTS with debounce (300 ms). - System returns matches: municipality name + state abbreviation, ranked by relevance (BR-017).
- User taps a result.
- System emits
CitySelected. - System navigates to UC-005.
Alternative flows
A1 — No results
- WHEN FTS returns empty
- THEN show
SEARCH_NO_RESULTS - AND suggest browsing by state (UC-003)
A2 — Ambiguous names
- WHEN multiple municipalities share similar names (e.g. "São Paulo" city vs state context)
- THEN always show state in result row
- AND disambiguate by
state + municipalitypair
A3 — Offline search
- WHEN no network
- THEN search works entirely on local FTS (BR-004)
A4 — City in catalog but no ANP data this week
- WHEN user selects a
MunicipalityCatalogEntrywithDataAvailability.NO_DATA_THIS_WEEKorNEVER_IN_ANP - THEN navigate to UC-005 and show informative empty state (BR-010)
- AND display subtitle in search results when
NO_DATA_THIS_WEEK(search_no_data_this_week)
Business rules
- BR-004, BR-005, BR-007, BR-010, BR-012, BR-016, BR-017
Domain events
CitySelected
Postconditions
- Selected municipality stored as preference (BR-012).
i18n keys
search_municipality_hintsearch_min_chars_hinterror_search_no_resultssearch_no_data_this_week