SureInk Common Model Library (sureink-common-model)
Type: Library (not a runnable microservice)
Overview
The sureink-common-model module is a dedicated Java library that defines a comprehensive set of shared data models (Data Transfer Objects - DTOs, Value Objects, etc.) for the SureInk Platform. Its sole purpose is to provide a centralized, canonical definition for data structures that are exchanged between microservices, used in API request/response payloads, and form the content of Kafka messages.
By centralizing these model definitions, sureink-common-model helps ensure consistency, reduces data contract discrepancies, and simplifies inter-service communication across the platform.
Key Features
- Centralized Model Definitions: Contains a large collection of POJOs (Plain Old Java Objects) and/or Java Records representing various data entities and structures used in the SureInk ecosystem.
- Data Contract Enforcement: Serves as the single source of truth for data contracts between services.
- Code Reusability: Allows different services to reuse the same model definitions, avoiding duplication and potential inconsistencies.
- Validation Annotations: Models are typically annotated with
jakarta.validation-apiconstraints (e.g.,@NotNull,@Size,@Valid) to facilitate data validation at various layers. - Serialization Support: Includes
jackson-datatype-jsr310to ensure correct JSON serialization and deserialization of Java 8+ date/time types. - Boilerplate Reduction: Uses
org.projectlombok(e.g.,@Data,@Value,@Builder) to reduce boilerplate code in model classes.
Package Structure
The primary package for these models is com.sureink.common. Given the large number of classes (over 400), this package is likely further organized into sub-packages based on domain or functionality. For example:
com.sureink.common.usercom.sureink.common.productcom.sureink.common.licensecom.sureink.common.requestcom.sureink.common.responsecom.sureink.common.event
(The exact sub-package structure would need to be explored within the source code.)
Dependencies
This library has minimal dependencies, focusing purely on what's needed for defining and using data models:
org.projectlombokjakarta.validation-apicom.fasterxml.jackson.datatype:jackson-datatype-jsr310org.springframework:spring-beans(lightweight, for potential Spring annotation compatibility)
It notably does not include Spring Boot starters or other heavy infrastructure dependencies, reinforcing its role as a lean model definition library.
Usage
To use these common models, other Maven-based microservices and libraries in the SureInk Platform should include sureink-common-model as a dependency in their pom.xml:
<dependency>
<groupId>com.sureink</groupId>
<artifactId>sureink-common-model</artifactId>
<version>1.0-SNAPSHOT</version> <!-- Or the relevant version -->
</dependency>
Services can then import and use these model classes directly in their code, for example, as types for REST controller parameters and return values, or as types for Kafka message payloads.
Building
As a library, sureink-common-model is built as part of the overall SureInk Platform build process:
# From the root project directory
mvn clean install
This will compile its code and install the resulting JAR (along with its sources, due to maven-source-plugin) into the local Maven repository, making it available to other modules.