Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

🌠Household

Overview

A household is the registry of homes visited by a health campaign. Each record represents one home. A household stores its shared address and optional GPS location. It also stores its member count and type, such as family or community.

Each household member references a person in the Individual registry. One member can be the head. Member records can also define relationships, such as spouse, child, or parent.

In short: Which homes exist, where are they, who lives in each, and how are they related?

Business Flow

  • During registration/enumeration, field workers walk an area and register each household (location, head, member count). Each person added becomes a household member linked to an Individual record.

  • During campaign delivery, household and member records provide context for beneficiary visits. Services, eligibility, and reports reference the relevant household or member.

  • As things change (a member moves in/out, the head changes, a household splits), workers update or soft-delete records; mobile devices sync these edits back and forth.

  • The data feeds dashboards (via the transformer → Elasticsearch) and is bulk-read by downsync (referral-management) so a device can pull every household in its assigned area for offline work.

The /household context contains two entities: households and members. For example, create a household with POST /household/v1/_create. Create a member with POST /household/member/v1/_create.

Each entity supports single and bulk create, update, delete, and search requests. Submit relationships within a household-member create or update request.

Endpoint
Purpose

POST /v1/_create, /v1/bulk/_create

Register a household (single or bulk).

POST /v1/_update, /v1/bulk/_update

Correct/change a household.

POST /v1/_delete, /v1/bulk/_delete

Soft-delete a household.

POST /v1/_search

Find households (by id, boundary/locality, lat-long radius, since-time…).

POST /member/v1/_create … /member/v1/bulk/_delete

Create bulk Household, This API is used to create/add new household in bulk or soft deleting the household

POST /member/v1/_search

Find members (by householdId, individualId, client-reference ids — each accepts a list).

Service Details

API Details

BasePath /Household

Household service APIs - contain create, update, delete and search endpoints

  • POST /member/v1/_create - Create Household member: This API is used to create/add a new Household member.

  • POST /member/v1/bulk/_create - Create bulk Household member: This API is used to create/add new household members in bulk.

  • POST /member/v1/_update - Update Household member: This API is used to update the details of an existing Household member.

  • POST /member/v1/bulk/_update - Update bulk Household member: This API is used to update the details of existing household members in bulk.

  • POST /member/v1/_delete - Delete Household member: This API is used to soft delete details of an existing Household member.

  • POST /member/v1/bulk/_delete - Delete bulk Household member: This API is used to soft delete details of an existing Household member in bulk.

  • POST /member/v1/_search - Search Household member: This API is used to search existing Household members.

  • POST /v1/_create - Create Household: This API is used to create/add a new Household.

  • POST /v1/bulk/_create - Create bulk Household: This API is used to create/add new households in bulk.

  • POST /v1/_update - Update Household: This API is used to update the details of an existing Household.

  • POST /v1/bulk/_update - Update bulk Household: This API is used to update the details of existing households in bulk.

  • POST /v1/_delete - Delete Household: This API is used to soft delete details of an existing Household.

  • POST /v1/bulk/_delete - Delete bulk Household: This API is used to soft delete details of an existing Household in bulk.

  • POST /v1/_search - Search Household: This API is used to search existing Households.

Kafka entry points (async). Bulk requests land on create-household-bulk-topic / update-… / delete-… (and the household-member-consumer-bulk-* equivalents) and are processed by the service's own consumer. Persisted results go out on save-household-topic / update-household-topic / delete-household-topic (+ the *-household-member-topic set) for the persister and transformer.

Swagger contract:

Kafka topics

Topic
Dir
Purpose

create-household-bulk-topic

in

Bulk household create requests

update-household-bulk-topic

in

Bulk household update requests

delete-household-bulk-topic

in

Bulk household delete requests

household-member-consumer-bulk-create-topic

in

Bulk member create requests

household-member-consumer-bulk-update-topic

in

Bulk member update requests

household-member-consumer-bulk-delete-topic

in

Bulk member delete requests

save-household-topic

out

Persist new households

update-household-topic

out

Persist household updates

delete-household-topic

out

Persist household soft-deletes

save-household-member-topic

out

Persist new household members

update-household-member-topic

out

Persist member updates

delete-household-member-topic

out

Persist member soft-deletes

Dependencies

  • idgen — generates household record IDs.

  • individual — validates the person each household member points to.

  • boundary-service — validates the household's boundary/locality code.

  • health-services-common / -models — shared clients, validators, POJOs (also brings in tracer).

  • Kafka — async create/update/delete pipeline.

  • egov-persister (deployed via the configs/ repo) — actually writes the rows to Postgres off the save-* topics.

  • transformer → Elasticsearch — builds the dashboard read-model from the same topics.

  • Redis — caches in-flight records (the API pre-loads bulk payloads into cache before handing off to the consumer).

  • referralmanagement (downsync) — a downstream reader of household + address data -Referral Management.

Process Flow

Writes are asynchronous. The API validates and enriches the request, then acknowledges it. A Kafka consumer persists the request later.

For bulk writes, 202 Accepted confirms that the request entered the async pipeline. It does not confirm that Postgres stores every record. Check consumer logs and record status when persistence matters.

The service does not write Postgres directly. It emits a save-* event. egov-persister writes the row, while the transformer indexes the same event for dashboards. Member create, update, and delete use the same pattern. Searches read directly from Postgres.

Sequence Diagrams

Household Create
Household Bulk create
Household Update
Household bulk update
Household Search
Household Delete
Household Bulk Delete
Household Member - Create
Household Member Bulk Create
Household Member - Update
Household Member Bulk Update
Household Member - Search
Household Member - Delete
Household Member - Bulk Delete

Data Model

Failure / Retry Handling

  • Async, no batch rollback. A bulk request returns 202 before persistence. If a record fails in the consumer, it is logged, and the batch continues; failed records do not roll back the rest — check consumer logs and the record's status.

  • Single (non-bulk) calls fail fast. /v1/_create etc. validate synchronously and return a 400/validation error on the spot.

  • Idempotency is via clientReferenceId — re-submitting the same one should not create a duplicate row (unique constraints include it).

  • Optimistic locking via rowVersion protects against concurrent edits on update/delete.

  • Soft delete (isDeleted) everywhere — nothing is hard-deleted.

  • Cross-service dependency failures (idgen, individual, boundary down/misconfigured) surface as validation/enrichment errors; the household is rejected rather than partially saved.

Known Risks / Limitations

  • Member ↔ Individual link is app-validated, not a DB foreign key. Pointing a member at a non-existent or wrong individual is caught only by the individual-service lookup at write time.

  • The household_address_mv is a snapshot, not a live table. Downsync now reads from this materialised view (hosted in referralmanagement) instead of the live household tables — regardless of which flow created or updated the household (referral, ITN registration, etc.). This means any household created or updated after the last MV refresh won't show up in downsync until the view is next refreshed. The delay is purely a function of the MV's refresh schedule versus the writing flow's own schedule (e.g. ITN registration/delivery), so different producers may see different effective lag depending on how their timing lines up with the refresh cycle. This is a freshness/ops concern tied to refresh cadence — not a bug in how households are written, and not specific to referral.

  • Async persistence hides write failures. Bulk writes are accepted (202) before they hit Postgres; a stale/missing persister config means data is silently not stored. Verify the deployed persister config matches the build.

  • householdType and relationship type are convention-driven. They are stored as strings/codes validated at the app layer (and via MDMS/role rules for community households), not constrained by the DB.

  • Search semantics differ by mode. Search-by-id, boundary, since-time and lat-long radius take different code paths; QA should cover each rather than assuming one filter behaves like another.

Last updated

Was this helpful?