π Shared Libraries Overview
FireMUDβs microservices share a set of utility classes and data transfer objects so each service can stay lightweight and consistent. The common library is published as a Gradle artifact and reused by all modules. It is released under the group ID net.firedevops.firemud.shared
with the artifact ID firemud-common
.
π Common DTOs & Error Handling
These classes define the basic request/response shapes recommended in AI Project Rules:
ApiResponse<T>
β Standard wrapper returned by controllers withsuccess()
anderror()
helpers.ResultStatus
β Enum used byApiResponse
(SUCCESS
/ERROR
).ErrorDetail
β Structured error information for validation problems or failed operations.GlobalExceptionHandler
β Captures exceptions and converts them intoApiResponse<ErrorDetail>
objects.
DTO records for common tasks (paging, IDs, basic metadata) live here so services share a consistent contract.
π§ Utility Packages
- Logging Utilities β SLF4J wrappers and helpers for correlation IDs.
- Security Utilities β
JwtUtil
for token generation/verification and role helpers aligned with the Authentication Design. - Database Connectors β
DatabaseAutoConfiguration
withPostgresProperties
andRedisProperties
reduces boilerplate setup. Defaults suit Docker Compose but any field can be overridden withFIREMUD_POSTGRES_*
orFIREMUD_REDIS_*
environment variables. - gRPC Interceptors β
LoggingInterceptor
andMetricsInterceptor
provide consistent instrumentation for every service. - Service Discovery & Config β Central location for discovering other services and handling environment properties.
ServiceEndpointsProperties
loads the base URLs for each microservice and is enabled byCommonAutoConfiguration
.- Spring Boot Starter β Lightweight autoconfiguration for logging, JWT, Redis and PostgreSQL so services can opt in.
- gRPC Types β Shared definitions (e.g.,
ErrorDetail
,PagingRequest
) inprotos/shared/
; each service generates its own stubs.
π Publishing Strategy
The shared code is built as a Gradle Java library and published to GitHub Packages so all services can depend on it.
- Define a Gradle module (e.g.,
common-library
) with thejava-library
plugin. - Configure publishing to GitHub Packages using
maven-publish
:publishing { repositories { maven { name = "github" url = uri("https://maven.pkg.github.com/<org>/firemud") credentials { username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME") password = project.findProperty("gpr.key") as String? ?: System.getenv("TOKEN") } } } }
- Version releases using semantic versioning (e.g.,
1.0.0
) and publish from CI. - Automate tagging and version bumps using
semantic-release
. - Deploy artifacts to GitHub Packages via CI/CD. If needed, publish a separate
firemud-protos
artifact containing only the shared gRPC definitions.
This library aligns with the Common Package tasks and keeps code reuse simple across all FireMUD services.