src/BuildingBlocks/* altında 20 bağımsız altyapı paketi bulunur. Her biri tek bir kesişen sorumluluğu (caching, messaging, identity, observability, util) kapsüller; Application/Infrastructure katmanları bu paketleri AddXxx(...) uzantılarıyla Program.cs’de wire-up eder. Paketler iş kuralı içermez ve Application/Domain projelerine referans vermez — yeni bir projeye olduğu gibi taşınabilir.
Tüm paketler
| Paket | Grup | Amaç |
|---|---|---|
BuildingBlocks.Caching | Caching | IHybridRequestCache — L1 (in-process) + L2 (Redis) birleşik cache, tag-based invalidation, multi-instance broadcast hook |
BuildingBlocks.Caching.Redis | Caching | Redis IDistributedCache backend’i, request/database/socket cache implementasyonları, distributed lock |
BuildingBlocks.Contracts.Events | Messaging | IntegrationEvent base + IIntegrationEventHandler<T> kontratları (cross-service) |
BuildingBlocks.EventBus | Messaging | Event bus soyutlaması (IEventBus), subscription registry, builder pattern |
BuildingBlocks.EventBus.MassTransit.RabbitMq | Messaging | Aktif — MassTransit + RabbitMQ ile integration event dağıtımı, EF Outbox, retry/redelivery |
BuildingBlocks.EventBus.EventBusRabbitMQ | Messaging | Legacy — ham RabbitMQ.Client tabanlı event bus (MassTransit tarafından değiştirildi) |
BuildingBlocks.Keycloak | Identity | Çift-realm Keycloak SSO (Vatandaş + Personel), claims transformation, ICurrentUserService |
BuildingBlocks.Jwt | Identity | Çok-şemalı JWT auth (Backoffice + OTPChallenge), token üretimi/doğrulama |
BuildingBlocks.OAuth | Identity | OAuth2 + PKCE soyutlaması (Google, Meta) — IOAuthClient<TUserInfo> |
BuildingBlocks.Otp | Identity | HMAC-SHA256 OTP üretimi, hash’leme, rate-limit ayarları |
BuildingBlocks.DeviceDetector | Identity | IP çözümleme, cihaz parmak izi, trust/risk değerlendirme |
BuildingBlocks.Security.BotProtection | Identity | Google reCAPTCHA v3 doğrulama (Polly resilient HTTP) |
BuildingBlocks.Specification | Util | Ardalis.Specification tabanlı generic spec pattern + cache entegrasyonu |
BuildingBlocks.Time | Util | IClock saat soyutlaması — SystemClock / FakeClock |
BuildingBlocks.FileServer | Util | Statik dosya sunumu, auth-aware özel file provider |
BuildingBlocks.Hangfire.MediatR.Extensions | Util | Hangfire + MediatR köprüsü — IRequest’leri arka plan job olarak serialize etme |
BuildingBlocks.Logging.Serilog | Observability | Serilog kurulumu, Seq sink, HTTP request enrichment |
BuildingBlocks.Monitoring.Prometheus | Observability | Prometheus HTTP metrik middleware’i + /metrics endpoint |
BuildingBlocks.Observability | Observability | OpenTelemetry metrics/tracing pipeline, health→gauge köprüsü |
BuildingBlocks.HealthChecks | Observability | K8s-uyumlu health check endpoint’leri (live/ready/startup/external) |
Gruplama
Öne çıkanlar
Caching
Hibrit L1+L2 cache, tag invalidation, multi-instance broadcast.
Event Bus (MassTransit)
RabbitMQ topic exchange + EF Outbox + retry/DLX.
Keycloak
Çift-realm SSO, claims transformation, çift JwtBearer şeması.
OTP
HMAC-SHA256 stateless doğrulama, rate-limit.
BuildingBlocks.EventBus.EventBusRabbitMQ legacy’dir ve yeni geliştirmede kullanılmaz. Aktif integration event altyapısı BuildingBlocks.EventBus.MassTransit.RabbitMq’tır (EF Outbox + delayed redelivery destekli). Yeni event publish/subscribe için her zaman MassTransit paketini kullanın.Ortak desenler
Tüm paketler aynı sözleşmelere uyar:- Options pattern — her paket
IConfiguration→IOptions<T>binding’i yapar (services.Configure<TOptions>(...)). AddXxx(...)uzantısı — DI kaydıIServiceCollectiondöner, fluent chaining’e izin verir.- Kayıt sırası önemli — özellikle cache:
AddRedisCache(L2) ÖNCE, sonraAddCache, sonraAddHybridCache. Aksi halde L1-only çalışır.
İlgili
Caching mimarisi
L1/L2 stratejisi, invalidation ve multi-instance detayları.
Event akışı
Domain event → integration event → Outbox → RabbitMQ.