openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: ALIS - Aegis Liquidity Intelligence System API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: financialData description: Financial data management (Layer 1 - Input Data) - name: predictions description: Predictive analytics (Layer 3 - Prediction Engine) - name: risk description: Risk engine (Layer 4 - Risk Engine) - name: survival description: Survival engine (Layer 5 - Survival Engine) - name: scenarios description: Stress simulation (Layer 7 - Stress Simulation Engine) - name: insights description: AI insights and alerts (Layer 6) - name: dashboard description: Dashboard aggregates (Layer 8) paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" # Layer 1 - Financial Data Input /financial-data: get: operationId: listFinancialData tags: [financialData] summary: List financial data records parameters: - name: limit in: query schema: { type: integer, default: 30 } - name: offset in: query schema: { type: integer, default: 0 } responses: "200": description: List of financial data records content: application/json: schema: type: array items: $ref: "#/components/schemas/FinancialData" post: operationId: createFinancialData tags: [financialData] summary: Record a new financial data entry requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/FinancialDataInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/FinancialData" /financial-data/{id}: get: operationId: getFinancialData tags: [financialData] summary: Get a specific financial data record parameters: - name: id in: path required: true schema: { type: integer } responses: "200": description: Financial data record content: application/json: schema: $ref: "#/components/schemas/FinancialData" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" delete: operationId: deleteFinancialData tags: [financialData] summary: Delete a financial data record parameters: - name: id in: path required: true schema: { type: integer } responses: "204": description: Deleted # Layer 2 + 3 - Predictions /predictions: get: operationId: listPredictions tags: [predictions] summary: Get 30-day liquidity forecast responses: "200": description: Prediction records content: application/json: schema: type: array items: $ref: "#/components/schemas/Prediction" /predictions/generate: post: operationId: generatePrediction tags: [predictions] summary: Run prediction engine on latest data requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PredictionRequest" responses: "200": description: Generated prediction content: application/json: schema: $ref: "#/components/schemas/Prediction" # Layer 4 - Risk Engine /risk: get: operationId: listRiskAssessments tags: [risk] summary: List risk assessments responses: "200": description: Risk assessments content: application/json: schema: type: array items: $ref: "#/components/schemas/RiskAssessment" /risk/current: get: operationId: getCurrentRisk tags: [risk] summary: Get current risk assessment with LCR ratio responses: "200": description: Current risk assessment content: application/json: schema: $ref: "#/components/schemas/RiskAssessment" # Layer 5 - Survival Engine /survival: get: operationId: getSurvivalTimeline tags: [survival] summary: Get survival timeline - days left and collapse projection responses: "200": description: Survival timeline content: application/json: schema: $ref: "#/components/schemas/SurvivalTimeline" # Layer 6 - Insights, AI Advisor, Panic Detection /insights: get: operationId: listInsights tags: [insights] summary: List AI-generated insights and advisor recommendations responses: "200": description: Insights list content: application/json: schema: type: array items: $ref: "#/components/schemas/Insight" /insights/generate: post: operationId: generateInsights tags: [insights] summary: Generate AI insights for current data requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/InsightRequest" responses: "200": description: Generated insights content: application/json: schema: type: array items: $ref: "#/components/schemas/Insight" /panic-detection: get: operationId: getPanicDetection tags: [insights] summary: Get panic detection status - bank run signals responses: "200": description: Panic detection status content: application/json: schema: $ref: "#/components/schemas/PanicDetection" # Layer 7 - Stress Simulation /scenarios: get: operationId: listScenarios tags: [scenarios] summary: List stress simulation scenarios responses: "200": description: Scenarios content: application/json: schema: type: array items: $ref: "#/components/schemas/Scenario" post: operationId: createScenario tags: [scenarios] summary: Create a new what-if scenario requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ScenarioInput" responses: "201": description: Created scenario content: application/json: schema: $ref: "#/components/schemas/Scenario" /scenarios/{id}/simulate: post: operationId: runScenarioSimulation tags: [scenarios] summary: Run a what-if scenario simulation parameters: - name: id in: path required: true schema: { type: integer } requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SimulationParams" responses: "200": description: Simulation results content: application/json: schema: $ref: "#/components/schemas/SimulationResult" /scenarios/{id}: delete: operationId: deleteScenario tags: [scenarios] summary: Delete a scenario parameters: - name: id in: path required: true schema: { type: integer } responses: "204": description: Deleted # Layer 8 - Dashboard /dashboard/summary: get: operationId: getDashboardSummary tags: [dashboard] summary: Get dashboard KPI summary responses: "200": description: Dashboard summary with all KPIs content: application/json: schema: $ref: "#/components/schemas/DashboardSummary" /dashboard/trends: get: operationId: getDashboardTrends tags: [dashboard] summary: Get rolling trend data for charts parameters: - name: days in: query schema: { type: integer, default: 30 } responses: "200": description: Trend data content: application/json: schema: type: array items: $ref: "#/components/schemas/TrendPoint" /dashboard/alerts: get: operationId: getDashboardAlerts tags: [dashboard] summary: Get active anomaly alerts responses: "200": description: Active alerts content: application/json: schema: type: array items: $ref: "#/components/schemas/Alert" components: schemas: HealthStatus: type: object required: [status] properties: status: type: string ErrorResponse: type: object required: [error] properties: error: type: string # Layer 1 - Input Data FinancialData: type: object required: [id, recordDate, deposits, withdrawals, cashBalance, interestRate, netFlow, userId, createdAt] properties: id: type: integer userId: type: string recordDate: type: string format: date deposits: type: number description: Inflow (deposits) in thousands withdrawals: type: number description: Outflow (withdrawals) in thousands cashBalance: type: number description: Current cash balance in thousands interestRate: type: number description: Interest rate percentage netFlow: type: number description: Net flow = deposits - withdrawals rollingTrend: type: ["number", "null"] description: 7-day rolling average net flow notes: type: ["string", "null"] createdAt: type: string format: date-time FinancialDataInput: type: object required: [recordDate, deposits, withdrawals, cashBalance, interestRate] properties: recordDate: type: string format: date deposits: type: number withdrawals: type: number cashBalance: type: number interestRate: type: number notes: type: string # Layer 3 - Prediction Prediction: type: object required: [id, generatedAt, forecastDays, forecastData, futureBalanceProjection, userId] properties: id: type: integer userId: type: string generatedAt: type: string format: date-time forecastDays: type: integer forecastData: type: array items: $ref: "#/components/schemas/ForecastPoint" futureBalanceProjection: type: number trendDirection: type: string enum: [improving, stable, declining, critical] confidenceScore: type: ["number", "null"] ForecastPoint: type: object required: [date, predictedBalance, predictedNetFlow] properties: date: type: string predictedBalance: type: number predictedNetFlow: type: number upperBound: type: ["number", "null"] lowerBound: type: ["number", "null"] PredictionRequest: type: object required: [forecastDays] properties: forecastDays: type: integer default: 30 # Layer 4 - Risk RiskAssessment: type: object required: [id, assessedAt, riskScore, riskLevel, lcrRatio, anomalyDetected, userId] properties: id: type: integer userId: type: string assessedAt: type: string format: date-time riskScore: type: integer description: 0-100 risk score riskLevel: type: string enum: [LOW, MEDIUM, HIGH, CRITICAL] lcrRatio: type: number description: Liquidity Coverage Ratio anomalyDetected: type: boolean anomalyDescription: type: ["string", "null"] trendAnomaly: type: boolean # Layer 5 - Survival SurvivalTimeline: type: object required: [daysRemaining, netBurnRate, currentBalance, collapseDate, survivalStatus] properties: daysRemaining: type: ["integer", "null"] description: Days left before balance hits zero netBurnRate: type: number description: Daily net burn rate currentBalance: type: number collapseDate: type: ["string", "null"] format: date survivalStatus: type: string enum: [SAFE, WARNING, CRITICAL, CRISIS] liquidityHealthScore: type: integer description: 0-100 gamified health score # Layer 6 - Insights Insight: type: object required: [id, type, title, description, severity, generatedAt, userId] properties: id: type: integer userId: type: string type: type: string enum: [INSIGHT, ADVISOR, PANIC] title: type: string description: type: string severity: type: string enum: [INFO, WARNING, HIGH, CRITICAL] actionRequired: type: boolean suggestedAction: type: ["string", "null"] generatedAt: type: string format: date-time InsightRequest: type: object required: [context] properties: context: type: string enum: [full, risk_only, advisor_only] PanicDetection: type: object required: [panicLevel, withdrawalAnomaly, bankRunSignal, detectedAt] properties: panicLevel: type: string enum: [NONE, LOW, MODERATE, HIGH, EXTREME] withdrawalAnomaly: type: boolean bankRunSignal: type: boolean unusualWithdrawalPattern: type: boolean panicScore: type: integer detectedAt: type: string format: date-time description: type: ["string", "null"] # Layer 7 - Scenarios Scenario: type: object required: [id, name, type, userId, createdAt] properties: id: type: integer userId: type: string name: type: string type: type: string enum: [what_if, bank_run, market_crash, contagion, custom] description: type: ["string", "null"] parameters: type: object additionalProperties: true lastResult: $ref: "#/components/schemas/SimulationResult" createdAt: type: string format: date-time ScenarioInput: type: object required: [name, type] properties: name: type: string type: type: string enum: [what_if, bank_run, market_crash, contagion, custom] description: type: string parameters: type: object additionalProperties: true SimulationParams: type: object required: [withdrawalMultiplier] properties: withdrawalMultiplier: type: number description: Multiplier applied to withdrawals (e.g. 1.5 = 50% increase) depositReduction: type: number description: Factor to reduce deposits (e.g. 0.7 = 30% reduction) interestRateChange: type: number description: Interest rate change in percentage points durationDays: type: integer default: 30 contagionBanks: type: integer description: Number of affected banks in contagion scenario SimulationResult: type: object required: [survivalDays, finalBalance, riskLevel, impactSummary] properties: survivalDays: type: ["integer", "null"] finalBalance: type: number riskLevel: type: string enum: [LOW, MEDIUM, HIGH, CRITICAL] projectedBalances: type: array items: $ref: "#/components/schemas/ForecastPoint" impactSummary: type: string collapseRisk: type: boolean # Layer 8 - Dashboard DashboardSummary: type: object required: [totalDeposits, totalWithdrawals, currentBalance, netFlow, riskLevel, riskScore, daysRemaining, lcrRatio, liquidityHealthScore, survivalStatus, panicLevel, totalRecords] properties: totalDeposits: type: number totalWithdrawals: type: number currentBalance: type: number netFlow: type: number riskLevel: type: string enum: [LOW, MEDIUM, HIGH, CRITICAL] riskScore: type: integer daysRemaining: type: ["integer", "null"] lcrRatio: type: number liquidityHealthScore: type: integer survivalStatus: type: string enum: [SAFE, WARNING, CRITICAL, CRISIS] panicLevel: type: string enum: [NONE, LOW, MODERATE, HIGH, EXTREME] totalRecords: type: integer lastUpdated: type: ["string", "null"] format: date-time TrendPoint: type: object required: [date, deposits, withdrawals, netFlow, cashBalance] properties: date: type: string deposits: type: number withdrawals: type: number netFlow: type: number cashBalance: type: number rollingAverage: type: ["number", "null"] Alert: type: object required: [id, type, message, severity, triggeredAt] properties: id: type: integer type: type: string enum: [ANOMALY, PANIC, RISK, SURVIVAL, PREDICTION] message: type: string severity: type: string enum: [INFO, WARNING, HIGH, CRITICAL] triggeredAt: type: string format: date-time acknowledged: type: boolean