How jabelresendiz/backend works
1. This repository is a layered ASP.NET Core backend split into four main projects: API, Application, Domain, and Infrastructure. The separation is deliberate: HTTP concerns live in API, business use cases in Application, core business objects in Domain, and all persistence/integration details in Infrastructure.
2. Finlay.PharmaVigilance.API is the entry boundary. Its controllers are organized by business area rather than by technical CRUD: authentication, catalog, dashboard, lot, manufacturer, medical review, report, and vaccination center. It also contains middleware for centralized error handling and rate limiting, plus a UserContextService for accessing the current caller identity/claims.
3. Finlay.PharmaVigilance.Application is the orchestration layer. It defines service interfaces, DTOs, validators, and helpers. Most controllers depend on application services rather than repositories directly, so business workflows are coordinated here and data is projected into feature-specific DTOs instead of exposing domain entities.
4. Finlay.PharmaVigilance.Domain holds the core model: entities such as AefiReport, AdverseEvent, MedicalReview, MedicalReviewAssignment, Reporter, VaccinatedSubject, Vaccination, Lot, Vaccine, Manufacturer, VaccinationCenter, User, and role-specific users like MedicalReviewer and SectionResponsible. Enums like ReportStatus, ReviewAssignmentStatus, UserRole, and Severity define the business vocabulary. Domain events are also modeled here, including AssignmentExpiredEvent, EmailToReporterEvent, and MedicalReviewerRegisteredEvent.
5. Finlay.PharmaVigilance.Infrastructure is where the system integrates with external services and persistence. It contains FinlayDbContext, repository implementations, a unit of work, an identity manager, JWT token generation, SMTP email delivery, a RabbitMQ message bus, consumers, and a background service for assignment expiration. This is the main boundary to the database, authentication provider logic, messaging, and email infrastructure.
6. Data access follows a repository + unit-of-work pattern. The Application layer defines repository abstractions and command/query services, while Infrastructure/Repository provides the concrete implementations over FinlayDbContext. This keeps query and mutation logic centralized in application services and avoids coupling controllers to EF Core.
7. Authentication and authorization are a distinct subsystem. The API exposes login and registration flows for general users, medical reviewers, and section responsible users. IdentityManager, IIdentityService, JWT token generation, and refresh token repositories indicate a token-based auth model with role-based access control. The current user context is used downstream to tailor behavior and permissions.
8. The report / AEFI workflow is the central business flow. Public or authenticated users submit reports through report controllers and command services, with validators enforcing domain-specific rules on reporters, vaccinated subjects, vaccinations, and adverse events. Reporting results in DTO-based responses and can trigger downstream events for notifications or review handling.
9. Medical review is a separate operational workflow. Reports can be assigned to medical reviewers via dedicated assignment and review controllers/services. The presence of assignment expiration logic, AssignmentExpirationBackgroundService, and AssignmentExpiredConsumer shows that review ownership is time-bound and partially automated through background processing and messaging.
10. Messaging is event-driven and used for side effects, not core request handling. IEventBus and RabbitMqMessageBus connect domain/application events to consumers such as EmailToReporterConsumer, EmailToSectionResponsibleConsumer, MedicalReviewerConsumer, and AssignmentExpiredConsumer. This decouples report submission and review actions from notifications and other asynchronous follow-up work.
11. Master data and lookup flows are handled as catalogs and reference entities. Vaccines, symptoms, manufacturers, lots, and vaccination centers have their own command/query services and controllers. These are likely used across report creation, administration screens, and search/filter features.
12. Dashboards are a read-optimized subsystem. Separate admin and municipal dashboard controllers/services expose aggregated views such as performance, report summaries, and vaccine-related metrics. The DTO structure suggests these endpoints are projection-heavy and role-dependent rather than entity-centric.
13. Validation is treated as a first-class boundary. The application layer includes dedicated validators for reports, medical reviewers, vaccinations, vaccinated subjects, and reporters, plus custom attributes for email, enum, and identity-number validation. This means malformed or incomplete input is rejected before it reaches domain/persistence logic.
14. Operationally, the repo is container-friendly and deployment-oriented. There is a root Dockerfile, a docker-compose.yml, a RabbitMQ container folder, Railway configuration files, migration scripts, and a Requests/ directory with .http samples for manual API testing. Those files indicate the backend is designed to run as a service with supporting infrastructure and scripted environment setup.
Main entry points: Program.cs API Host · Finlay.PharmaVigilance.Application Contracts & Validation · MedicalReview Review Services · ReportController.cs Report API
Components 24
API
HTTP entry boundary, controllers, middleware, and caller context.
- API Host · Bootstraps HTTP pipeline and exposes the backend entry point.
Finlay.PharmaVigilance.API/Program.cs - Middleware · Centralized error handling and rate limiting.
Finlay.PharmaVigilance.API/Middleware - User Context · Resolves current user identity and claims for downstream services.
Finlay.PharmaVigilance.API/Common/UserContextService.cs - Auth Controllers · Login and registration endpoints for users and role-specific accounts.
Finlay.PharmaVigilance.API/Controllers/AuthenticationControllers - Report API · Creates and reads AEFI reports and report access views.
Finlay.PharmaVigilance.API/Controllers/ReportControllers/ReportController.cs - Review API · Medical review and assignment endpoints for report handling.
Finlay.PharmaVigilance.API/Controllers/MedicalReviewControllers - Catalog API · Reference data endpoints for vaccines and symptoms.
Finlay.PharmaVigilance.API/Controllers/CatalogControllers/CatalogController.cs - Dashboards · Role-based aggregate views for admin and municipal users.
Finlay.PharmaVigilance.API/Controllers/Dashboard - Master Data · Endpoints for lots, manufacturers, and vaccination centers.
Finlay.PharmaVigilance.API/Controllers
Application
Use-case orchestration, DTOs, validation, and repository/service contracts.
- Identity Services · Coordinates login, registration, JWT issuance, and role-based identity flows.
Finlay.PharmaVigilance.Application/Services/Authentication - Report Services · Coordinates report creation, validation, querying, and DTO projection.
Finlay.PharmaVigilance.Application/Services/Report - Review Services · Manages medical review, assignment, and expiration workflows.
Finlay.PharmaVigilance.Application/Services/MedicalReview - Catalog Services · Handles vaccine and symptom command/query flows.
Finlay.PharmaVigilance.Application/Services/Catalog - Dashboard Services · Builds admin and municipal dashboard projections.
Finlay.PharmaVigilance.Application/Services/Dashboard - Contracts & Validation · Repository interfaces, service interfaces, DTOs, validators, and helpers.
Finlay.PharmaVigilance.Application
Domain
Core business model, enums, and domain events.
- Core Model · AEFI reports, users, vaccinations, medical review entities, and business enums.
Finlay.PharmaVigilance.Domain/Entities - Domain Events · Business events used to trigger notifications and follow-up processing.
Finlay.PharmaVigilance.Domain/Events
Infrastructure
Persistence, auth, messaging, email, background processing, and external integrations.
- Db Context · Entity Framework Core context and database boundary.
Finlay.PharmaVigilance.Infrastructure/FinlayDbContext.cs - Repositories · Concrete repository implementations over the database context.
Finlay.PharmaVigilance.Infrastructure/Repository - Unit of Work · Coordinates repository commits as a single persistence unit.
Finlay.PharmaVigilance.Infrastructure/UnitOfWork/UnitOfWork.cs - Identity & JWT · Identity manager and token generation for authentication and refresh tokens.
Finlay.PharmaVigilance.Infrastructure/Authentication - Event Bus · RabbitMQ-backed bus and consumers for async side effects.
Finlay.PharmaVigilance.Infrastructure/Messaging/RabbitMqMessageBus.cs - Email Delivery · SMTP email service and notification consumers.
Finlay.PharmaVigilance.Infrastructure/Email/SmtpEmailService.cs - Expiration Worker · Background processing for assignment expiration and related automation.
Finlay.PharmaVigilance.Infrastructure/BackgroundServices/AssignmentExpirationBackgroundService.cs
Connections 32
- API Host → Middleware: pipeline · HTTP requests flow through centralized middleware.
- API Host → Auth Controllers: routes · The host maps authentication endpoints.
- API Host → Report API: routes · The host maps report endpoints.
- API Host → Review API: routes · The host maps review endpoints.
- API Host → Catalog API: routes · The host maps catalog endpoints.
- API Host → Dashboards: routes · The host maps dashboard endpoints.
- API Host → Master Data: routes · The host maps master-data endpoints.
- Auth Controllers → Identity Services: uses · Authentication controllers delegate to application identity services.
- Report API → Report Services: uses · Report controllers coordinate report use cases through application services.
- Review API → Review Services: uses · Review controllers delegate assignment and review workflows.
- Catalog API → Catalog Services: uses · Catalog controllers call application lookup services.
- Dashboards → Dashboard Services: uses · Dashboard controllers request projection services.
- Master Data → Contracts & Validation: uses · Master-data controllers depend on shared application contracts and DTOs.
- Report API → User Context: context · Report endpoints use caller identity and claims for access and tailoring.
- Identity Services → Contracts & Validation: depends on · Identity services rely on shared interfaces and DTOs.
- Report Services → Contracts & Validation: depends on · Report services use DTOs, validators, and repository contracts.
- Review Services → Contracts & Validation: depends on · Review services use repository contracts and event abstractions.
- Catalog Services → Contracts & Validation: depends on · Catalog services use shared application contracts.
- Dashboard Services → Contracts & Validation: depends on · Dashboard services use DTO projections and common services.
- Contracts & Validation → Core Model: models · Application contracts are shaped by the domain model and vocabularies.
- Contracts & Validation → Domain Events: publishes · Application logic can raise domain events through shared messaging abstractions.
- Repositories → Db Context: implements over · Repositories are built on the EF Core context.
- Unit of Work → Repositories: coordinates · Unit of work composes repository mutations.
- Identity & JWT → Db Context: persists · Identity and token flows read and write through the database boundary.
- Event Bus → Domain Events: delivers · Events are transported to async consumers.
- Email Delivery → Event Bus: consumes · Notification side effects are triggered from the message bus.
- Expiration Worker → Event Bus: publishes · Background expiration processing emits follow-up messages.
- Expiration Worker → Review Services: coordinates · Expiration work supports review assignment workflows.
- Report Services → Unit of Work: persists via · Report use cases commit through the unit of work.
- Review Services → Unit of Work: persists via · Review use cases commit through the unit of work.
- Identity Services → Identity & JWT: auth via · Identity services rely on token generation and identity management.
- Catalog Services → Repositories: queries via · Catalog services read and write through repositories.