π 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 β
JwtUtilfor token generation/verification and role helpers aligned with the Authentication Design. - Database Connectors β
DatabaseAutoConfigurationwithPostgresPropertiesandRedisPropertiesreduces boilerplate setup. Defaults suit Docker Compose but any field can be overridden withFIREMUD_POSTGRES_*orFIREMUD_REDIS_*environment variables. - gRPC Interceptors β
LoggingInterceptorandMetricsInterceptorprovide consistent instrumentation for every service. - Service Discovery & Config β Central location for discovering other services and handling environment properties.
ServiceEndpointsPropertiesloads 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-libraryplugin. - 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-protosartifact containing only the shared gRPC definitions.
This library aligns with the Common Package tasks and keeps code reuse simple across all FireMUD services.