Referans · metot-metot

apps/api — Public API

Her tip için görev + metot metot ne yaptığı + hangi arayüzlere bağlı. Katmanlar: FinevoConnect.Yos.Api (giriş) → FinevoConnect.Yos.Application (servis) → FinevoConnect.Yos.Infrastructure (DB/güvenlik/entegrasyon).

Boru hattı: CorrelationId → ExceptionHandling → RequestLogging → LocaleResolution → Authentication → Authorization → ValidationFilter/IdempotencyFilter → Controller.

Controller'lar

AuthControllerFinevoConnect.Yos.Api/Controllers

Kayıt/token uçları — hepsi IAuthService'e delege eder. Ayrı login yok; register hem kayıt hem giriştir.

Register(req, appKey)X-App-Key başlığı + userKey/customerNo alır. Kullanıcı yoksa oluşturur, varsa mevcut kullanıcı için token çifti döner. Token gerekmez.
Refresh(req)Yenileme token'ı ile yeni erişim token'ı.
Logout(req)Kullanıcının yenileme token'larını iptal eder (JWT gerekir).
Me()Oturumdaki kullanıcının profilini (userKey, customerNo, görünen ad, dil) döner.
Bağlı: IAuthService
HhsConnectionsControllerFinevoConnect.Yos.Api/Controllers

Rıza akışı uçları.

Create(req)Yeni banka bağlantısı (rıza) başlatır; redirect'te authorizationUrl döner.
GetById(id, fresh)Bağlantı detayı; fresh=true ise canlı durum senkronu.
Callback(query)GKD onay dönüşü (state+consentStatus+authCode); token gerekmez.
Delete(id)Rızayı iptal eder (gerekirse HHS'e cancel niyeti).
Bağlı: IHhsConnectionService
AccountsController / CardsController / TransactionsControllerFinevoConnect.Yos.Api/Controllers

Hesap/kart/işlem okuma uçları; hepsi ?fresh=true destekler (canlı sorgu).

List(fresh) / GetByIdBağlı tüm bankalardan liste/detay; fresh=true → LiveRefreshCoordinator.
Transactions(id, cursor)İmleç sayfalama; yalnız ilk sayfada canlı tazeleme.
Detail(id) [Cards]Kart detayı: limit/borç + puan + taksit birleştirir.
Bağlı: IAccountAggregationService, ICardService, ITransactionService
PaymentOrders / Recurring / ForwardDated ControllersFinevoConnect.Yos.Api/Controllers

Ödeme aileleri; Create'te Idempotency-Key; her ödeme standalone rıza.

Create(req, Idempotency-Key)Ödeme emri/talimatı oluşturur; onay akışı başlar.
List / GetById(fresh)Sayfalı liste + durum (fresh=true canlı).
Callback(query)Ödeme onay dönüşü → aktivasyon niyeti.
Cancel/Delete(id)İptal (iptal-edilebilirlik kontrolüyle).
Bağlı: IPaymentOrderService, IRecurringPaymentService, IForwardDatedPaymentService
HhsController / HealthControllerFinevoConnect.Yos.Api/Controllers

Banka listesi + sağlık.

List / GetByCodeEtkin bankaların listesi/detayı.
Live / ReadyLiveness (ayakta mı) / readiness (DB bağlı mı).
Bağlı: IHhsRegistryService

Middleware & Filter'lar

CorrelationIdMiddlewareFinevoConnect.Yos.Api/Middleware

İzlenebilirlik kimliği.

InvokeAsyncIIdGenerator ile 32-hex correlation_id üretir, HttpContext.Items'e koyar ve Serilog LogContext'e push eder → isteğin tüm logları bu id'yi taşır.
Bağlı: IIdGenerator
ExceptionHandlingMiddlewareFinevoConnect.Yos.Api/Middleware

Tek merkezî hata dönüştürücü.

InvokeAsyncSonraki middleware'leri try/catch ile sarar; hata yakalanınca HandleAsync çağırır.
Map(ex)Exception tipi → (HTTP status, error code): ValidationException→400, NotFoundException→404, ConflictException→409, BusinessRuleException→422, OhvpsIntegrationException→503, HhsAuthorizationUrlUnavailable→504, diğer→500.
HandleAsyncErrorLocalizer ile dile göre başlık/detay alır, RFC 7807 ProblemDetails (code+traceId) yazar; 5xx→LogError, 4xx→LogInformation (log_kind=error).
Bağlı: IErrorLocalizer
RequestLoggingMiddlewareFinevoConnect.Yos.Api/Middleware

İstek/yanıt logu.

InvokeAsyncİstek gövdesini buffer'lar, yanıt gövdesini MemoryStream ile yakalar; method/path/status/süre + gövdeler (LogScrubber ile redakte) loglar (log_kind=request); asla isteği bozmaz.
Bağlı: ICurrentUser
LocaleResolutionMiddlewareFinevoConnect.Yos.Api/Middleware

Dil çözümü.

InvokeAsync / ResolveLocale?lang veya Accept-Language → desteklenen dil (tr/en); HttpContext.Items[locale] + CurrentUICulture; Content-Language yanıt başlığı.
ValidationFilterFinevoConnect.Yos.Api/Filters

Girdi doğrulama.

OnActionExecutionAsyncAction argümanları için IValidator<T> bulur+çalıştırır; hata varsa ValidationException (400 + alan-bazlı) fırlatır.
Bağlı: FluentValidation
IdempotencyFilterFinevoConnect.Yos.Api/Filters

Yazma tekrar koruması.

OnActionExecutionAsyncPOST/PUT/PATCH/DELETE'te Idempotency-Key + gövde-hash'i; mevcut+tamamlanmış → cache yanıtı döner; TryReserve (unique) → çalıştır → CompleteAsync; hata → ReleaseAsync (TOCTOU guard).
Bağlı: IIdempotencyStore, IFeatureFlags

Uygulama servisleri

HhsConnectionServiceFinevoConnect.Yos.Application/HhsConnections

Rıza yaşam döngüsünün API tarafı.

CreateAsyncHHS'i çözer, izinleri doğrular (OhvpsPermissionRules), aktif rıza kontrolü; yeni HhsConnection + izinler + ConsentCreate niyeti AYNI tx'te; redirect ise TriggerAndAwaitAuthorizationUrlAsync.
TriggerAndAwaitAuthorizationUrlAsyncHangfire immediate trigger atar, batch'in authorizationUrl'i DB'ye yazmasını bounded-poll ile bekler (~5sn); gelmezse 504.
GetByIdAsyncBağlantıyı okur; fresh ise LiveRefreshCoordinator (ConnectionStatus kind) ile canlı durum; Reloaded ise DetachAll+yeniden oku.
HandleCallbackAsyncGkdCallbackProcessor ile state tüketir, onay-echo doğrular, AuthorizationComplete niyeti + immediate trigger.
DeleteAsyncMarkCancelled + gerekirse ConsentCancel niyeti.
Bağlı: ISyncIntentService, ILiveRefreshCoordinator, IGkdCallbackProcessor, IHhsResolver, ITokenProtector
AccountAggregationServiceFinevoConnect.Yos.Application/Accounts

Çok-banka hesap birleştirme + canlı tazeleme.

ListAsync(userId, fresh)Kullanıcının hesaplarını okur; bağlı bağlantılar için BuildAccountLiveQueries kurar; LiveRefreshCoordinator.ResolveAsync ile canlı/cache; Reloaded ise DB'den yeniden okur; Freshness+AsOf ile döner.
GetByIdAsyncTek hesap + canlı tazeleme sonucu.
RefreshAsyncBağlı tüm bağlantılara refresh niyeti + immediate trigger (elle yenileme).
Bağlı: IAccountRepository, ILiveRefreshCoordinator, ISyncIntentService
CardServiceFinevoConnect.Yos.Application/Cards

Kart + detay/işlem/puan/taksit.

ListAsync / GetByIdAsyncKart izni (CardInfo) kontrolü + canlı sorgu (Cards kind).
GetDetailAsyncBuildDetailItemAsync ile CardDetail+CardPoints+CardInstallments birleştirir; CardDetail kind canlı.
ListTransactionsAsyncİmleç sayfalama; yalnız ilk sayfada CardTransactions canlı.
BuildCardLiveQueriesAsyncBağlı+izinli ise LiveQueryRequest üretir; değilse boş (cache).
Bağlı: ICardRepository (+detail/point/installment), ILiveRefreshCoordinator
PaymentOrderServiceFinevoConnect.Yos.Application/PaymentOrders

Ödeme emri (standalone rıza).

CreateAsyncTutar/IBAN doğrular; YENİ ConsentType.Payment bağlantı + PaymentOrder + PaymentOrderSubmit niyeti + PaymentOrderCreatedEvent outbox — hepsi Serializable tx; redirect ise authorizationUrl bounded-wait.
GetByIdAsyncÖdeme + fresh ise durum canlı senkronu (odmStm→paymentSystem).
HandleCallbackAsyncGkdCallbackProcessor → PaymentOrderAuthorizationComplete niyeti.
Bağlı: IPaymentOrderRepository, IOutboxStore, ILiveRefreshCoordinator
SyncIntentServiceFinevoConnect.Yos.Application/SyncIntents

Niyet kuyruğa yazma.

EnqueueAsync<TPayload>GroupId'yi hedef bağlantıdan çözer (FindGroupIdByIdAsync → rıza-sabit), TraceId'yi Activity'den alır, payload'ı JSON'a serialize eder, SyncIntent kaydını AddAsync (SaveChanges çağıran servise ait — tx-içi).
Bağlı: ISyncIntentRepository, IHhsConnectionRepository, IRequestCorrelation

Ortak (koordinatör/callback/yardımcı)

LiveRefreshCoordinatorFinevoConnect.Yos.Application/Common/LiveRefresh

Canlı/cache kararının tek yeri (ADR-YOS-051/063).

ResolveAsync(fresh, asOf, enqueueIntents, buildLiveQueries)asOf tazelik penceresi içindeyse Cached döner. fresh + buildLiveQueries varsa → ResolveViaLiveQueryAsync. Aksi/autonomous → intent+trigger yolu.
ResolveViaLiveQueryAsyncbuildLiveQueries() ile istek listesi üretir; her biri için ILiveQueryClient.QueryAsync (senkron batch RPC); hepsi başarılı→Live+Reloaded; herhangi başarısız→autonomous intent kick + Stale+Refreshing.
TriggerAndAwaitRefreshAsyncUserRequested niyet(ler)i + immediate trigger; niyet durumunu ~30sn bounded-poll; Consumed→Live, Failed/timeout→Stale (eski/fallback yol).
KickBackgroundRefreshAsyncAutonomous niyet + trigger; beklemeden döner (arka plan tazeleme).
Bağlı: ILiveQueryClient, ISyncIntentRepository, IBackgroundJobClient
GkdCallbackProcessorFinevoConnect.Yos.Application/Common/Gkd

Ortak GKD callback işleme.

ProcessAsync<TEntity>state ile kaynağı tüketir (ConsumeByStateCode), onay-echo doğrular (değilse hata), aktivasyon niyetini stage eder, commit sonrası FireImmediateTrigger.
FireImmediateTriggerHangfire ISyncIntentImmediateTrigger enqueue; enqueue hatası yutulur (IExceptionLogger'a bir kez loglanır) — kullanıcıya hızlı 2xx.
Bağlı: IBackgroundJobClient, IExceptionLogger
LogScrubberFinevoConnect.Yos.Application/Common/Logging

Hassas veri redaksiyonu (saf yardımcı).

Scrub(input)Bearer/JWT/sk-/AWS/IBAN/TCKN/VKN/PAN regex'leri + JSON alan-bazlı (password/token/secret/cvv/identityValue → [REDACTED]). Enricher tarafından her string log property'sine uygulanır.
ErrorLocalizerFinevoConnect.Yos.Application/Localization

Çok-dilli hata metni.

Localize(code, locale)FrozenDictionary'den kod+dil ile başlık/detay; dilde yoksa tr fallback; kod hiç yoksa kodu döner (LocalizationIntegrityCheck boot-gate).

Altyapı (DB/güvenlik/entegrasyon)

LiveQueryClientFinevoConnect.Yos.Infrastructure.Integration

E canlı-okuma senkron istemcisi.

QueryAsync(req)Named HttpClient ile POST /internal/live-query + X-Internal-Secret; 15sn timeout; 200→LiveQueryResponse parse; hata/timeout/non-200→{Success=false, Outcome=unreachable} (fırlatmaz — çağıran cache'e düşer).
Bağlı: IHttpClientFactory (batch-live-query)
UnitOfWorkFinevoConnect.Yos.Infrastructure/Persistence

İşlem sınırı.

SaveChangesAsync / TrySaveChangesAsyncKaydet; Try* DbUpdateConcurrencyException'ı yakalayıp false döner (kaybeden tx no-op).
DetachAllChange-tracker'ı temizler — canlı-okuma sonrası batch'in yazdığı taze veriyi görmek için.
BeginTransactionAsync(level)Serializable tx (ödeme create atomikliği).
Bağlı: AppDbContext
IdempotencyStoreFinevoConnect.Yos.Infrastructure/Persistence/Stores

Yazma tekrar koruması.

FindAsync / TryReserveAsyncVar mı bak; yoksa unique-constraint ile rezerve et (yarış güvenli).
CompleteAsync / ReleaseAsyncYanıtı yaz (tamamlandı) / hata olursa kaydı sil.
Bağlı: AppDbContext, IClock
DataProtectorTokenProtectorFinevoConnect.Yos.Infrastructure/Security

At-rest şifreleme.

ProtectToken / UnprotectTokenHHS token'ı şifrele/çöz (purpose yos.hhs.token).
ProtectIdentity / UnprotectIdentityTCKN/VKN/IBAN şifrele/çöz (purpose yos.pii.identity). Anahtar halkası batch ile paylaşımlı.
Bağlı: IDataProtectionProvider
JwtTokenGeneratorFinevoConnect.Yos.Infrastructure/Security/Auth

JWT üretimi.

GenerateAccessToken(user)Kullanıcı claim'leri + kısa ömür (dk); imzalı erişim token'ı.
GenerateRefreshToken / HashRefreshTokenRastgele yenileme token'ı + SHA256 hash (DB'de hash saklanır).
Bağlı: JwtOptions
HhsResolver / SystemClock / ConfigurationFeatureFlagsFinevoConnect.Yos.Infrastructure

Yardımcılar.

HhsResolver.ResolveAsyncHHS kodu → entity (MemoryCache 15dk).
SystemClock.NowEurope/Istanbul saatli DateTimeOffset.
FeatureFlags.IsEnabled(key)IdempotencyEnforcement/EnableMtls/EnableJws/AutoEventSubscription.
Bağlı: IMemoryCache, IConfiguration