> For the complete documentation index, see [llms.txt](https://docs.digit.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digit.org/health/v2.0/deploy/configuration/microplan-service-configuration/services/resource-generator-service.md).

# Resource Generator Service

## Overview

The **Resource Generator Service** processes uploaded inputs to generate resource estimations and microplans.

It parses supported file formats, applies configured assumptions and formulas, triggers downstream creation flows, and publishes approved outputs back to the platform (including **HCM Console**).

## Pre-requisites

* Spring Boot
* Git (or another version control system)
* REST APIs
* Kafka
* PostgreSQL
* Familiarity with MDMS, Filestore, Boundary, Project Factory, and Localisation (helpful)

## Capabilities

### File parsing and estimation

* Parses Excel, Shapefiles, and GeoJSON inputs.
* Applies configured assumptions and formulas to compute resource needs.

### Triggers and orchestration

* **Plan–facility creation**: on facility file upload, triggers facility mapping creation via Project Factory.
* **Census creation/update**: on population file upload, triggers census ingestion flows.
* **Microplan generation**: once the census is approved, triggers estimation and microplan generation using the latest approved population data.

{% hint style="info" %}
The service supports mixed registration and distribution strategies. It can intentionally leave some fields `null` based on the `MixedStrategy` master.
{% endhint %}

### Resource mapping

* Maps uploaded columns into the expected campaign attributes.
* Validates schema compatibility before estimation runs.

### Output publishing

* Uploads approved estimation sheets to Filestore.
* Writes the final Filestore reference back to the plan configuration for traceability.

### HCM Console integration

* Publish estimated resources back to Project Factory so Console can surface the latest plan outputs.

## Service Dependencies

* MDMS service
* Filestore service
* Boundary service
* Localisation service
* Census service
* Project Factory
* Plan Service

## API Specification

Swagger:

{% embed url="<https://editor.swagger.io/?url=https://raw.githubusercontent.com/egovernments/DIGIT-Specs/grouped-service-contracts/Domain%20Services/Resource%20Generator/resource-1.0.0.yaml>" %}

[Postman Collection](https://api.postman.com/collections/13428435-c702603a-b3c5-4954-9f67-17c06e41d225?access_key=PMAT-01JRA0QCZE111Z3JQSM4R8KZEP)

## Sequence Diagram

<figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2FwvEmOt90RdFxMkLZMQSl%2Fimage.png?alt=media&amp;token=15501748-860b-41dc-b6ae-a3e5ef6cc0e6" alt="Resource Generator Service sequence diagram"><figcaption></figcaption></figure>

## Kafka topics

### Producer topics

<table><thead><tr><th width="276.99609375">Topic</th><th>Description</th></tr></thead><tbody><tr><td>resource-microplan-create-topic</td><td>Pushes to plan service for microplan creation after resource estimation.</td></tr><tr><td>resource-plan-config-update-topic</td><td>Updates a plan configuration with INVALID_DATA status in case of exception while processing file.</td></tr></tbody></table>

### Consumer topics

<table><thead><tr><th width="227.81640625">Topic</th><th>Description</th></tr></thead><tbody><tr><td>plan-config-update-topic</td><td>Triggers resource estimation, microplan creation, and campaign manager integration.</td></tr></tbody></table>

## Deployment configuration

### Environment variables

Configure values in your DIGIT DevOps environment YAMLs (search for `resource` / `resource-generator`):

* DB config: `db-host`, `db-name`, `db-url`, `domain`
* Core platform service configs (for example: persister, filestore)
* Secrets in the environment secrets file:
  * [unified-qa-secrets.yaml](https://github.com/egovernments/DIGIT-DevOps/blob/unified-env/deploy-as-code/helm/environments/unified-qa-secrets.yaml)
  * [unified-uat-secrets.yaml](https://github.com/egovernments/DIGIT-DevOps/blob/unified-env/deploy-as-code/helm/environments/unified-uat-secrets.yaml)

Localisation sheet:

* [Localisation details](https://docs.google.com/spreadsheets/d/1wi5c2aOtTiMO0dZtnn2kp3OudOenWkMxisubU_K_5o4/edit?gid=483861604#gid=483861604)

## MDMS

MDMS for Resource Generator is tightly coupled to microplanning masters used by Plan Service.

References:

* [Plan Service](/health/v2.0/deploy/configuration/microplan-service-configuration/services/plan-service.md)
* [Microplanning MDMS JSON data (v0.2)](https://github.com/egovernments/releasekit/tree/master/mdms/HCM/HCM%20Microplanning%20v0.2/JSON%20Data)

### Reference Docs <a href="#reference-docs" id="reference-docs"></a>

* [MDMS Service](https://core.digit.org/platform/core-services/mdms-master-data-management-service)
* [Filestore Service](https://core.digit.org/platform/core-services/filestore-service)
* [Boundary Service](https://digit-discuss.atlassian.net/wiki/spaces/DD/pages/2388295698/Boundary+Service)
* [Localisation Service](https://core.digit.org/platform/core-services/localization-service)
* [Project Factory - Campaign Manager](/health/v2.0/design/architecture/low-level-design/services/console-services/project-factory-campaign-manager.md)
* [Plan Service](/health/v2.0/deploy/configuration/microplan-service-configuration/services/plan-service.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.digit.org/health/v2.0/deploy/configuration/microplan-service-configuration/services/resource-generator-service.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
