Skip to content

Backend Overview

The MedRegia backend is a .NET 10 modular monolith — a single ASP.NET Core process that contains multiple clearly-bounded modules, each responsible for a distinct domain.

Project Structure

backend/
├── MedRegia.API/               ← Main API project
│   ├── Modules/                ← One folder per bounded context
│   │   ├── Identity/
│   │   ├── VendorManagement/
│   │   ├── Settings/
│   │   ├── Dashboard/
│   │   ├── Reports/
│   │   ├── Onboarding/
│   │   └── UserProfile/
│   ├── Infrastructure/
│   │   ├── DependencyInjection.cs
│   │   └── Persistence/
│   │       ├── DbConnectionFactory.cs
│   │       └── EnumTypeHandlers.cs
│   ├── Filters/
│   │   ├── RequirePermissionAttribute.cs
│   │   └── PermissionAuthorizationFilter.cs
│   ├── Shared/
│   │   ├── Result/PagedResult.cs
│   │   ├── Constants/
│   │   ├── Extensions/
│   │   ├── Helpers/
│   │   └── Services/
│   └── Program.cs
├── MedRegia.API.Tests/         ← xUnit unit tests
└── MedRegia.Migrations/        ← DbUp schema migrations

Key Technologies

PackagePurpose
DapperMicro-ORM for all SQL queries
MySqlConnectorADO.NET MySQL driver
AutoMapperDomain → DTO mapping
BCrypt.Net-NextPassword hashing
Microsoft.AspNetCore.Authentication.JwtBearerJWT validation
Scalar.AspNetCoreOpenAPI UI at /scalar/v1
DbUpDatabase migration runner
ClosedXMLExcel report generation
xUnit + MoqUnit testing

Startup Sequence (Program.cs)

  1. Dapper global config: MatchNamesWithUnderscores = true + enum type handlers
  2. Controllers registered with camelCase JSON policy
  3. AddInfrastructure() — registers IDbConnectionFactory
  4. AddModules() — registers all repositories and services
  5. JWT authentication configured from appsettings.json
  6. AutoMapper scans all Profile classes in the assembly
  7. CORS AllowAll policy (dev) / restrict in production
  8. OpenAPI / Scalar registered
  9. Middleware pipeline: UseCors → UseAuthentication → UseAuthorization → MapControllers

MedRegia — Pharmaceutical Vendor Management Platform