Audience: Engineers, DBAs. What this answers: the report engine, the warehouse architecture, and the BI sync.

Source: AdminReportService.cs (7,058), ReportService.cs (519), WarehouseService.cs (22), ControlAnalyticService.cs (313), WarehouseDbContext, DataSynchronizationService.cs, ReportModel.cs, plus a live pass 2026-07-21.


1. The big picture

Operational DBs (TenantDb / MembershipDb)
        │  DataSynchronizationService — 30s worker, SyncBIData()
        ▼
WarehouseDb  (WarehouseDbContext, via WarehouseDbFactory)
   ├── Stores      (denormalized flat copies)
   └── Containers  (pre-aggregated trends/summaries, via SQL procedures)
        │
        ▼  read by
AdminReportService (7,058 lines) ──▶ Admin/ReportsController (26 endpoints)
        │
        ▼  emits Paginator<T> envelope (server-driven-tables format)
Frontend report tables (EnhancedReportTable)

2. The Warehouse (WarehouseDb)

A fourth DbContext (alongside Tenant, Membership, and the EWA/warehouse split), resolved by WarehouseDbFactory.

Stores — denormalized flat copies

Store Source (via SyncBIData)
PersonStore PersonService.SyncBIData()
PayrollItemSummaryStore PayrollService.SyncBIData()
EmployeeRequestStore RequestService.SyncBIData()
ContractorStore ContractorService.SyncBIData()
PaymentScheduleItemStore PaymentService.SyncCustomPaymentBIData()

Flattening the operational graph into wide Store rows makes wide, multi-join reports cheap — the joins are pre-done.

Containers — pre-aggregated

EmployeeTrendContainer, GenderSummaryContainer, PayrollTrendContainer, TopPayrollCompaniesContainer, ProcedureExecutionContainer.

ProcedureExecutionContainer (a Result int) is the tell that SQL stored procedures compute the Containers — the aggregation runs in-database. (RFD-001)

3. The BI sync worker

BackgroundServices/DataSynchronizationService.cs — BackgroundService, Task.Delay(30s) loop:

_companyService.SynchronizeCompanyEwaEmployees();
_personService.SyncBIData();       // → PersonStore
_payrollService.SyncBIData();      // → PayrollItemSummaryStore
_requestService.SyncBIData();      // → EmployeeRequestStore
_personService.SyncContactData();
_contractorService.SyncBIData();   // → ContractorStore
_paymentService.SyncCustomPaymentBIData(); // → PaymentScheduleItemStore
_miscellaneousService.CleanupDataSyncTask();

Consequence: the warehouse is eventually consistent — a live change lands in reports after the next sync cycle (≤ ~30s + sync duration). Reports are not transactionally consistent with live data. (RFD-002)

4. The report engine (AdminReportService, 7,058 lines)

The largest single service in the codebase. It produces: