Happy House - Ecommerce Docs
Developer ResourcesGeo

Geo API Reference

Complete API contracts for the Geo module, including routes, auth, DTOs, responses, errors, examples, and integration notes.

Geo - API Reference

Audience: Frontend engineers, mobile engineers, backend engineers, QA, and API consumers. Scope: The two public reference-data endpoints for Nepal's provinces and districts.

1. Documentation Evidence

AreaFiles InspectedWhat Was Verified
Controllersapps/api/src/modules/geo/customer/geo-customer.controller.tsRoutes, methods, guards, rate limits
DTOscustomer/dto/*.tsQuery validation, pagination flags
Servicescustomer/geo-customer.service.tsOrdering, province filter
Schemapackages/db/src/schema/geo/*.tsCodes, relations
Error registryapps/api/src/common/types/error-codes.ts (// GEO)GEO_* codes

2. Module Summary

FieldValue
Module namegeo
Module sluggeo
Primary actorsguest (any caller), internal system
API surfacesmobile (public)
Base route prefixes/api/mobile/geo
Auth model@Public()
PersistencePostgreSQL (seeded reference tables)
Runtime source of truthPostgreSQL tables
Sibling docsBackend, Features and flows

3. Concepts and Terminology

TermMeaningSource FileUsed By
codeStable machine key — provinces get renamed, codes do notschemaPickers, logic
displayOrderOfficial province order (not alphabetical)schemaProvinces
provinceId / districtIdUUID v7 public idsschemaFilters, other modules' FKs

4. API Surface Map

SurfaceMethodPathActorAuth/GuardPermissionControllerPurpose
PublicGET/api/mobile/geo/provincesGuest@Public() + IpThrottleGeoCustomerControllerList 7 provinces
PublicGET/api/mobile/geo/districtsGuest@Public() + IpThrottleGeoCustomerControllerList 77 districts (or one province's)

5. Auth, Identity, and Permissions

SurfaceGuard/DecoratorIdentity ShapePermissionGuest AllowedNotes
Public@Public() + IpThrottlerGuardNoneN/AYesPUBLIC_READ 60/min per IP

6. DTO and Model Reference

6.1 Query DTOs

DTOFieldsValidation
GeoListQueryDtopagination (bool, default true per QueryDto base), page, sizeshared QueryDto
ListDistrictsQueryDtoprovinceId (UUID v7, optional), + QueryDto base@IsUUID("7")

6.2 Response DTOs

DTOFields
ProvinceResponseDtoid, code, name, displayOrder
DistrictResponseDtoid, code, name, province: { id, code, name }

7. Enum Reference

None — province/district codes are data, not enums.

8. Endpoint Reference

8.1 GET /api/mobile/geo/provinces

Purpose

The province picker. Seven entries in official order; key on code, display name.

Auth and Permissions

@Public(); PUBLIC_READ 60/min; no permission.

Response

200data array of { id, code, name, displayOrder }.

{
  "message": "Provinces fetched successfully",
  "errorCode": null,
  "data": [
    { "id": "0198…", "code": "koshi", "name": "Koshi", "displayOrder": 1 },
    { "id": "0198…", "code": "bagmati", "name": "Bagmati", "displayOrder": 3 }
  ]
}

Error Cases

None — a list of a fixed table cannot 404.

8.2 GET /api/mobile/geo/districts

Purpose

The district picker — all 77, or one province's, ordered by name.

Request

PartRequiredDetails
QueryNoprovinceId (UUID v7), pagination, page, size

Response

200data array of { id, code, name, province }.

{
  "message": "Districts fetched successfully",
  "errorCode": null,
  "data": [
    {
      "id": "0198…",
      "code": "kathmandu",
      "name": "Kathmandu",
      "province": { "id": "0198…", "code": "bagmati", "name": "Bagmati" }
    }
  ]
}

Error Cases

HTTPCodeCondition
404GEO_PROVINCE_NOT_FOUNDprovinceId names no province

Edge Cases

The four merge-trap codes (rukum-east/rukum-west, nawalpur/parasi) are distinct rows in different provinces — never merge them.

9. Flow Diagrams

9.1 Route Ownership

9.2 Request Sequence

EndpointPagination TypeDefault SizeMax SizeSort FieldsFiltersResult Cap
/provincesoffset (opt-in)20100displayOrder (fixed)7
/districtsoffset (opt-in)20100name (fixed)provinceId77

Unpaginated by default — the whole list is the contract for a picker.

11. Caching, Jobs, and External Integrations

IntegrationUsed?Details
Redis cacheNo84 rows; direct indexed reads
BullMQNo
External APINo

13. Mandatory Deep API Documentation Pack

13.1 Route-by-Route Completeness Matrix

RouteController MethodDTOsService MethodGuardsPermissionsCacheJobsDB TouchesErrorsDocumented?
GET /api/mobile/geo/provinceslistProvincesGeoListQueryDtoGeoCustomerService.listProvincesPublic+IpThrottleprovinceYes
GET /api/mobile/geo/districtslistDistrictsListDistrictsQueryDto…listDistrictsPublic+IpThrottledistrict, province404Yes

13.2 Request/Response Exhaustiveness

Covered in §8: full responses (§8.1/8.2), empty-list behavior (empty data before seeding), domain error (404 GEO_PROVINCE_NOT_FOUND), rate-limit behavior (429).

13.3 API Diagram Pack

Route ownership (§9.1), request sequence (§9.2).

13.4 Consumer Integration Notes

ConsumerRequired KnowledgeFailure HandlingContract Stability
Web frontendKey on code, not name; four split-district codes404 → refresh listStable
Mobile appPUBLIC_READ 60/min shared budget429 → back offStable
Internal servicesResolve districts via GeoLookupService, never direct reads404 → treat as bad inputStable

13.5 API Tradeoffs and Rationale

DecisionChosen BehaviorAlternatives ConsideredWhy This TradeoffRiskMitigation
Public, unauthenticatedOpen readsAuth-gatedPicker works pre-loginLoadRate limit
Unpaginated defaultFull listPage-by-defaultPicker needs all rowsPayload sizeTiny data
Codes as keysStable keysNamesRenames happenDocumented

13.6 API Change Impact

ChangeAffected ConsumersBackend ImpactData ImpactMigration Needed?Compatibility Plan
Province renamePickers showing nameSeed updatename columnNocode stable

14. Zero-Omission API Checklist

  • Every controller route is documented (§4, §8, §13.1).
  • Every parent route prefix and runtime URL is documented (§2, §4).
  • Every DTO field, enum, default, transform and validator is documented (§6).
  • Every response field and nullable field is documented (§8).
  • Every auth, guard, permission and guest identity branch is documented (§5).
  • Every success and error branch is documented (§8).
  • Every DB read, cache and external call is documented (§11).
  • Every route has examples for success responses and representative failures (§8).
  • Every endpoint family has route and sequence diagrams (§9).
  • Every tradeoff and compatibility risk is documented (§13.5, §13.6).
  • The API doc links to backend and features/flows (§1, See Also).

15. Integration Checklist

  • Every route from controllers is documented.
  • Every DTO field is documented.
  • Every response envelope is documented.
  • Every error code is documented.
  • Every auth guard and permission is documented.
  • Every cache key, queue job and external call is documented.
  • Every diagram matches the current code.
  • The API doc links to backend and features/flows.

See Also