Base URL:

API hierarchy design

Three-level architecture for simulations, analyses, and reports.

Levels of analysis

Level 2

Reports

AI-generated documents orchestrating multiple jobs. Future feature.

Level 1

Analyses

Operations on simulations - thin wrappers around policyengine package functions.

/analysis/decile-impact/*/analysis/budget-impact/*/analysis/winners-losers/*/analysis/compare/*
Level 0

Simulations

Single world-state calculations - the foundation for all analyses.

/simulate/household/simulate/economy

Modal functions

All compute runs on Modal.com serverless functions with sub-1s cold starts.

FunctionPurpose
simulate_household_uk/usSingle household calculation
simulate_economy_uk/usSingle economy simulation
economy_comparison_uk/usEconomy comparison (decile impacts, budget)

Mapping to policyengine package

API endpointpolicyengine function
/simulate/householdcalculate_household_impact()
/simulate/economySimulation.run()
/analysis/decile-impact/*calculate_decile_impacts()
/analysis/budget-impact/*ProgrammeStatistics
/analysis/winners-losers/*ChangeAggregate

Use cases

My tax under current law/simulate/household
Reform impact on my household/analysis/compare/household
Revenue impact of reform/analysis/budget-impact/economy
Decile breakdown of reform/analysis/decile-impact/economy
Who wins and loses/analysis/winners-losers/economy
Full reform analysis/analysis/compare/economy