NovusCore.AuditService.Contracts
1.0.1
dotnet add package NovusCore.AuditService.Contracts --version 1.0.1
NuGet\Install-Package NovusCore.AuditService.Contracts -Version 1.0.1
<PackageReference Include="NovusCore.AuditService.Contracts" Version="1.0.1" />
<PackageVersion Include="NovusCore.AuditService.Contracts" Version="1.0.1" />
<PackageReference Include="NovusCore.AuditService.Contracts" />
paket add NovusCore.AuditService.Contracts --version 1.0.1
#r "nuget: NovusCore.AuditService.Contracts, 1.0.1"
#:package NovusCore.AuditService.Contracts@1.0.1
#addin nuget:?package=NovusCore.AuditService.Contracts&version=1.0.1
#tool nuget:?package=NovusCore.AuditService.Contracts&version=1.0.1
RetireAix Audit Service
Centralized audit microservice for the RetireAix platform. This service consumes audit events from 40+ microservices via Amazon SQS, enriches and stores them in PostgreSQL, and provides query APIs for compliance, debugging, and reporting.
Architecture
- AuditService.API: REST API for querying audit logs
- AuditService.Worker: Background service that consumes SQS messages and stores audit logs
- AuditService.Contracts: Shared NuGet package for audit event contracts
- AuditService.Application: Business logic and CQRS handlers
- AuditService.Domain: Domain entities
- AuditService.Infrastructure: Data access with EF Core (writes) and Dapper (reads)
Technology Stack
- .NET 8
- PostgreSQL 16
- Amazon SQS
- Entity Framework Core 8 (writes)
- Dapper (reads)
- MediatR (CQRS)
- FluentValidation
- Serilog
Quick Start with Docker
# Start all services (PostgreSQL, LocalStack, API, Worker)
docker-compose up -d
# Check API health
curl http://localhost:5100/health
# View API documentation
open http://localhost:5100/swagger
Local Development Setup
Prerequisites
- .NET 8 SDK
- PostgreSQL 16
- Docker and Docker Compose (for LocalStack)
- AWS CLI (for testing)
Running Locally
- Start infrastructure:
docker-compose up -d postgres localstack localstack-init
- Run API:
cd src/AuditService.API
dotnet run
- Run Worker (in another terminal):
cd src/AuditService.Worker
dotnet run
Testing SQS Integration
Send a test message to LocalStack SQS:
aws --endpoint-url=http://localhost:4566 sqs send-message \
--queue-url http://localhost:4566/000000000000/dev_retireaix-audit-queue \
--message-body '{"entityName":"TestEntity","recordId":"123","action":"Added","sourceService":"TestService","timestamp":"2025-01-01T00:00:00Z"}'
Check DLQ for failed messages:
aws --endpoint-url=http://localhost:4566 sqs receive-message \
--queue-url http://localhost:4566/000000000000/dev_retireaix-audit-dlq
API Endpoints
Query Endpoints
GET /api/audit/entity/{entityName}/{recordId}- Get audit trail for entityGET /api/audit/user/{userId}- Get audit events by userGET /api/audit/trace/{traceId}- Get audit events by trace IDGET /api/audit/search- Advanced search with filtersGET /api/audit/services- Get service summariesGET /api/audit/entities- Get entity summariesGET /health- Health check
Example Query
# Get audit trail for an entity
curl "http://localhost:5100/api/audit/entity/Employer/123?page=1&pageSize=10"
# Search audit events
curl "http://localhost:5100/api/audit/search?from=2025-01-01&to=2025-12-31&sourceService=PlanSponsor"
Database Setup
The database schema is automatically created when PostgreSQL starts using the migration scripts in the migrations/ folder.
To manually run migrations:
psql -h localhost -U postgres -d audit_db -f migrations/000_create_audit_logs.sql
psql -h localhost -U postgres -d audit_db -f migrations/001_add_source_service.sql
Building the Solution
# Restore dependencies
dotnet restore
# Build all projects
dotnet build
# Run tests (when available)
dotnet test
# Pack Contracts NuGet package
cd src/AuditService.Contracts
dotnet pack -c Release
Configuration
API (appsettings.json)
{
"ConnectionStrings": {
"AuditDb": "Host=localhost;Database=******;Username=******;Password=xxx"
}
}
Worker (appsettings.json)
{
"ConnectionStrings": {
"AuditDb": "Host=localhost;Database=******;Username=******;Password=xxx"
},
"Aws": {
"Region": "us-east-1",
"Sqs": {
"QueueUrl": "**************",
"DeadLetterQueueUrl": "**************"
}
}
}
Project Structure
AuditService/
├── src/
│ ├── AuditService.Contracts/ # Shared contracts (NuGet package)
│ ├── AuditService.Domain/ # Domain entities
│ ├── AuditService.Application/ # CQRS handlers, DTOs, interfaces
│ ├── AuditService.Infrastructure/ # EF Core, Dapper, repositories
│ ├── AuditService.API/ # REST API
│ └── AuditService.Worker/ # SQS consumer
├── migrations/ # Database migrations
├── docker-compose.yml
└── AuditService.sln
Publishing Contracts Package
cd src/AuditService.Contracts
dotnet pack -c Release
dotnet nuget push bin/Release/AuditService.Contracts.1.0.0.nupkg --source "your-nuget-feed"
Monitoring
- Health endpoint:
GET /health - Logs: Console output via Serilog
- Metrics: Available via health checks
License
Proprietary - RetireAix Platform
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on NovusCore.AuditService.Contracts:
| Package | Downloads |
|---|---|
|
NovusCore.AuditService.ChangeTracking
EF Core change tracking and audit interceptor for RetireAix microservices |
GitHub repositories
This package is not used by any popular GitHub repositories.