08 - Services Reference

Reference for all 45+ services in MO.Ekyc.Infrastructure/Services/. Services are where all business logic lives.

Stage-Specific Services

StageServiceKey Methods / Responsibilities
0ArrivalServiceInitJourneyAsync() - creates Lead + LeadSession, captures UTM/device/fraud signals
1RegistrationServiceSignupAsync() - validates mobile/name, mobile dedup check, creates Lead + OTP
2OtpVerificationServiceVerifyOtpAsync() - verifies OTP, transitions state, triggers background checks, fires Decentro auto-verify on first attempt
2 asyncBackgroundCheckServiceRuns Zintlr phone-to-PAN, CSAFE fraud check, KRA lookup in parallel (Hangfire)
3EmailVerificationServiceEmail OTP generate/verify, supports Google OAuth and KRA prefill paths
4PanVerificationServiceVerifyAsync() - calls PAN provider chain (Zintlr → Hyperverge → NSDL → UTI → CVL KRA → NDML), applies name matching
5AadhaarVerificationServiceInitiateDigilockerAsync(), HandleDigilockerCallbackAsync(), UploadAadhaarAsync() (fallback for offline)
6BankVerificationServiceGetBankDetailsAsync(), SubmitBankAccountAsync(), InitiateReversePennyAsync(), CompleteReversePennyAsync(). Auto-promotes pre-verified Decentro bank to verified state.
7LivenessServiceInitiateLivenessAsync(), CompleteLivenessAsync() - face match via AINXT
8SignatureServiceValidateSignatureAsync() - AINXT signature validation
9PersonalDetailsServiceSubmit personal info (education, occupation, annual income, father/spouse name, marital status, PEP)
9NomineeServiceCRUD for nominees (max 3), PAN format verify (no NSDL lookup per BRD), share percentage validation
10IncomeProofServiceUpload/validate income proof PDFs, OneMoney account aggregator flow
11FinalValidationServiceCross-stage compliance check: C-SAFE, name match scores, STP scoring
12DocumentGenerationServiceOrchestrates KRA re-check, AOF PDF generation, PDF merging, eSign coordinate calculation
12AofPdfGenerationServiceRenders AOF PDF from template using iText7
12ClientCodeGenerationServiceGenerates MOSL client code for CBOS
12EsignCoordinateServiceMaps eSign signature positions to PDF page coordinates
12PdfMergingServiceMerges multiple PDFs into one package
13EsignServiceInitiateEsignAsync(), HandleEsignCallbackAsync(), GenerateClientCodeAsync(), WetSignAsync(). Uses EsignVendorRouter (Hyperverge → eMudhra → NSDL)
14AccountCreationServiceCreateAccountAsync(), GetAccountStatusAsync() - calls CBOS API to create Demat account
15ActivationServiceActivateAccountAsync() - final account activation, sends welcome notifications
15FundTransferServiceGetDefaultsAsync(), InitiatePaymentAsync(), CheckPaymentStatusAsync(), HandlePaymentCallbackAsync(). Routes EPay → Razorpay.

Common Services

ServicePurpose
JourneyTrackerRecords state transitions in lead_state_transitions, stage events in journey_stage_events
JourneyActivityChannel + ActivityLogWriterServiceAsync channel for activity logging. Writer is a HostedService that batches inserts into journey_activity_logs.
ActivityMessageGeneratorFormats human-readable activity log messages
OtpGeneratorServiceGenerates, stores, and verifies OTPs. Honors Sms.Mode = FIXED_OTP and Email.Mode = FIXED_OTP.
NameMatchServiceFuzzy name matching between KRA/PAN/bank/nominee names
StpDecisionServiceScores the lead and decides STP (straight-through) vs Non-STP (manual review)
FraudCheckServiceCSAFE fraud screening, IP velocity, device fingerprint
HashingServiceBCrypt hashing for mobile, PAN, passwords
InMemoryCacheServiceImplements ICacheService with in-memory dictionary
InMemoryOtpStoreImplements IOtpStore for OTP attempt tracking
BankAutoVerifyServiceDecentro mobile-to-bank lookup, triggered at Stage 2 for first-time leads only
NriValidationServiceRejects non-resident account types where required
MinorAccountServiceEnforces guardian details when applicant DOB < 18 years
LeadDeletionServiceGDPR cascade delete across all lead-related tables
HandoffLinkServiceGenerates Firebase Dynamic Links / Saathi short URLs for desktop → mobile handoff
CsJourneyServiceCustomer-service hold / release flow, expiry enforcement
VerifierServiceImplManual verifier queue: assign, approve, reject, send-back
ApplicationConfigServiceReads from application_config table for runtime-adjustable settings
FileStorageServiceAbstracts file storage (local disk or S3)
CampaignRoutingServiceRoutes IIBL / partner campaigns to specific provider chains
SmsTemplateServiceRenders SMS template strings with placeholder replacement
EmailNotificationServiceOrchestrator that picks the best email provider (Netcore → TheChecker → Karza → SMTP)
BackOfficeCheckServiceFires Zintlr, CSafe, KRA lookups in parallel
WarRoomServiceAggregates dashboard data: KPIs, stage distribution, recent journeys
SebiPdfServiceGenerates SEBI submission PDFs and tracks submission state

Service Registration Pattern

All services are registered in Program.cs with the correct lifetime (scoped for DB-bound services, singleton for stateless helpers, hosted for background workers).

backend/src/MO.Ekyc.Api/Program.csC#DI excerpt
builder.Services.AddScoped<ArrivalService>();
builder.Services.AddScoped<RegistrationService>();
builder.Services.AddScoped<OtpVerificationService>();
builder.Services.AddScoped<EmailVerificationService>();
builder.Services.AddScoped<PanVerificationService>();
builder.Services.AddScoped<AadhaarVerificationService>();
builder.Services.AddScoped<BankVerificationService>();
builder.Services.AddScoped<BankAutoVerifyService>();
// ... 20+ more stage services

builder.Services.AddScoped<IJourneyTracker, JourneyTracker>();
builder.Services.AddScoped<IHashingService, HashingService>();
builder.Services.AddSingleton<ICacheService, InMemoryCacheService>();
builder.Services.AddSingleton<IOtpStore, InMemoryOtpStore>();

// Hosted (background) services
builder.Services.AddHostedService<ActivityLogWriterService>();