Code and methodology for analyzing Home Mortgage Disclosure Act (HMDA) loan-level data and FFIEC Census data: mortgage-lending patterns, geographic disparities, tract-boundary corrections across vintages, longitudinal time-series, systemic-bank analysis, and a Python replication of published R methodologies (incl. a Bhutta-style replication).
This is a code-only release. The underlying HMDA LAR and Census corpora (hundreds of
GB) are not included — see data/MANIFEST.md for the public
sources and download links.
Technical/src/— analysis libraryhmda/,census/— loaders / parsers for HMDA LAR and FFIEC Census flat filesanalysis/— disparity, geographic-aggregation, longitudinal, multi-scope analysesbhutta_replication/— Python port of the R replication (multiple iterations + diagnostics)validation/,quality/— tract-boundary correction/validation and data-quality monitorsapi/— Flask / Streamlit / FastAPI dashboards
Technical/scripts/— CLI entry pointsTechnical/src/api/hmda_dashboard.py— the maintained Streamlit dashboardTechnical/src/api/stakeholder_dashboard.py— the Flask dashboard served by the Docker imageupdate_dashboard_data.py— dashboard data refreshstreamlit_dashboard.py— stale stub, do not run; it is kept only as a pointer to the dashboard above (it showed a mislabeled approval rate)comprehensive_*.py,hmda_master_workflow.py— top-level orchestration
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txtThe code reads inputs from DATA_ROOT and writes outputs to OUTPUT_ROOT, both set via
environment variables (defaults: ./data and ./outputs). Point them at where you have
downloaded the HMDA / Census data (see data/MANIFEST.md):
export DATA_ROOT=/path/to/your/hmda-and-census-data
export OUTPUT_ROOT=/path/to/where/outputs/should/go$env:DATA_ROOT = "D:\path\to\data"
$env:OUTPUT_ROOT = "D:\path\to\outputs"Inside DATA_ROOT, the loaders expect the original sub-layout (e.g.
Inputs/Old/CRA_code/..., Inputs/Old/Python Stuff/schemas/...); data/MANIFEST.md
documents which public files populate each path. Copy .env.example to .env and edit if
you prefer a dotenv file.
# Census flat-file parser
python "Technical/src/census/census_full_parser.py"
# Bhutta-style replication (latest)
python Technical/src/bhutta_replication/r_modified/bhutta_replication_FINAL.py
# Dashboard (Streamlit)
streamlit run Technical/src/api/hmda_dashboard.pyDo not run the root-level streamlit_dashboard.py: it is a stale stub kept only as a
pointer (see the repository layout above).
The image in Dockerfile serves the Flask dashboard
(Technical/src/api/stakeholder_dashboard.py) with Gunicorn on port 5000:
docker build -t hmda-analysis .
docker run --rm -p 5000:5000 -e SECRET_KEY=$(python -c "import secrets; print(secrets.token_hex(32))") hmda-analysisThe dashboard reads pre-processed outputs, so it renders real numbers only once you have
run the analysis pipeline and mounted the results (see docker-compose.yml). This project
is not hosted anywhere — there is no public deployment to visit.
The analysis pipeline runs on local files and needs no API keys. The dashboards
expose only operational settings (see .env.example): SECRET_KEY (generate your own
with python -c "import secrets; print(secrets.token_hex(32))"), host/port, CORS, and
optional GOOGLE_ANALYTICS_ID / SENTRY_DSN. None are required to run the analysis code.
HMDA and FFIEC Census data are public. This repository ships no data. Download the
required inputs yourself per data/MANIFEST.md and set DATA_ROOT.
This project is dual-licensed:
- Code — MIT License.
- Data & documentation produced by this project — Creative Commons Attribution 4.0 International (CC BY 4.0).
See LICENSE for the full text of both and LICENSES.md for a
plain-language summary of which applies where. HMDA LAR and FFIEC Census data are U.S.
public data and retain their own terms.