Skip to main content

SureInk Platform Utilities Service (sureink-platform-utils)

Overview

The sureink-platform-utils module is a Spring Boot microservice that provides a collection of shared, platform-level services and utilities for the SureInk Platform. Despite its name suggesting a simple utility library, it is a runnable application that offers centralized functionalities accessible by other microservices.

Key services likely provided include a centralized email sending service, common reporting functionalities, and potentially shared business logic or event handling mechanisms.

Technology Stack

  • Core Framework: Java, Spring Boot
    • Spring Web (for REST APIs)
    • Spring Data JPA (for database interaction)
    • Spring Security
    • Spring Boot Mail (for email functionalities)
  • Database:
    • PostgreSQL
    • Liquibase (for schema migrations if this service has its own tables)
  • Spring Cloud:
    • Spring Cloud Netflix Eureka Client (for service discovery)
  • Messaging: Apache Kafka (spring-kafka)
  • Security: Keycloak (integrated via keycloak-spring-boot-starter)
  • Monitoring & Metrics:
    • Spring Boot Actuator
    • JavaMelody
    • Micrometer Prometheus
  • Utilities: Project Lombok, Jackson, Gson
  • Internal Libraries:
    • sureink-common
    • sureink-common-model

Key Functionalities

Based on its structure and dependencies, this service likely provides:

  • Centralized Email Service: Offers an API or service for sending emails (managed via EmailConfiguration.java and the email/ package).
  • Shared Business Services: A suite of common business logic operations accessible to other microservices (within the extensive service/ package).
  • Platform-Level Event Handling: May include common Kafka event producers, consumers, or event definitions used across the platform (within the event/ package).
  • Reporting Utilities/Services: Common functionalities or data aggregation for reporting purposes (within the report/ package).
  • API Endpoints: Exposes REST APIs via its controller/ package for accessing its shared services.
  • Database Interaction: May manage its own database tables for its specific utilities (via repository/ and PersistenceConfiguration.java).

Project Structure

The service is organized under the com.sureink.platform.utils package:

  • PlatformUtilsApplication.java: The main Spring Boot application class.
  • Configuration Classes:
    • EmailConfiguration.java: Configures email sending capabilities.
    • KeycloakSecurityConfig.java: Standard Keycloak security setup.
    • PersistenceConfiguration.java: Configures JPA and database connectivity.
  • controller/: Spring MVC controllers defining REST APIs for the shared services.
  • service/: Contains the business logic for the various platform utilities offered.
  • repository/: JPA repositories for data persistence related to the utility services.
  • model/: Data Transfer Objects (DTOs) or internal models for the service.
  • event/: Manages Kafka integration, including event definitions, producers, and consumers.
  • client/: May contain Feign clients if this service needs to call other microservices.
  • email/: Specific logic related to the email service.
  • report/: Logic for reporting functionalities.

API Endpoints & Kafka Topics

  • REST APIs: Defined in controllers within the controller/ package. These APIs would expose the various utility functions (e.g., an endpoint to trigger an email).
  • Kafka Topics: This service may produce and/or consume events related to its operations (e.g., an event when an email is sent, or consuming events that trigger a utility function).

(Refer to the specific classes for exact API endpoint details, request/response DTOs, and Kafka topic names.)

Configuration

Key configuration areas (typically in application.properties or application.yml, or provided by a Spring Cloud Config server if used):

  • Database Connection: PostgreSQL connection details.
  • Eureka Client: Eureka server address.
  • Keycloak: Keycloak server URL, realm, client ID, and credentials.
  • Apache Kafka: Broker addresses, topic names.
  • Email Server: SMTP server details (host, port, username, password) for the email service.

Prerequisites

  • JDK 11 or later
  • Apache Maven
  • Access to a running PostgreSQL instance (if it has its own schema)
  • Access to a running Keycloak instance
  • Access to a running Apache Kafka cluster
  • Access to a running Eureka server
  • Access to an SMTP server for email functionality

Build Instructions

cd path/to/sureink-platform-utils
mvn clean install

Running the Application

java -jar target/sureink-platform-utils-1.0-SNAPSHOT.jar

Ensure all prerequisite services (Database, Eureka, Keycloak, Kafka, SMTP server) are running and configurations are correctly set up.

Dockerization

The pom.xml includes profiles for building Docker images using docker-maven-plugin, indicating that this service is intended to be containerized.