Spaces:
Sleeping
Sleeping
File size: 22,970 Bytes
2582052 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | # Backend API Requirements
This document lists the backend APIs needed to replace all mock and page-local data in the actuarial platform frontend.
Current mock sources:
- `src/lib/api.ts`: main mock service layer used by most pages.
- `src/lib/mock-data.ts`: static files, products, runs, reports, model versions, users, and activity.
- `src/lib/table-data.ts`: table registry, editable 1D/2D/3D tables, inforce records, and assumption records.
- Page-local mocks in `DashboardPage.tsx`, `ProductDetailPage.tsx`, `RunPages.tsx`, `ReportPages.tsx`, `DataPages.tsx`, and `SettingsPages.tsx`.
Recommended base path: `/api/v1`.
## Shared API Rules
All endpoints should return JSON unless the endpoint is explicitly for file upload or export.
Use ISO-8601 strings for timestamps and `YYYY-MM-DD` strings for actuarial/effective dates. Money and counts should be numeric, not pre-formatted strings. The frontend will handle display formatting.
Recommended list response shape:
```json
{
"data": [],
"pagination": {
"page": 1,
"pageSize": 50,
"total": 0
}
}
```
The current frontend can also consume raw arrays during the first integration, but the backend should prefer the wrapper above if pagination will be needed.
Recommended error shape:
```json
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Human readable message",
"details": {}
}
}
```
## Core Enums
```ts
type FileStatus = 'pending' | 'uploaded' | 'validating' | 'validated' | 'failed';
type ProductType = 'MYGA' | 'SPIA' | 'FIA' | 'RILA' | 'Disability';
type RunStatus = 'draft' | 'queued' | 'running' | 'completed' | 'failed' | 'cancelled';
type ProjectionFrequency = 'monthly' | 'quarterly' | 'annual';
type OutputGranularity = 'policy' | 'cohort' | 'product' | 'portfolio';
type UserRole = 'admin' | 'actuary' | 'analyst' | 'viewer';
```
## Authentication And Current User
The app currently has no real auth API, but backend integration should include auth before replacing user mocks.
| Method | Endpoint | Purpose |
| --- | --- | --- |
| `POST` | `/auth/login` | Start a session. |
| `POST` | `/auth/logout` | End a session. |
| `GET` | `/auth/me` | Return the current user, role, permissions, and tenant/company context. |
| `POST` | `/auth/refresh` | Refresh session token/cookie if token auth is used. |
`GET /auth/me` should return:
```ts
{
id: string;
name: string;
email: string;
role: UserRole;
department: string;
permissions: string[];
}
```
## Data Files
These replace `getInforceFiles`, `getAssumptionTables`, `getScenarioFiles`, `getFactorFiles`, `uploadFile`, `validateFile`, and `deleteFile`.
### Shared File Shape
```ts
interface DataFile {
id: string;
name: string;
type: 'inforce' | 'assumption' | 'scenario' | 'factor' | 'asset' | 'product_mapping';
size: number;
uploadedAt: string;
uploadedBy: string;
status: FileStatus;
validationErrors?: string[];
recordCount?: number;
version: string;
description?: string;
tags?: string[];
}
```
### File Endpoints
| Method | Endpoint | Purpose |
| --- | --- | --- |
| `GET` | `/files?type=inforce` | List inforce files. |
| `GET` | `/files?type=assumption` | List assumption tables/files. |
| `GET` | `/files?type=scenario` | List scenario files. |
| `GET` | `/files?type=factor` | List factor files. |
| `GET` | `/files?type=asset` | List asset portfolio files. |
| `GET` | `/files/{fileId}` | Fetch file metadata/detail. |
| `POST` | `/files` | Multipart upload for any supported file type. |
| `PATCH` | `/files/{fileId}` | Update editable metadata such as name, version, description, tags, product, basis, etc. |
| `POST` | `/files/{fileId}/validate` | Start validation or revalidation. |
| `GET` | `/files/{fileId}/validation` | Return validation state, errors, warnings, and record counts. |
| `DELETE` | `/files/{fileId}` | Delete/archive a file. |
| `GET` | `/files/{fileId}/download` | Download original uploaded file. |
### Specialized File Shapes
```ts
interface InforceFile extends DataFile {
type: 'inforce';
product: ProductType;
policyCount: number;
effectiveDate: string;
premiumAmount: number;
}
interface AssumptionTable extends DataFile {
type: 'assumption';
assumptionType: 'mortality' | 'lapse' | 'interest' | 'expense' | 'policyholder_behavior' | 'mixed';
basis: 'company' | 'industry' | 'reinsurance';
}
interface ScenarioFile extends DataFile {
type: 'scenario';
scenarioCount: number;
scenarioType: 'deterministic' | 'stochastic' | 'stress';
interestRatePath: string;
}
interface FactorFile extends DataFile {
type: 'factor';
factorType: 'crediting_rate' | 'mortality_improvement' | 'shock_lapse' | 'spread';
}
```
## File Record Viewers
These replace `inforceRecords`, `assumptionRecords`, `scenarioRows`, and `factorRows`. They are used by spreadsheet-style modals and need row-level edit support.
| Method | Endpoint | Purpose |
| --- | --- | --- |
| `GET` | `/files/{fileId}/records` | Return parsed records for a file. Supports pagination/filtering. |
| `PATCH` | `/files/{fileId}/records/{recordId}` | Update one parsed record/cell row. |
| `DELETE` | `/files/{fileId}/records/{recordId}` | Delete one parsed record. |
| `POST` | `/files/{fileId}/records` | Add one parsed record if manual entry is allowed. |
| `POST` | `/files/{fileId}/records/bulk` | Bulk update parsed records. |
Suggested query params: `page`, `pageSize`, `search`, `sort`, `section`, `scenarioId`, `product`, `status`.
### Inforce Record Shape
```ts
{
id: string;
policyNo: string;
insuredName: string;
product: string;
issueDate: string;
issueAge: number;
gender: 'M' | 'F' | 'U';
smokerStatus: 'SM' | 'NS' | string;
stateName: string;
premium: number;
accountValue: number;
surrenderValue: number;
guaranteedRate: number;
guaranteePeriod: number;
surrenderChargeYr: number;
status: 'Active' | 'Surrender' | 'Death' | string;
beneficiaryName?: string;
agentCode?: string;
}
```
### Assumption Record Shape
```ts
{
id: string;
tableId: string;
section: string;
subType: string;
age: number | 'N/A';
duration: string;
value: number;
unit: string;
basis: string;
effectiveDate: string;
}
```
### Scenario Record Shape
```ts
{
id: string;
scenarioId: string;
type: 'Base' | 'Stress' | 'Stochastic' | string;
description: string;
yr1Rate: number;
yr5Rate: number;
yr10Rate: number;
yr20Rate: number;
yr30Rate: number;
equity: number;
credit: number;
inflation: number;
}
```
### Factor Record Shape
```ts
{
id: string;
product: string;
duration: string;
rateGroup: string;
factor: number;
unit: string;
effectiveDate: string;
expiryDate: string;
notes?: string;
}
```
## Asset Positions
These replace `mockAssets` in `DataPages.tsx`.
| Method | Endpoint | Purpose |
| --- | --- | --- |
| `GET` | `/assets/positions` | List asset portfolio positions/files. |
| `GET` | `/assets/positions/{assetId}` | Fetch one asset record. |
| `POST` | `/assets/positions/upload` | Upload asset portfolio file. |
| `PATCH` | `/assets/positions/{assetId}` | Update asset metadata. |
| `DELETE` | `/assets/positions/{assetId}` | Delete/archive asset record. |
| `GET` | `/assets/summary` | Return total market value, average duration, average yield, and breakdowns. |
Shape:
```ts
{
id: string;
name: string;
type: 'Treasury' | 'IG Corporate' | 'High Yield' | 'MBS/ABS' | 'Municipal' | 'Equity' | string;
marketValue: number;
bookValue: number;
duration: number;
yield_pct: number;
date: string;
cusip?: string;
quantity?: number;
}
```
## Product Mapping
These replace `mockMappings` in `DataPages.tsx`.
| Method | Endpoint | Purpose |
| --- | --- | --- |
| `GET` | `/product-mappings` | List mappings from admin system products to actuarial model codes. |
| `POST` | `/product-mappings` | Create a mapping. |
| `GET` | `/product-mappings/{mappingId}` | Fetch one mapping. |
| `PATCH` | `/product-mappings/{mappingId}` | Update a mapping. |
| `DELETE` | `/product-mappings/{mappingId}` | Delete/deactivate a mapping. |
Shape:
```ts
{
id: string;
adminCode: string;
productCode: ProductType;
modelCode: string;
rateGroup: string;
description?: string;
active: boolean;
}
```
## Actuarial Table Registry
These replace `allTables` and editable 1D/2D/3D table data in `table-data.ts`.
| Method | Endpoint | Purpose |
| --- | --- | --- |
| `GET` | `/tables` | List all actuarial tables. |
| `GET` | `/tables/{tableId}` | Fetch one table including full rows/data. |
| `POST` | `/tables` | Create a vector/matrix/cube table. |
| `PATCH` | `/tables/{tableId}` | Update table metadata. |
| `PUT` | `/tables/{tableId}/data` | Replace table data after edits. |
| `PATCH` | `/tables/{tableId}/cells` | Patch one or more cells. |
| `DELETE` | `/tables/{tableId}` | Delete/archive a table. |
| `POST` | `/tables/{tableId}/versions` | Save a new version. |
| `GET` | `/tables/{tableId}/versions` | List historical versions. |
Shapes:
```ts
type AnyTable = VectorTable | Matrix2DTable | Cube3DTable;
interface VectorTable {
id: string;
name: string;
dimension: '1D';
description: string;
rowLabel: string;
valueLabel: string;
unit: string;
rows: { key: string; value: number }[];
}
interface Matrix2DTable {
id: string;
name: string;
dimension: '2D';
description: string;
rowLabel: string;
colLabel: string;
valueLabel: string;
unit: string;
rows: string[];
cols: string[];
data: number[][];
}
interface Cube3DTable {
id: string;
name: string;
dimension: '3D';
description: string;
axisLabels: [string, string, string];
valueLabel: string;
unit: string;
axes: [string[], string[], string[]];
data: number[][][];
}
```
## Products
These replace `getProducts`, `getProduct`, static product descriptions, product cohort chart data, and lapse curve data.
| Method | Endpoint | Purpose |
| --- | --- | --- |
| `GET` | `/products` | List products. |
| `GET` | `/products/{productCodeOrId}` | Fetch product detail. |
| `POST` | `/products` | Create a product if product management is required. |
| `PATCH` | `/products/{productId}` | Update product metadata. |
| `GET` | `/products/{productCode}/metrics` | Product KPI metrics. |
| `GET` | `/products/{productCode}/cohort-cashflows` | Product detail cohort chart/table. |
| `GET` | `/products/{productCode}/lapse-curve` | Product detail base/stress lapse curves. |
| `GET` | `/products/{productCode}/regulatory-framework` | Product regulatory/accounting framework bullets. |
Product shape:
```ts
{
id: string;
code: ProductType;
name: string;
description: string;
launchDate: string;
status: 'active' | 'discontinued' | 'in_development';
policyCount: number;
totalPremium: number;
totalReserve: number;
defaultAssumptionTable?: string;
modelVersion: string;
features?: string[];
regulatoryFramework?: string[];
}
```
## Projection Runs
These replace `getRuns`, `getRun`, `createRun`, `submitRun`, `cancelRun`, `deleteRun`, `getRunEvents`, and `summaryMetricsData`.
| Method | Endpoint | Purpose |
| --- | --- | --- |
| `GET` | `/runs` | List projection runs. Supports filters by status, product, createdBy, date range. |
| `POST` | `/runs` | Create a draft run from selected input files and projection config. |
| `GET` | `/runs/{runId}` | Fetch run detail. |
| `PATCH` | `/runs/{runId}` | Update draft run metadata/config. |
| `POST` | `/runs/{runId}/submit` | Submit draft run to queue. |
| `POST` | `/runs/{runId}/cancel` | Cancel queued/running run. |
| `DELETE` | `/runs/{runId}` | Delete/archive run. |
| `GET` | `/runs/{runId}/events` | Run status timeline. |
| `GET` | `/runs/{runId}/summary` | Summary metrics used by run detail result chart. |
| `GET` | `/runs/{runId}/downloads/results` | Download complete result package. |
| `GET` | `/runs/active` | List queued/running runs for status monitor. |
Run shape:
```ts
{
id: string;
name: string;
description?: string;
product: ProductType;
inforceFileId: string;
inforceFileName: string;
assumptionTableId: string;
assumptionTableName: string;
scenarioFileId: string;
scenarioFileName: string;
factorFileId?: string;
factorFileName?: string;
projectionFrequency: ProjectionFrequency;
projectionStartDate: string;
projectionEndDate: string;
outputGranularity: OutputGranularity;
status: RunStatus;
createdAt: string;
createdBy: string;
startedAt?: string;
completedAt?: string;
progressPct?: number;
errorMessage?: string;
scenarioCount: number;
policyCount: number;
duration?: number;
modelVersion: string;
tags?: string[];
}
```
Create run request:
```ts
{
name: string;
description?: string;
product: ProductType;
inforceFileId: string;
assumptionTableId: string;
scenarioFileId: string;
factorFileId?: string;
projectionFrequency: ProjectionFrequency;
projectionStartDate: string;
projectionEndDate: string;
outputGranularity: OutputGranularity;
}
```
Run event shape:
```ts
{
id: string;
runId: string;
timestamp: string;
status: RunStatus;
message: string;
detail?: string;
}
```
Run summary row:
```ts
{
period: string;
reserve: number;
cashflow: number;
av: number;
}
```
## Reports And Exports
These replace `getCashflows`, `getReserves`, `getAccountValues`, `getClaims`, plus page-local benefits, fees, reconciliation, downloadable reports, and export buttons.
All report endpoints should support at least `runId`, `scenario`, `product`, `fromPeriod`, `toPeriod`, and `format` where relevant.
| Method | Endpoint | Purpose |
| --- | --- | --- |
| `GET` | `/runs/{runId}/reports/cashflows` | Cashflow rows and scenario-specific data. |
| `GET` | `/runs/{runId}/reports/reserves` | Gross/ceded/net reserves. |
| `GET` | `/runs/{runId}/reports/account-values` | Account value rollforward. |
| `GET` | `/runs/{runId}/reports/claims` | Claim rows. |
| `GET` | `/runs/{runId}/reports/benefits` | Benefits report. |
| `GET` | `/runs/{runId}/reports/fees` | Fees report. |
| `GET` | `/runs/{runId}/reports/reconciliation` | Reserve bridge/reconciliation report. |
| `GET` | `/runs/{runId}/reports/scenario-comparison` | Cross-scenario comparison for download/report list. |
| `GET` | `/runs/{runId}/reports` | List available reports for run detail page. |
| `GET` | `/runs/{runId}/reports/{reportType}/export?format=csv` | Export report as CSV. |
| `GET` | `/runs/{runId}/reports/{reportType}/export?format=xlsx` | Export report as Excel. |
Cashflow row:
```ts
{
period: string;
premiums: number;
benefits: number;
claims: number;
expenses: number;
netCashflow: number;
reserves: number;
scenario: string;
}
```
Reserve row:
```ts
{
period: string;
product: ProductType;
grossReserve: number;
cededReserve: number;
netReserve: number;
policyCount: number;
scenario: string;
}
```
Account value row:
```ts
{
period: string;
beginningAV: number;
premiums: number;
credited: number;
withdrawals: number;
surrenders: number;
deaths: number;
endingAV: number;
scenario: string;
}
```
Claim row:
```ts
{
period: string;
product: ProductType;
deathClaims: number;
disabilityClaims: number;
surrenderValues: number;
maturityBenefits: number;
totalClaims: number;
scenario: string;
}
```
Benefits row:
```ts
{
period: string;
guaranteedBenefits: number;
livingBenefits: number;
deathBenefits: number;
annuityPayments: number;
}
```
Fees row:
```ts
{
period: string;
adminFees: number;
mortalityCharges: number;
surrenderCharges: number;
riderCharges: number;
investmentMgmt: number;
}
```
Reconciliation row:
```ts
{
label: string;
prior: number;
current: number;
variance: number;
pct: number | null;
commentary?: string;
}
```
## Dashboard
These replace `getDashboardStats`, `getRecentActivity`, `chartData`, and `productMix`.
| Method | Endpoint | Purpose |
| --- | --- | --- |
| `GET` | `/dashboard/stats` | KPI cards. |
| `GET` | `/dashboard/activity` | Recent activity feed. |
| `GET` | `/dashboard/reserve-premium-trend` | 6-month reserve/premium/cashflow trend chart. |
| `GET` | `/dashboard/product-mix` | Reserve/premium/policy breakdown by product. |
| `GET` | `/dashboard/recent-runs` | Latest runs, or frontend can use `/runs?limit=5`. |
Dashboard stats:
```ts
{
totalRuns: number;
completedRuns: number;
activeRuns: number;
totalPolicies: number;
totalReserve: number;
totalPremium: number;
failedRuns: number;
reserveChangePct?: number;
premiumChangePct?: number;
newPoliciesCount?: number;
}
```
Activity:
```ts
{
id: string;
type: 'run_completed' | 'run_failed' | 'file_uploaded' | 'file_validated' | 'run_created';
message: string;
timestamp: string;
user: string;
entityId?: string;
}
```
Trend row:
```ts
{
period: string;
reserve: number;
premium: number;
cashflow: number;
}
```
Product mix row:
```ts
{
product: ProductType | 'DI';
reserve: number;
premium: number;
policies: number;
}
```
## Settings: Product Assumptions
These replace `assumptionSettings` in `SettingsPages.tsx`.
| Method | Endpoint | Purpose |
| --- | --- | --- |
| `GET` | `/settings/product-assumptions` | List product-level assumption settings. |
| `POST` | `/settings/product-assumptions` | Create an assumption set. |
| `PATCH` | `/settings/product-assumptions/{setId}` | Update set metadata. |
| `POST` | `/settings/product-assumptions/{setId}/items` | Add assumption item. |
| `PATCH` | `/settings/product-assumptions/{setId}/items/{itemId}` | Update assumption item. |
| `DELETE` | `/settings/product-assumptions/{setId}/items/{itemId}` | Delete assumption item. |
Shape:
```ts
{
id: string;
product: ProductType;
table: string;
tableId?: string;
version: string;
lastUpdated: string;
assumptions: {
id: string;
name: string;
basis: string;
status: 'current' | 'review' | 'deprecated';
value: string;
effectiveDate: string;
}[];
}
```
## Settings: Model Versions
These replace `getModelVersions`.
| Method | Endpoint | Purpose |
| --- | --- | --- |
| `GET` | `/model-versions` | List model versions. |
| `POST` | `/model-versions` | Create/register a model version. |
| `GET` | `/model-versions/{modelVersionId}` | Fetch model version detail. |
| `PATCH` | `/model-versions/{modelVersionId}` | Update model version metadata/status. |
| `DELETE` | `/model-versions/{modelVersionId}` | Delete/archive model version. |
| `POST` | `/model-versions/{modelVersionId}/activate` | Mark as current production version. |
| `POST` | `/model-versions/{modelVersionId}/beta-access` | Request/enable beta access. |
Shape:
```ts
{
id: string;
version: string;
name: string;
releaseDate: string;
status: 'current' | 'deprecated' | 'beta';
changes: string[];
products: ProductType[];
}
```
## Settings: Users, Roles, System
These replace `getUsers`, the invite dialog local state, the role matrix, and static system cards.
| Method | Endpoint | Purpose |
| --- | --- | --- |
| `GET` | `/users` | List users. |
| `POST` | `/users/invitations` | Invite a user. |
| `GET` | `/users/{userId}` | Fetch user detail. |
| `PATCH` | `/users/{userId}` | Update user profile, role, department, or status. |
| `DELETE` | `/users/{userId}` | Deactivate/delete user. |
| `GET` | `/roles` | List roles. |
| `GET` | `/roles/permissions-matrix` | Return role permissions table. |
| `GET` | `/settings/system` | System settings cards: compute, retention, integrations, governance. |
| `PATCH` | `/settings/system` | Update editable system settings if supported. |
User shape:
```ts
{
id: string;
name: string;
email: string;
role: UserRole;
lastLogin: string;
status: 'active' | 'inactive';
department: string;
}
```
Invitation request:
```ts
{
email: string;
role: UserRole;
}
```
Permission matrix shape:
```ts
{
permissions: {
key: string;
label: string;
viewer: boolean;
analyst: boolean;
actuary: boolean;
admin: boolean;
}[];
}
```
System settings shape:
```ts
{
sections: {
id: string;
title: string;
items: {
key: string;
label: string;
value: string | number | boolean;
editable?: boolean;
}[];
}[];
}
```
## Backend-Powered Derived Values
Several screens currently compute summary cards from local arrays. The backend can either return raw rows and let the frontend compute totals, or provide summary endpoints. Prefer backend summaries for large datasets.
Required summaries:
- Scenario file counts by scenario type.
- Asset total market value, average duration, average yield.
- Run counts by status.
- Report totals for premiums, benefits, claims, expenses, reserves, account values, fees, and reconciliation.
- Product-level policy count, premium, reserve, average premium per policy, reserve-to-premium ratio.
- Dashboard period-over-period changes.
## Integration Priority
1. Auth/current user, products, files, runs, and dashboard stats.
2. File upload, validation, records, and table registry.
3. Run execution lifecycle and report result endpoints.
4. Settings APIs for users, roles, model versions, system settings, and product assumptions.
5. Export/download endpoints and historical versioning/audit endpoints.
## Minimum API Set To Remove The Main Mock Layer
If the first backend milestone is only to replace `src/lib/api.ts`, implement these first:
- `GET /files?type=inforce`
- `GET /files?type=assumption`
- `GET /files?type=scenario`
- `GET /files?type=factor`
- `POST /files`
- `POST /files/{fileId}/validate`
- `DELETE /files/{fileId}`
- `GET /products`
- `GET /products/{productId}`
- `GET /runs`
- `POST /runs`
- `GET /runs/{runId}`
- `POST /runs/{runId}/submit`
- `POST /runs/{runId}/cancel`
- `DELETE /runs/{runId}`
- `GET /runs/{runId}/events`
- `GET /runs/{runId}/reports/cashflows`
- `GET /runs/{runId}/reports/reserves`
- `GET /runs/{runId}/reports/account-values`
- `GET /runs/{runId}/reports/claims`
- `GET /model-versions`
- `GET /users`
- `GET /dashboard/activity`
- `GET /dashboard/stats`
|