Our platform receives a JSON export from the order management system every hour. Each export is a flat list of order events that need to be validated, enriched, and written to a processed output file for downstream consumers.
You've been handed this codebase by a junior engineer who got it working and moved on to another project. Your task is to work with it, understand it, and improve it.
Each record in data/orders_raw.json represents a single order event:
{
"order_id": "ORD-1001",
"customer_id": "CUST-42",
"amount": 120.0,
"status": "confirmed"
}Valid statuses: pending, confirmed, shipped, cancelled.
uv run main.pyOutput will be written to data/orders_out.json.
- Reads all records from the input file
- Validates that required fields are present
- Filters out records with unrecognised statuses
- Enriches each valid record with
total_with_taxand aprocessed_attimestamp - Writes the enriched records to the output file
- Prints a summary of processed / failed / skipped counts