08 - Services Reference
Reference for all 45+ services in MO.Ekyc.Infrastructure/Services/. Services are where all business logic lives.
Stage-Specific Services
| Stage | Service | Key Methods / Responsibilities |
|---|---|---|
| 0 | ArrivalService | InitJourneyAsync() - creates Lead + LeadSession, captures UTM/device/fraud signals |
| 1 | RegistrationService | SignupAsync() - validates mobile/name, mobile dedup check, creates Lead + OTP |
| 2 | OtpVerificationService | VerifyOtpAsync() - verifies OTP, transitions state, triggers background checks, fires Decentro auto-verify on first attempt |
| 2 async | BackgroundCheckService | Runs Zintlr phone-to-PAN, CSAFE fraud check, KRA lookup in parallel (Hangfire) |
| 3 | EmailVerificationService | Email OTP generate/verify, supports Google OAuth and KRA prefill paths |
| 4 | PanVerificationService | VerifyAsync() - calls PAN provider chain (Zintlr → Hyperverge → NSDL → UTI → CVL KRA → NDML), applies name matching |
| 5 | AadhaarVerificationService | InitiateDigilockerAsync(), HandleDigilockerCallbackAsync(), UploadAadhaarAsync() (fallback for offline) |
| 6 | BankVerificationService | GetBankDetailsAsync(), SubmitBankAccountAsync(), InitiateReversePennyAsync(), CompleteReversePennyAsync(). Auto-promotes pre-verified Decentro bank to verified state. |
| 7 | LivenessService | InitiateLivenessAsync(), CompleteLivenessAsync() - face match via AINXT |
| 8 | SignatureService | ValidateSignatureAsync() - AINXT signature validation |
| 9 | PersonalDetailsService | Submit personal info (education, occupation, annual income, father/spouse name, marital status, PEP) |
| 9 | NomineeService | CRUD for nominees (max 3), PAN format verify (no NSDL lookup per BRD), share percentage validation |
| 10 | IncomeProofService | Upload/validate income proof PDFs, OneMoney account aggregator flow |
| 11 | FinalValidationService | Cross-stage compliance check: C-SAFE, name match scores, STP scoring |
| 12 | DocumentGenerationService | Orchestrates KRA re-check, AOF PDF generation, PDF merging, eSign coordinate calculation |
| 12 | AofPdfGenerationService | Renders AOF PDF from template using iText7 |
| 12 | ClientCodeGenerationService | Generates MOSL client code for CBOS |
| 12 | EsignCoordinateService | Maps eSign signature positions to PDF page coordinates |
| 12 | PdfMergingService | Merges multiple PDFs into one package |
| 13 | EsignService | InitiateEsignAsync(), HandleEsignCallbackAsync(), GenerateClientCodeAsync(), WetSignAsync(). Uses EsignVendorRouter (Hyperverge → eMudhra → NSDL) |
| 14 | AccountCreationService | CreateAccountAsync(), GetAccountStatusAsync() - calls CBOS API to create Demat account |
| 15 | ActivationService | ActivateAccountAsync() - final account activation, sends welcome notifications |
| 15 | FundTransferService | GetDefaultsAsync(), InitiatePaymentAsync(), CheckPaymentStatusAsync(), HandlePaymentCallbackAsync(). Routes EPay → Razorpay. |
Common Services
| Service | Purpose |
|---|---|
JourneyTracker | Records state transitions in lead_state_transitions, stage events in journey_stage_events |
JourneyActivityChannel + ActivityLogWriterService | Async channel for activity logging. Writer is a HostedService that batches inserts into journey_activity_logs. |
ActivityMessageGenerator | Formats human-readable activity log messages |
OtpGeneratorService | Generates, stores, and verifies OTPs. Honors Sms.Mode = FIXED_OTP and Email.Mode = FIXED_OTP. |
NameMatchService | Fuzzy name matching between KRA/PAN/bank/nominee names |
StpDecisionService | Scores the lead and decides STP (straight-through) vs Non-STP (manual review) |
FraudCheckService | CSAFE fraud screening, IP velocity, device fingerprint |
HashingService | BCrypt hashing for mobile, PAN, passwords |
InMemoryCacheService | Implements ICacheService with in-memory dictionary |
InMemoryOtpStore | Implements IOtpStore for OTP attempt tracking |
BankAutoVerifyService | Decentro mobile-to-bank lookup, triggered at Stage 2 for first-time leads only |
NriValidationService | Rejects non-resident account types where required |
MinorAccountService | Enforces guardian details when applicant DOB < 18 years |
LeadDeletionService | GDPR cascade delete across all lead-related tables |
HandoffLinkService | Generates Firebase Dynamic Links / Saathi short URLs for desktop → mobile handoff |
CsJourneyService | Customer-service hold / release flow, expiry enforcement |
VerifierServiceImpl | Manual verifier queue: assign, approve, reject, send-back |
ApplicationConfigService | Reads from application_config table for runtime-adjustable settings |
FileStorageService | Abstracts file storage (local disk or S3) |
CampaignRoutingService | Routes IIBL / partner campaigns to specific provider chains |
SmsTemplateService | Renders SMS template strings with placeholder replacement |
EmailNotificationService | Orchestrator that picks the best email provider (Netcore → TheChecker → Karza → SMTP) |
BackOfficeCheckService | Fires Zintlr, CSafe, KRA lookups in parallel |
WarRoomService | Aggregates dashboard data: KPIs, stage distribution, recent journeys |
SebiPdfService | Generates 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>();