Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding resource-estimation-service folder for master merge #784

Merged
merged 14 commits into from
Jun 27, 2024
Merged
4 changes: 1 addition & 3 deletions build/build-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,7 @@ config:
build:
- work-dir: "health-services/resource-estimation-service"
image-name: "resource-estimation-service"
dockerfile: "build/17/maven/Dockerfile"
- work-dir: "health-services/resource-estimation-service/src/main/resources/db"
image-name: "resource-estimation-service-db"
dockerfile: "build/17/maven/Dockerfile"
devdatta-egov marked this conversation as resolved.
Show resolved Hide resolved
- name: "builds/health-campaign-services/analytics/auth-proxy"
build:
- work-dir: "analytics/auth-proxy"
Expand Down
8 changes: 8 additions & 0 deletions health-services/resource-estimation-service/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog
devdatta-egov marked this conversation as resolved.
Show resolved Hide resolved
## 1.0.0 - 2024-06-24
devdatta-egov marked this conversation as resolved.
Show resolved Hide resolved
#### Base Resource Estimation Service
devdatta-egov marked this conversation as resolved.
Show resolved Hide resolved
1. Resource Estimation Service manages file processing: validating data, calculating for files, updating plans, and integrating with campaigns.
2. File Processing: In file processing, it processes files present in plan configuration by calculating resources.
3. Updating Plan: It creates plans based on rows and updates those by putting them on topics that are consumed by the plan service.
4. Integrate with Campaign Manager: After processing calculations, it also integrates resources and boundary with the Campaign Manager.
5. Boundary and Data Validation: Validates boundaries and excel data during calculations.
devdatta-egov marked this conversation as resolved.
Show resolved Hide resolved
39 changes: 39 additions & 0 deletions health-services/resource-estimation-service/LOCALSETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Local Setup

To set up the Resource Estimation Service in your local system, clone the [Health Campaign Services repository](https://github.com/egovernments/health-campaign-services.git).

## Dependencies

- [x] Postgres DB
- [ ] Redis
- [ ] Elasticsearch
- [x] Kafka
- [x] Consumer
- [x] Producer


## Running Locally

### Local setup
1. To set up the Resource Estimation Service in your local system, clone the [Health Campaign Services repository](https://github.com/egovernments/health-campaign-services.git).
devdatta-egov marked this conversation as resolved.
Show resolved Hide resolved
2. Install GIT.
[For Windows](https://git-scm.com/download/win).
[For Linux](https://www.digitalocean.com/community/tutorials/how-to-install-git-on-ubuntu-18-04-quickstart).
2. Install JDK version 17 or above.
[For windows](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html).
[For Linux](https://javahelps.com/install-oracle-jdk-17-on-linux).
3. Install maven locally and configure environment variables.
4. Install Kafka (version 3.2.0 which is the latest version) - To install and run Kafka locally, follow the following links -
[Kafka for windows](https://dzone.com/articles/running-apache-kafka-on-windows-os) or [Kafka for Linux](https://tecadmin.net/install-apache-kafka-ubuntu/)
5. Install Postman - To install Postman, follow the following links -
[Postman for windows](https://www.postman.com/downloads/)
6. Install Kubectl - Kubectl is the tool that we use to interact with services deployed on our sandbox environment -
[kubectl for windows](https://core.digit.org/guides/operations-guide/working-with-kubernetes/installation-of-kubectl)
devdatta-egov marked this conversation as resolved.
Show resolved Hide resolved
[kubectl for Linux](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/)
7. Install aws-iam-authenticator - [if the DIGIT development environment is in AWS](https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html)
8. Install PostgreSQL v14 locally.
4. Also update DB config values as per your local system config.
5. Update all dependency service host either on any unified-env or port-forward.
6. Run spring boot main class
devdatta-egov marked this conversation as resolved.
Show resolved Hide resolved
devdatta-egov marked this conversation as resolved.
Show resolved Hide resolved

> Note: After running the above steps, if you encounter a Kafka error, ensure that both Kafka and Zookeeper services are actively running. For connection errors with other microservices, verify the correctness of the URL in the external mapping of the data configuration or consider port-forwarding the problematic service for direct access.
61 changes: 61 additions & 0 deletions health-services/resource-estimation-service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Resource Estimation Service Documentation

## Overview

The resource estimation service processes various file formats to estimate resources, generate microplans, upload result sheets, and update the HCM Admin Console. It integrates with other services like Mdms, Filestore, Project Factory, and Plan Service to ensure accurate resource estimation and campaign planning.

## Key Features

- **Parsing and Estimating Resources**: Processes file formats (Excel, Shapefiles, GeoJSON) to estimate necessary resources for micro planning by applying assumptions and formulas.
- **Validation**: Validates file data for proper data types and updates plan configuration status based on exceptions.
- **Generating Microplans**: Triggers the creation of microplans based on estimated resources and input data, detailing resource distribution for campaigns.
- **Uploading Results**: Uploads updated result sheets to a filestore, ensuring secure storage and accessibility.
- **Integrating with HCM Admin Console**: Updates the HCM Admin Console with estimated resources for effective campaign planning and execution.
devdatta-egov marked this conversation as resolved.
Show resolved Hide resolved

## Service Dependencies

- **Mdms service**
- **Filestore service**
- **Project Factory service**
- **Plan service**

## API Specification

- Not Applicable (NA)

## Sequence Diagram

- To be provided (Placeholder)
devdatta-egov marked this conversation as resolved.
Show resolved Hide resolved

## Producer Details

### Topics

| Topic | Description |
|--------------------------------|-------------------------------------------------------------------------|
| resource-microplan-create-topic | Pushes to Plan Service for microplan creation after resource estimation. |
| resource-plan-config-update-topic | Updates a plan configuration with INVALID_DATA status in case of processing exceptions. |

### Topics

| Topic | Description |
|---------------------------|------------------------------------------------------------------------|
| plan-config-update-topic | Triggers resource estimation, microplan creation, and campaign manager integration. |

devdatta-egov marked this conversation as resolved.
Show resolved Hide resolved
## Configuration and Deployment

- **Persister Config**: NA
- **Helm Chart**: Deployment details available [here](https://github.com/egovernments/DIGIT-DevOps/tree/unified-env/deploy-as-code/helm/charts/health-services/resource-estimation-service).

## Environment Variables

- Configure environment variables such as `db-host`, `db-name`, `db-url`, `domain`, and other DIGIT core platform services configurations before deployment.

## MDMS Configuration

- Configure MDMS data for Plan Service as per the documentation [here](https://github.com/egovernments/egov-mdms-data/tree/UNIFIED-QA/data/mz/health/hcm-microplanning).

## Reference Documents

- **MDMS Technical Document**: [Mdms service](https://core.digit.org/platform/core-services/mdms-master-data-management-service)

169 changes: 169 additions & 0 deletions health-services/resource-estimation-service/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.egov</groupId>
<artifactId>resource-estimation-service</artifactId>
<packaging>jar</packaging>
<name>file-processor-utility</name>
<version>1.0.0</version>
<properties>
<java.version>17</java.version>
<geotools.version>32-SNAPSHOT</geotools.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.2</version>
</parent>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>9.22.3</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-core</artifactId>
<version>1.5.18</version>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.2.8</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-geojson</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.5</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.3.10</version> <!-- Use the appropriate version -->
</dependency>

<!-- Egov dependencies -->
<dependency>
<groupId>org.egov.services</groupId>
<artifactId>tracer</artifactId>
<version>2.9.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.egov</groupId>
<artifactId>mdms-client</artifactId>
<version>2.9.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<!-- Bean Validation API support -->
</dependencies>
<repositories>
<repository>
<id>repo.egovernments.org</id>
<name>eGov ERP Releases Repository</name>
<url>https://nexus-repo.egovernments.org/nexus/content/repositories/releases/</url>
</repository>
<repository>
<id>repo.egovernments.org.snapshots</id>
<name>eGov ERP Releases Repository</name>
<url>https://nexus-repo.egovernments.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>repo.egovernments.org.public</id>
<name>eGov Public Repository Group</name>
<url>https://nexus-repo.egovernments.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>repo.digit.org</id>
<name>eGov DIGIT Releases Repository</name>
<url>https://nexus-repo.digit.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>apache.snapshots</id>
<name>Apache Development Snapshot Repository</name>
<url>https://repository.apache.org/snapshots/</url>
</repository>
<repository>
<id>osgeo-snapshot</id>
<name>OSGeo Snapshot Repository</name>
<url>https://repo.osgeo.org/repository/snapshot/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.egov.processor;


import org.egov.tracer.config.TracerConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;

@Import({ TracerConfiguration.class })
@SpringBootApplication
@ComponentScan(basePackages = { "org.egov.processor", "org.egov.processor.web.controllers" , "org.egov.processor.config"})
public class Main {


public static void main(String[] args) throws Exception {
SpringApplication.run(Main.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package org.egov.processor.config;

import org.egov.tracer.config.TracerConfiguration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Component;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Component
@Data
@Import({ TracerConfiguration.class })
@NoArgsConstructor
@AllArgsConstructor
@Setter
@Getter
public class Configuration {

// MDMS
@Value("${egov.mdms.host}")
private String mdmsHost;

@Value("${egov.mdms.search.endpoint}")
private String mdmsEndPoint;

@Value("${egov.plan.config.host}")
private String planConfigHost;

@Value("${egov.plan.config.endpoint}")
private String planConfigEndPoint;

// Filestore

@Value("${egov.filestore.service.host}")
private String fileStoreHost;

@Value("${egov.filestore.endpoint}")
private String fileStoreEndpoint;

@Value("${egov.filestore.upload.endpoint}")
private String fileStoreUploadEndpoint;

@Value("${egov.plan.create.endpoint}")
private String planCreateEndPoint;

@Value("${egov.project.factory.search.endpoint}")
private String campaignIntegrationSearchEndPoint;

@Value("${egov.project.factory.update.endpoint}")
private String campaignIntegrationUpdateEndPoint;

@Value("${egov.project.factory.host}")
private String projectFactoryHostEndPoint;

@Value("${resource.microplan.create.topic}")
private String resourceMicroplanCreateTopic;

@Value("${integrate.with.admin.console}")
private boolean isIntegrateWithAdminConsole;

@Value("${resource.update.plan.config.consumer.topic}")
private String resourceUpdatePlanConfigConsumerTopic;

@Value("${egov.boundary.service.host}")
private String egovBoundaryServiceHost;

@Value("${egov.boundary.relationship.search.endpoint}")
private String egovBoundaryRelationshipSearchEndpoint;

}
Loading
Loading