03 - Project Tour
A guided walk through the backend solution. By the end you will know what each of the 5 projects does and where to look for anything.
Solution Structure
backend/Tree
backend/
├── MO.Ekyc.sln # Solution file
├── src/
│ ├── MO.Ekyc.Api/ # Web API (controllers, filters, middleware, Program.cs)
│ ├── MO.Ekyc.Application/ # CQRS commands, results, interfaces
│ ├── MO.Ekyc.Domain/ # 75 POCO entities, no dependencies
│ ├── MO.Ekyc.Infrastructure/ # EF Core, services, external providers, Hangfire
│ └── MO.Ekyc.Shared/ # ApiRoutes, ErrorCodes, ApiResponse, helpers
├── tests/
│ ├── MO.Ekyc.Api.Tests/ # Controller integration tests
│ ├── MO.Ekyc.IntegrationTests/ # DB + external provider integration
│ └── MO.Ekyc.UnitTests/ # Service unit tests
└── database/ # Manual schema scripts (if present)
Clean Architecture
Dependencies flow inward: Api depends on Application and Infrastructure. Both depend on Domain. Shared is a leaf project. See 04 - Architecture.
MO.Ekyc.Api (Presentation Layer)
| Folder | Contents |
|---|---|
Controllers/Stage0-15/ | ~17 stage-specific controllers (ArrivalController, RegistrationController, BankController, etc.) |
Controllers/Common/ | JourneyController, HandoffController, LeadDeletionController, DevController, OneMoneyController, SebiController |
Controllers/Admin/ | AnalyticsController, ApplicationSearchController, LookupController, MockController, ProviderConfigController, StageConfigController, VerifierController |
Controllers/WarRoom/ | WarRoomController, WarRoomAuthController |
Filters/ | StageValidationFilter, AdminAuthorizationFilter |
Middleware/ | CorrelationIdMiddleware, ExceptionHandlingMiddleware, RequestLoggingMiddleware, SessionRefreshMiddleware |
Program.cs | DI composition root (~818 lines) - registers services, providers, HttpClients, auth, Hangfire, middleware pipeline |
appsettings.json | Production defaults for JWT, DB, CORS, external providers |
appsettings.Development.json | Dev overrides (mock mode, fixed OTP, local connection string) |
MO.Ekyc.Application (Business Layer)
Pure business logic contracts and models. No external dependencies.
| Folder | Contents |
|---|---|
Interfaces/ | IJourneyTracker, ICacheService, IHashingService, IOtpStore, IPaymentService, IDownstreamEventPublisher, INotificationService, IApplicationConfigService, IFileStorageService |
Models/Commands/ | SignupCommand, VerifyOtpCommand, SaveBankAccountCommand, etc. (input DTOs) |
Models/Results/ | SignupResult, VerifyOtpResult, BankVerificationResult, FundTransferDefaults, etc. (output DTOs) |
MO.Ekyc.Domain (Domain Layer)
75 POCO entity classes. No dependencies on anything.
MO.Ekyc.Infrastructure
| Folder | Contents |
|---|---|
Persistence/EkycDbContext.cs | EF Core DbContext with 75 DbSets. Default schema ekyc. Snake_case naming via EFCore.NamingConventions. |
Persistence/Configurations/ | EntityTypeConfiguration<T> classes applied in OnModelCreating |
Services/StageN/ | Stage-specific services (RegistrationService, PanVerificationService, BankVerificationService, etc.) |
Services/Common/ | Shared services (JourneyTracker, HashingService, BankAutoVerifyService, NameMatchService, OtpGenerator, VerifierService) |
ExternalProviders/ | 60+ provider implementations grouped by category (Pan, Bank, FaceMatch, Esign, Sms, Payment, AccountAggregator) |
ExternalProviders/Common/ | ProviderChainExecutor, CircuitBreaker, ApiAuditLogger, ProviderHealthTracker |
BackgroundJobs/ | Hangfire jobs, HostedServices (e.g., ActivityLogWriterService) |
MO.Ekyc.Shared
Constants, helpers, generic wrappers. Zero dependencies.
Constants/ApiRoutes.cs | All endpoint route strings |
Constants/ErrorCodes.cs | Frontend + backend error codes (FE_OTP_WRONG, BE_REG_DUPLICATE, CS_NSDL_DOWN) |
Constants/StageDefinitions.cs | Stage numbers + display names + progress percentages |
Models/ApiResponse.cs | Generic ApiResponse<T> wrapper returned by every endpoint |
Helpers/MaskingHelper.cs | PAN/mobile/email masking for logs |
Extensions/StringExtensions.cs | IsValidPanFormat, IsValidIfsc validation helpers |
Key NuGet Packages
| Package | Version | Why |
|---|---|---|
| Microsoft.EntityFrameworkCore | 8.0.* | ORM |
| Npgsql.EntityFrameworkCore.PostgreSQL | 8.0.* | PostgreSQL provider |
| EFCore.NamingConventions | 8.0.* | Snake_case table/column names |
| Hangfire.AspNetCore + PostgreSql | 1.8.23, 1.21.1 | Background jobs with Postgres storage |
| Serilog.AspNetCore | 10.0.0 | Structured logging with CorrelationId |
| Swashbuckle.AspNetCore | 6.5.0 | Swagger/OpenAPI docs at /swagger |
| JwtBearer Authentication | 8.0.* | JWT validation |
| Confluent.Kafka | 2.13.2 | Downstream event publishing |
| Polly | 8.6.6 | Retry / circuit breaker for HttpClients |
| itext7 | 8.0.5 | AOF PDF generation |
| FluentValidation.AspNetCore | 11.3.1 | Request validation |