> 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/design/architecture/low-level-design/services/microplan-low-level-design.md).

# Microplan - Low Level Design

## Overview

The Low Level Design (LLD) details on this page provide a detailed technical blueprint for implementing the **Microplanning** system. It translates functional requirements into concrete technical components, including APIs, service responsibilities, sequence flows, and database schemas.

The LLD covers:

* Internal architecture of Microplanning services
* API specifications at a component level
* Asynchronous processing flows
* Sequence diagrams for key workflows
* Database schema design and entity relationships

## System Overview

The Microplanning system enables planning, estimation, and allocation of resources across administrative units, employees, and facilities. It is composed of two core backend services:

1. **Resource Generator Service** – Responsible for generating resource estimations asynchronously.
2. **Plan Management Service** – Manages the lifecycle of micro plans, including configuration, assignments, validation, and approval.

Both services follow DIGIT’s event-driven, microservices-based architecture.

## Resource Management <a href="#overview" id="overview"></a>

The Draft API is part of the **Resource Generator Service**. It initiates the resource estimation process for a given micro plan configuration.

**Key Characteristics**

* Fully asynchronous processing
* Designed for large datasets
* Non-blocking client interaction

**Processing Flow**

1. Client invokes Draft API with plan configuration reference
2. Request is validated and accepted
3. The estimation job is triggered asynchronously
4. Input data is parsed and business logic applied
5. Output file is generated and uploaded to File Store
6. Plan configuration is updated with estimation metadata

### API Specification <a href="#api-specification" id="api-specification"></a>

​[Resource Generator API Specification](https://github.com/egovernments/DIGIT-Specs/blob/grouped-service-contracts/Domain%20Services/Resource%20Generator/resource-1.0.0.yaml)&#x20;

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

### Sequence Diagrams <a href="#sequence-diagrams" id="sequence-diagrams"></a>

#### Draft API <a href="#draft-api" id="draft-api"></a>

<figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2FjrBBFvzanLcq2qMKM5gv%2Fimage.png?alt=media&amp;token=bc163bbe-7881-492a-af9f-9d0afd711600" alt=""><figcaption></figcaption></figure>

## Plan Management

The Plan Management Service handles the complete lifecycle of micro plans, including:

* Micro plan creation and configuration
* Employee assignment to plans
* Facility linkage
* Validation and approval of estimations

Key Characteristics

**Plan Configuration**

* Create and update micro plans
* Store administrative hierarchy and planning parameters

**Plan Employee Assignment**

* Assign employees to micro plans
* Validate role and jurisdiction alignment

**Plan Facility Linkage**

* Link facilities (e.g., schools, health centres) to plans
* Support one-to-many and many-to-many mappings

**Plan Estimation Management**

* Store estimation references
* Track draft vs approved estimations

**Validation & Approval**

* Rule-based validation of estimation data
* Approval workflows for finalised plans

### API Specification

[Plan Management API Specification](https://github.com/egovernments/DIGIT-Specs/blob/grouped-service-contracts/Domain%20Services/Plan%20Service/plan-1.0.0.yaml)

### Sequence Diagrams

#### Plan Configuration APIs

<figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2FlaTvRDmORnqZcradkIvK%2Fimage.png?alt=media&amp;token=91339b15-3332-4455-b833-0203719e155d" alt=""><figcaption><p><em>Plan Configuration Create API Sequence Diagram</em></p></figcaption></figure>

<div align="left"><figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2FN0yPRIPpZrUvPaRaLPyJ%2Fimage.png?alt=media&amp;token=f38e9163-d0ce-44c6-b927-765e13f05148" alt=""><figcaption><p><em>Plan Configuration Search API Sequence Diagram</em></p></figcaption></figure></div>

<figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2FstAo1jjWsLhIVNZrYxU2%2Fimage.png?alt=media&amp;token=7ecb2620-1188-4801-8132-06bb258cb59a" alt=""><figcaption><p><em>Plan Configuration Update API Sequence Diagram</em></p></figcaption></figure>

### Plan Employee Assignment APIs

<figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2Fk3190rDkct5dR5HgP7Hl%2Fimage.png?alt=media&amp;token=d0991a63-6261-45cb-95ff-0858b6cf85dd" alt=""><figcaption><p><em>Plan Employee Assignment Create API Sequence Diagram</em></p></figcaption></figure>

<figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2FbfKceuUfED8KTrP8Kd5X%2Fimage.png?alt=media&amp;token=620d3627-b7e7-426b-bb45-93f036b3549a" alt=""><figcaption><p><em>Plan Employee Assignment Search API Sequence Diagram</em></p></figcaption></figure>

<figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2FS7AKnx05saYI3pfrLwlD%2Fimage.png?alt=media&amp;token=fbdc7580-af7f-41ea-86ad-bdd651bd4665" alt=""><figcaption><p><em>Plan Employee Assignment Update API Sequence Diagram</em></p></figcaption></figure>

### Plan Facility APIs

<figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2FjiNhzz27Jl3uaJ7FcLnr%2Fimage.png?alt=media&amp;token=a909e06c-1ebd-4444-8977-2affcf11e5aa" alt=""><figcaption><p><em>Plan Facility Create API Sequence Diagram</em></p></figcaption></figure>

<figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2FKPfrGJdrJinJI9PLFmGl%2Fimage.png?alt=media&amp;token=1ab8da21-99ad-4b0e-a45f-cbe046765f70" alt=""><figcaption><p><em>Plan Facility Search API Sequence Diagram</em></p></figcaption></figure>

<figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2Fc0ya6OhTDrw0920vcREJ%2Fimage.png?alt=media&amp;token=575eb3f7-078d-4d03-aaff-0a9151081c5a" alt=""><figcaption><p><em>Plan Facility Update API Sequence Diagram</em></p></figcaption></figure>

### Plan Management APIs

<figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2FuJCEbu4bh2LEdu1rNtrP%2Fimage.png?alt=media&amp;token=f6fabea8-35b4-41e8-b2d9-cc8676524b0f" alt=""><figcaption><p><em>Plan Create API Sequence Diagram</em></p></figcaption></figure>

<div align="left"><figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2FfqGzBrd6FX5FtZhiE6yE%2Fimage.png?alt=media&amp;token=c2988670-4453-4150-9b97-11d1074fe714" alt=""><figcaption><p><em>Plan Search API Sequence Diagram</em></p></figcaption></figure></div>

<figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2FpASpsnPkPROlTPkhzJY1%2Fimage.png?alt=media&amp;token=02882206-8dbd-43e9-9fc6-b25aba2b7fe1" alt=""><figcaption><p><em>Plan Update API Sequence Diagram</em></p></figcaption></figure>

## Database Schemas

<figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2FTK4WfekAlYGFuxs8iYTw%2Fimage.png?alt=media&amp;token=c9402782-d69f-4fb9-8bfa-9f83ee3488c4" alt=""><figcaption><p><em>Plan Configuration Database Schema</em></p></figcaption></figure>

<div align="left"><figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2FMVZKr1An8TcTODJYlo3P%2Fimage.png?alt=media&amp;token=425230d7-b15c-4a38-97b0-0b1c55808643" alt=""><figcaption><p><em>Plan Employee Assignment Database Schema</em></p></figcaption></figure></div>

<div align="left"><figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2F7P2R6jandguHjZBuAZLH%2Fimage.png?alt=media&amp;token=4682fad4-0cd9-46d0-9178-c755751db2a7" alt=""><figcaption><p><em>Plan Facility Database Schema</em></p></figcaption></figure></div>

<figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2Fr5CdMIFthwI9Ml0Gh9Ad%2Fimage.png?alt=media&amp;token=70c614fa-8d50-4ddb-affc-8b1b7cf9b1f9" alt=""><figcaption><p><em>Plan Database Schema</em></p></figcaption></figure>

## Census Management

### Overview

The **Census Management Service** is responsible for managing population census data used as a key input for microplanning and resource estimation. It supports capture, validation, approval, and versioning of census data across administrative hierarchies.

Census data acts as a foundational dataset for estimation logic and must pass through defined validation and approval workflows before it can be consumed by downstream services such as the Resource Generator.

**Key Characteristics**

* Capture population census data at multiple administrative levels
* Maintain draft and approved versions of census datasets
* Validate census data against configured rules
* Support approval workflows for finalised census data
* Expose approved census data to dependent services

### API Specifications

[Census Management API Specification](https://github.com/egovernments/DIGIT-Specs/blob/grouped-service-contracts/Domain%20Services/Census/census-v1.0.0.yaml)

### Sequence Diagrams <a href="#sequence-diagrams" id="sequence-diagrams"></a>

#### Census Management APIs <a href="#census-management-apis" id="census-management-apis"></a>

<figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2FPp6YJt8LEqVbEjrgihGO%2Fimage.png?alt=media&amp;token=1b038a2e-3aa2-4bb8-9eb3-67fc081d7dc4" alt=""><figcaption><p><em>Census Create API Sequence Diagram</em></p></figcaption></figure>

<br>

<div align="left"><figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2F3X7V34Zu7a1yD0D8Owmo%2Fimage.png?alt=media&amp;token=45c1523c-78a7-40cb-bdb2-659ddddbd34e" alt=""><figcaption><p><em>Census Search API Sequence Diagram</em></p></figcaption></figure></div>

<figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2Fzliz4tnwlokpesNmZ4B6%2Fimage.png?alt=media&amp;token=b6704b71-6d49-403e-8e2b-ef38f54e8528" alt=""><figcaption><p><em>Census Update API Sequence Diagram</em></p></figcaption></figure>

### Database Schemas

<figure><img src="https://3976166735-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmb5VUHEnO0msarLMPz6q%2Fuploads%2FXWnOyDKo5m8V5m4ri9aP%2Fimage.png?alt=media&amp;token=13d9ab07-8ee1-4805-a2ce-6a976401873f" alt=""><figcaption></figcaption></figure>


---

# 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/design/architecture/low-level-design/services/microplan-low-level-design.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.
