# Default-data-handler

## Overview

The Default Data Handler is an orchestration service designed to streamline tenant onboarding and data setup. It offers functionality to create and manage MDMS data (schemas and corresponding data), localization data, and workflow configurations set up for the new tenants.

## Pre-requisites

Before you proceed with the documentation, make sure the following prerequisites are met -

* Prior knowledge of Java/J2EE
* Prior knowledge of Spring Boot
* Prior knowledge of Kafka and related concepts like Producer, Consumer, Topic, etc
* Prior knowledge of Elasticsearch

## Key Functionalities <a href="#release-summary" id="release-summary"></a>

* Loads all MDMS data (schemas and corresponding data) for schema codes listed in the resource/mdmsData folder.
* Loads all localization data for locales and modules listed in the resource/localisation folder to the new tenant.
* Loads the workflow configuration JSON from the application classpath, updates the tenantId with the new tenant ID, and invokes the workflow create API.
* Creates users for the new tenant and sends an OTP for login.

## Onboarding a New Module

1. **Add Module Data:** Add the module's MDMS data (schemas and corresponding data) and localisation data to the resource/mdmsData and resource/schema folder.\
   Reference: [mdmsData](https://github.com/egovernments/Citizen-Complaint-Resolution-System/tree/master/utilities/default-data-handler/src/main/resources/mdmsData), [schema](https://github.com/egovernments/Citizen-Complaint-Resolution-System/tree/master/utilities/default-data-handler/src/main/resources/schema)
2. **Add Workflow Configurations:** Update the PgrWorkflowConfig.json file (located at src/main/resources) by including the module's workflow configurations in the "BusinessServices" array.\
   Reference: [PgrWorkflowConfig.json](https://github.com/egovernments/Citizen-Complaint-Resolution-System/blob/master/utilities/default-data-handler/src/main/resources/PgrWorkflowConfig.json)
3. Add the module’s localisation locales and modules under the resource/localisation folder.\
   Reference: [localisation](https://github.com/egovernments/Citizen-Complaint-Resolution-System/tree/master/utilities/default-data-handler/src/main/resources/localisations)
4. Add Users with the necessary roles.\
   Reference: [User.json](https://github.com/egovernments/Citizen-Complaint-Resolution-System/blob/master/utilities/default-data-handler/src/main/resources/User.json)
5. Add Employees with the necessary roles.\
   Reference: [HRMS.json](https://github.com/egovernments/Citizen-Complaint-Resolution-System/blob/master/utilities/default-data-handler/src/main/resources/HRMS.json)
6. All these files have tenantid as a placeholder, which will be replaced by the tenantid set in the env file.
7. **Deploy the Service:** Build and deploy the default-data-handler service using the modified helm file

## **`Service Dependencies`**

```
mdms-v2
boundary-service
localisation service
user service
employee service
workflow service
```

## How it works

1. **Initialisation**
   * Start by setting up the necessary components.
   * Ensure all dependencies are installed.
2. **Process Execution**
   * Waits 10 seconds after startup until dependent services are running:

     mdms-v2

     boundary-service

     localisation service
   * Initialises StartupSchemaAndMasterDataInitializer after the 10-second wait.
   * Runs StartupUserAndEmployeeInitializer 4 times at 4-minute intervals.
3. **Finalization**
   * Within 20 minutes of service initialisation, all master data, localisation data, workflow data, users, and employees are created or updated.


---

# Agent Instructions: 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:

```
GET https://docs.digit.org/complaints-management/complaints-resolution-v2.10/design/architecture/default-data-handler.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
