Ezel Data Services logo

Ezel Data Services

Federal IT Contract Tracker

How the Federal IT Contract Tracker works

The Federal IT Contract Tracker is a working demonstration by Ezel Data Services LLC. It is a small production data system: it runs on its own every day, checks its own data before publishing, and alerts a person when something goes wrong. This page explains how it is built and why, for readers who want to look under the hood.

Architecture diagram

At a glance

Data source and scope

USAspending.gov publishes federal spending data through a free, public API. The tracker requests:

Filter Value
Award types Contracts only: purchase orders, delivery orders, definitive contracts, and BPA calls. Indefinite-delivery vehicles (IDVs) are excluded because their amounts are ceilings, not spending.
Industry NAICS 5415xx (computer systems design and related services) and 518210 (data processing and hosting)
Location Place of performance in Arizona or Kentucky
Period Federal fiscal year 2024 (October 1, 2023) to date

It pulls two views of the same contracts:

Ingestion

The pipeline is a Python job packaged as a container and run on Cloud Run Jobs. Cloud Scheduler starts it daily.

  1. Plan the slices. Awards are requested per state across the whole period. Transactions are requested per state and fiscal year, since each action falls in exactly one fiscal year. Slicing keeps every request well under the API's paging limits and makes any gap easy to trace.
  2. Count, then fetch. For each slice, the job asks the API's count endpoint how many records to expect, then pages through the results. Temporary errors (throttling, server errors, timeouts) are retried with increasing waits. Any other error stops the run.
  3. Keep the raw data. Each slice is saved to Cloud Storage as newline-delimited JSON, in a folder per run. Records are wrapped with the run ID, state, fiscal year, and fetch time, but are otherwise left exactly as received.
  4. Load. The files are loaded into BigQuery's raw tables, which keep each API record in a JSON column. A renamed or added API field cannot break the load.
  5. Log. Every slice's expected count, fetched count, and timing is written to a run log table.

Each run is a full refresh of the period. With a few thousand records, re-pulling everything is simple and cheap, and it picks up corrections the source makes to older records automatically.

Data quality: validate, then publish

Before the clean tables are rebuilt, a set of checks runs against the new raw data. Results are stored for every run.

Check Severity
Every slice fetched exactly the number of records the API reported Error
BigQuery holds exactly the rows the run fetched Error
Required award fields are present (identifier, amount, start date, recipient) Error
Required transaction fields are present (identifier, modification, date, amount) Error
Each transaction's date falls in the fiscal year of the slice it came from Error
Contract actions duplicated by the source, removed in the clean layer Info
Awards with no product/service code (can't be categorized) Warning
Spending since FY2024 that exceeds an award's lifetime value Warning

If any error check fails, the run stops before publishing. The dashboard keeps serving the last good data, and the failure is recorded and emailed. Warnings and information are recorded but don't block publishing.

One finding from building this: the API returns some contract actions twice, identical in every field (about 90 per run). The clean layer removes them, and the duplicate count is tracked as an information check.

Data model

Layer Contents
raw Awards and transactions exactly as received, one row per record per run, partitioned by day
clean One row per award and one row per contract action from the latest good run: typed fields, duplicates removed, fiscal year computed, and a spending category
reporting Views for the dashboard: spending by fiscal year and agency, top recipients, and new awards
ops The run log and data-quality results

Categories come from the first character of each contract's product/service code (PSC): D for IT services, 7 for IT products, R for professional support, and everything else as Other. The mapping lives in a version-controlled SQL file, so a category change is a reviewed code change.

Amounts are net obligations: the sum of contract actions in the period, including de-obligations (negative amounts when money is taken back).

All transformations are plain SQL files, run in order by the pipeline and kept in the same repository as the code.

Dashboard

The dashboard is a small Flask application on Cloud Run, with charts drawn by Chart.js. It reads only from the clean and reporting layers.

Security

Infrastructure as code and deployment

Everything in the diagram is defined in Terraform: storage, datasets, service accounts and their permissions, the job, the schedule, the dashboard service, the custom domain, and the alert. Terraform state is stored in a versioned cloud bucket. Every change is previewed with terraform plan before it is applied.

A deploy is one script:

  1. It refuses to run if the code being deployed isn't committed, so every image traces to an exact version.
  2. Cloud Build builds the container in the cloud and tags it with the git commit.
  3. The script updates the image version in the Terraform settings, shows the plan, and asks for confirmation before applying.

Automated tests (pytest) cover API paging and retries, fiscal-year logic, data-quality gating, query parameters, and every dashboard page.

Monitoring and recovery

Design decisions and trade-offs

Decision Why Trade-off
Full daily refresh instead of pulling only changes Simple, self-correcting, and fast at this volume Would need to switch to pulling only changes if the scope grew a lot
Keep raw data exactly as received (JSON column) Every number traces back to its source; schema changes can't break loads Typed columns are extracted in the clean layer instead
Validate, then publish A bad run never reaches the dashboard Data can be a day old until a failure is fixed
Plain SQL files instead of a transformation framework Fewest moving parts for five transformation steps No built-in lineage graph; Google's Dataform is a natural next step
Serverless (Cloud Run) instead of always-on servers Near-zero cost when idle, nothing to patch Occasional cold starts outside business hours

Known limitations


Questions about this project, or a similar pipeline for your own data? Contact robert@ezeldata.com · www.ezeldata.com