Happy House - Ecommerce Docs
Developer ResourcesGeo

Geo Features and Flows

Complete feature list, actor journeys, state flows, business rules, edge cases, and diagrams for the Geo module.

Geo Features and Flows

Use this page for the geo reference domain: what it does for consumers and systems, and how the reads behave.

1. Documentation Evidence

Source TypeFiles or DocsWhat Was Extracted
APIapps/api/src/modules/geo/customer/geo-customer.controller.tsRoutes, rate limits, pagination behaviour
Backendapps/api/src/modules/geo/customer/geo-customer.service.tsOrdering, province filter, pagination
Schemapackages/db/src/schema/geo/{province,district,municipality,enums}.tsTables, codes, the empty municipality reference
Seedpackages/db/src/seed/seed-geo.tsIdempotent seeding, db:seed:geo
Error registryapps/api/src/common/types/error-codes.ts (// GEO)GEO_PROVINCE_NOT_FOUND, GEO_DISTRICT_NOT_FOUND

2. Feature Summary

FieldValue
Modulegeo
SubmoduleN/A
Primary user valueAuthoritative, code-stable province and district reference data for every location picker
ActorsGuest (any caller), internal systems via GeoLookupService
Main entry pointsGET /api/mobile/geo/provinces, GET /api/mobile/geo/districts, GeoLookupService
Main outputsProvince/district lists; resolved district rows for FK conversion
Related docsAPI, Backend

3. Actor Matrix

ActorCan DoCannot DoAuth RequirementNotes
Guest / any callerList provinces, list districts (all or by province)None (@Public())PUBLIC_READ 60/min per IP
Internal systemsResolve a district uuid → district row via GeoLookupServiceRead geo tables directlyInternal serviceSingle FK-conversion path
AdminNo admin surface; data is seeded, not edited

4. Capability Matrix

CapabilitySurfaceActorRoute/TriggerState ReadState WrittenLinked API Section
List provincesPublicGuestGET /api/mobile/geo/provincesprovinceAPI
List districtsPublicGuestGET /api/mobile/geo/districtsdistrictAPI
Filter districts by provincePublicGuest?provinceId=districtAPI
Resolve district for FKInternalAny moduleGeoLookupService.resolveDistrictdistrictbackend §6

5. User-Facing Flows

5.1 Fill the address form's district picker

Summary

A guest (or customer) opens an address form. The client fetches provinces, then districts for the selected province. The picker keys on code and displays name.

Sequence Diagram

Branches and Edge Cases

BranchConditionBehaviorError/Result
Unknown provinceprovinceId names nothing404GEO_PROVINCE_NOT_FOUND
Unknown district (lookup path)uuid names nothing404GEO_DISTRICT_NOT_FOUND
Pagination onpagination=trueOffset pages with count/currentPage/totalPage
Renamed provinceGovernment renamescode unchanged, name updatesConsumers keyed on code unaffected

5.2 Resolve a district for a foreign key

Called by shipping (quote), address (create/update) and any future module: GeoLookupService converts a district uuid into the internal integer id — the single place that conversion happens.

6. Admin Flows

None. Geo has no admin surface and no configuration: the reference data is government-published and seeded, not edited through the API.

7. Lifecycle and State Transitions

None — reference data has no lifecycle. The only transition is the seed itself: an empty database gains provinces and districts, idempotently, via db:seed:geo.

9. Data and Side Effects by Flow

FlowDB WritesCache EffectsJobsRealtimeAnalyticsNotifications
List provinces/districts
Seed (db:seed:geo)province, district

10. Error and Recovery Flows

ScenarioTriggerUser/System ExperienceRecoverySource
Rate limited> 60 requests/min from one IP429Retry laterPUBLIC_READ
Unknown idBad provinceId/district uuid404 with codeRefresh the picker listservice
Seed re-runEnvironment re-seededNo-op on existing rowsIdempotentseed script

11. Diagrams Required Per Module

  • Actor capability diagram — §3/§4.
  • Sequence diagram per major flow — §5.1.
  • Data side-effect diagram — §9.

12. Mandatory Feature and Flow Deep-Dive Pack

12.1 Feature Inventory With Minor Behaviors

FeatureMinor BehaviorActorTriggerUser/System ResultBackend Side EffectSource
ProvincesOfficial orderingGuestlistdisplayOrder orderservice
ProvincesRename resilienceGuestrenamescode stableschema comment
DistrictsName orderingGuestlistalphabeticalservice
DistrictsProvince filterGuest?provinceIdSubsetservice
DistrictsMerge trapsGuestrukum-east vs rukum-westDistinct rows, different provincesseed
LookupUnknown idSystemresolve404service

12.2 Business Process Diagram Pack

12.3 Business Rules and Policy Traceability

RuleBusiness ReasonActor ImpactEnforced InAPI ImpactBackend ImpactTests
Key on code, not nameProvinces get renamedConsumers survive renamesSchema + docscode in every responseseed
Four split-district codesThird-party datasets merge themCorrect picker rowsSeed dataDistinct codesseed
Single FK-conversion pathOne true resolutionModules never read geo directlyGeoLookupServiceService boundary
Public reads throttledLoad, not secrecy429 possiblePUBLIC_READguard

12.4 Tradeoffs and Product Rationale

Product DecisionUser BenefitEngineering BenefitAlternativeTradeoffRisk
Municipality reference emptyName is free textNo 753-row memory gameFull municipality tableNo municipality idsDocumented
Public, unauthenticatedPicker works pre-loginNo auth plumbingAuthenticated readsLoadRate limited
Seeded, not editableCanonical dataNo driftAdmin editingSeed-only updatesIdempotent re-seed

12.5 Flow Edge-Case Matrix

FlowEdge CaseTriggerExpected BehaviorUser/System FeedbackSource
ProvincesEmpty databaseFresh environmentEmpty until seeded[]seed ordering
DistrictsUnknown province idBad query404GEO_PROVINCE_NOT_FOUND
DistrictsPaginationpagination=trueOffset pagesEnvelope metadata
LookupDistrict renamedReference updateCode stableSame id

12.6 Flow-to-Data Trace

FlowReadsWritesCacheJobs/EventsResponse Fields
Provincesprovinceid, code, name, displayOrder
Districtsdistrict (+ province)id, code, name, province

12.7 Experience Quality Checklist

  • The doc explains what the actor is trying to accomplish.
  • The doc explains what the backend does that the actor does not see (lookup service, seeding).
  • The doc covers every minor flow and branch.
  • The doc includes user and system flows.
  • The doc explains business logic, tradeoffs, and rationale.
  • The doc maps every flow to API routes and backend side effects.
  • The doc includes diagrams appropriate to each flow type.
  • The doc covers edge cases and failure recovery.

13. Completion Checklist

  • Every feature, minor action, and submodule capability is listed.
  • Every actor has allowed and forbidden behavior.
  • Every major and minor flow includes steps, branches, and diagrams.
  • Every lifecycle has a transition table and state diagram (none exist — stated).
  • Every flow links to the API and backend docs.
  • TDD dependencies are called out where they shape behavior (no TDD pages published yet).

See Also