Developed by the Firefly Software Foundation. dev@fireflysoftware.io
Website · OpenPlatform · Module catalogue
Core domain microservice for calculating prices, fees, and commissions using product configurations and a rule engine. This service acts as the centralized pricing orchestration layer within the Firefly platform, coordinating pricing computations, fee schedule management, and commission calculations through saga-based distributed transactions against the core-common-pricing-mgmt management service.
The Core Pricing Engine service provides the domain orchestration layer for all pricing-related operations across the Firefly platform:
- Price Calculation -- Computes product prices by evaluating rate structures, tiered pricing models, and margin rules against product configurations.
- Fee Management -- Orchestrates fee structure definitions including fee components, application rules, and product-fee associations through multi-step saga workflows with compensating transactions.
- Commission Calculation -- Determines commission amounts based on configurable rule sets tied to product and distributor hierarchies.
- Eligibility Evaluation -- Evaluates applicant eligibility against published criteria (KYC/KYB, credit score, income, activity) and returns fit/not-fit determinations with reasons.
- Saga Orchestration -- All write operations are executed as saga workflows with compensating transactions, ensuring data consistency across distributed steps.
| Module | Description |
|---|---|
domain-core-pricing-engine-core |
Business logic: commands, handlers, saga workflows, service interfaces and implementations |
domain-core-pricing-engine-interfaces |
Interface adapters connecting core to infrastructure and external boundaries |
domain-core-pricing-engine-infra |
Infrastructure layer: API client factory, configuration properties, external service integration |
domain-core-pricing-engine-web |
Spring Boot WebFlux application: REST controllers, application entry point, configuration |
domain-core-pricing-engine-sdk |
Auto-generated client SDK from OpenAPI spec for downstream consumers |
- Java 25
- Spring Boot with WebFlux (reactive, non-blocking)
- FireflyFramework -- Parent POM (
firefly-parent), and libraries:fireflyframework-web-- Common web configurationsfireflyframework-starter-domain-- Domain layer CQRS and saga supportfireflyframework-utils-- Shared utilitiesfireflyframework-validators-- Validation framework
- FireflyFramework Transactional Saga Engine --
@Saga,@SagaStep,@StepEventannotations withSagaEnginefor orchestrating distributed transactions with compensation - FireflyFramework CQRS --
CommandBusfor command dispatch - FireflyFramework EDA -- Event-driven architecture with Kafka publishers for domain events
- Project Reactor (
Mono/Flux) -- Reactive streams throughout - MapStruct -- Object mapping between layers
- Lombok -- Boilerplate reduction
- SpringDoc OpenAPI -- API documentation and Swagger UI
- Micrometer + Prometheus -- Metrics export
- Spring Boot Actuator -- Health checks and operational endpoints
- OpenAPI Generator -- SDK generation from the OpenAPI spec (WebClient-based reactive client)
| Saga | Steps | Description |
|---|---|---|
RegisterPricingSaga |
registerProductPricing |
Registers a new pricing configuration (rates, tiers, effective date) for a product |
UpdatePricingSaga |
updatePricing |
Amends pricing by creating a new effective version with updated rates, margins, or tiers |
RegisterFeeSchemaSaga |
registerFeeStructure -> registerFeeComponent (depends on structure) -> registerFeeApplicationRule (depends on structure + component) -> registerProductFeeStructure (depends on structure) |
Defines a complete fee scheme with compensating rollback for each step |
UpdateFeeRuleSaga |
updateFee |
Updates a specific fee calculation rule |
The service emits the following events via @StepEvent:
productPricing.registeredpricing.updatedfeeStructure.registeredfeeComponent.registeredfeeApplicationRule.registeredproductFeeStructure.registeredfee.updated
- Java 25
- Maven 3.9+
- Access to the FireflyFramework Maven repository for parent POM and BOM dependencies
- Running instance of
core-common-pricing-mgmtservice (or its API accessible at the configured base path) - Apache Kafka broker (for domain event publishing)
| Variable | Default | Description |
|---|---|---|
SERVER_ADDRESS |
localhost |
Server bind address |
SERVER_PORT |
8080 |
Server port |
FIREFLY_KAFKA_BOOTSTRAP_SERVERS |
localhost:9092 |
Kafka bootstrap servers for event publishing |
Key configuration sections in application.yaml:
spring:
application:
name: domain-core-pricing-engine
version: 1.0.0
description: Core Pricing Engine - Domain Layer
team:
name: Firefly Software Foundation
email: dev@fireflysoftware.io
threads:
virtual:
enabled: true
firefly:
cqrs:
enabled: true
command:
timeout: 30s
metrics-enabled: true
tracing-enabled: true
query:
timeout: 15s
caching-enabled: true
cache-ttl: 15m
saga.performance.enabled: true
eda:
enabled: true
default-publisher-type: KAFKA
stepevents:
enabled: trueAdditional configuration typically includes:
api-configuration.common-platform.pricing-mgmt.base-path-- Base URL for the downstream pricing management service- Server port, logging levels, and profile-specific settings
mvn clean installmvn -pl domain-core-pricing-engine-web spring-boot:runOr run the packaged JAR:
java -jar domain-core-pricing-engine-web/target/domain-core-pricing-engine.jarBase path: /api/v1/pricing
| Method | Path | Description |
|---|---|---|
POST |
/api/v1/pricing |
Register pricing -- create rates with tiers and effective-from date |
PUT |
/api/v1/pricing/{pricingId} |
Amend pricing -- create a new effective version with updated rates, margins, or tiers |
Base path: /api/v1/pricing/fees
| Method | Path | Description |
|---|---|---|
POST |
/api/v1/pricing/fees/schemes |
Define fee scheme -- define fee types and calculation rules |
PUT |
/api/v1/pricing/fees/schemes/{schemeId}/components/{componentId} |
Update fee rule -- update a specific fee calculation rule |
Base path: /api/v1/pricing/eligibility
| Method | Path | Description |
|---|---|---|
POST |
/api/v1/pricing/eligibility |
Publish eligibility criteria -- publish eligibility rules (KYC/KYB, score, income, activity) |
PATCH |
/api/v1/pricing/eligibility/{eligibilityId} |
Adjust eligibility criteria -- adjust criteria with versioning |
POST |
/api/v1/pricing/eligibility/{eligibilityId}/evaluate |
Evaluate eligibility -- evaluate applicant facts and return fit/not-fit with reasons |
| Header | Required | Description |
|---|---|---|
X-Idempotency-Key |
No | Ensures identical requests are processed only once |
X-Party-ID |
Conditional | Client identifier (at least one identity header required) |
X-Employee-ID |
Conditional | Employee identifier |
X-Service-Account-ID |
Conditional | Service account identifier |
X-Auth-Roles |
No | Comma-separated roles (CUSTOMER, ADMIN, CUSTOMER_SUPPORT, SUPERVISOR, MANAGER, BRANCH_STAFF, SERVICE_ACCOUNT) |
X-Auth-Scopes |
No | Comma-separated OAuth2 scopes |
X-Request-ID |
No | Request traceability identifier |
The domain-core-pricing-engine-sdk module auto-generates a reactive Java client from the service's OpenAPI specification using the OpenAPI Generator Maven plugin.
Generated packages:
| Package | Description |
|---|---|
io.fireflysoftware.domain.core.pricing.engine.sdk.api |
API client classes for each controller tag |
io.fireflysoftware.domain.core.pricing.engine.sdk.model |
Request/response model DTOs |
io.fireflysoftware.domain.core.pricing.engine.sdk.invoker |
ApiClient configuration and HTTP transport |
Usage:
Add the SDK dependency to your consuming service:
<dependency>
<groupId>io.fireflysoftware</groupId>
<artifactId>domain-core-pricing-engine-sdk</artifactId>
<version>${domain-core-pricing-engine.version}</version>
</dependency>The SDK uses Spring WebClient for reactive HTTP calls. Configure the ApiClient base path in your ClientFactory to point at the running service instance.
mvn testmvn verifyTest dependencies include:
- Spring Boot Test --
@SpringBootTestfor application context loading - Reactor Test --
StepVerifierfor reactive stream assertions
The service exposes the following operational endpoints via Spring Boot Actuator:
| Endpoint | Description |
|---|---|
/actuator/health |
Application health status |
/actuator/info |
Application information |
/actuator/prometheus |
Prometheus metrics endpoint |
OpenAPI documentation is available at:
- Swagger UI: http://localhost:{port}/swagger-ui.html
- API Docs (JSON): http://localhost:{port}/v3/api-docs
https://github.com/firefly-oss/domain-core-pricing-engine
- Multi-module Maven structure (
-interfaces,-infra,-core,-web,-sdk). - Spring Boot bootstrap: production entry point
PricingEngineApplicationand the build-timeOpenApiGenApplication(undersrc/test/java) used by the parent POM'sopenapi-start/openapi-stopflow. ClientFactoryandProductMgmtPropertieswiring for the downstreamcore-common-product-mgmtservice.- Stub
openapi.ymlsoopenapi-generator-maven-plugincan run before any controllers exist; the spec is regenerated from the live web app on each build. domain-core-pricing-engine-sdkregistered infirefly-bom.
The introduction above and the Setup section refer to core-common-pricing-mgmt
as the downstream pricing data store. That service has been deprecated; pricing
data now lives in core-common-product-mgmt (extended in Phase 1). The
ClientFactory in this scaffold therefore consumes
io.fireflysoftware.core-common-product-mgmt-sdk and the configuration prefix is
api-configuration.common-platform.product-mgmt.
PricingEngineService,CalculateSimulationCommand,GetProductPricingQuery.- REST controllers under
io.fireflysoftware.domain.core.pricing.engine.web.controllers. - Business logic for price calculation and simulation.
- Full unit and integration test suite.
RegisterPricingSaga,UpdatePricingSaga,RegisterFeeSchemaSaga,UpdateFeeRuleSaga.- Fee, commission and eligibility orchestration with
@StepEventdomain events.