MIT Open Source · v1.0.0 · Node.js & Python · Zero Dependencies
stc-freight-tools Freight EDI 204/214/210/990 & DOE/EIA FSC Toolkit
Deterministic, zero-dependency engineering library for ANSI X12 Motor Carrier EDI parsing & envelope validation,
U.S. DOE/EIA Form EIA-888 diesel fuel surcharge peg-scale schedules, and trucking cost-per-mile (CPM) & Operating Ratio analytics.
Authored and maintained by Strong Tower Consulting, LLC (Forest City, Iowa · Est. 2008).
Built from production motor carrier TMS, brokerage, and intermodal engineering engagements across North America. Every calculation uses integer-scaled arithmetic to prevent IEEE 754 drift at tariff bracket edges.
1. ANSI X12 EDI Parser & Validator
Auto-detects element, sub-element, and segment delimiters directly from the 106-character ISA header. Verifies ISA13/IEA02, GS06/GE02, and ST02/SE02 control parity, duplicate ST02 collisions, segment counts (SE01), and EDI 210 L1 sum vs. B307 net-amount reconciliation.
Computes loaded vs. total-mile cost-per-mile, deadhead drag, break-even rate per loaded mile, net profit, margin %, and trucking Operating Ratio (OR) across per-mile, loaded/empty split, flat, and percentage-of-revenue driver pay structures.
Clone directly from github.com/stjmelliott/stc-freight-tools or run the built-in CLI in CI/CD pipelines for automated EDI 204/214/210/990 linting and tariff verification.
# Validate an EDI 204 load tender or EDI 210 carrier invoice
stc-freight edi validate ./invoice-210.edi
stc-freight edi parse ./tender-204.edi
# Calculate DOE/EIA Fuel Surcharge at U.S. Nov 30, 2026 ($5.474/gal)
stc-freight fsc --diesel 5.474 --base 1.20 --mpg 6.0 --step 0.06 --miles 800
# Generate uncapped peg-scale schedule through $8.50/gal (California 2026 peak $8.246)
stc-freight fsc-table --base 1.20 --max 8.50 --step 0.06 --mpg 6.0
# Run zero-dependency test suites
node test/run-tests.mjs
python -m unittest discover -s tests
Interactive DOE/EIA Peg-Scale Preview
Test bracket-boundary math directly in the browser (pre-seeded with the verified November 30, 2026 U.S. National EIA Form EIA-888 diesel average of $5.474/gal). For full regional PADD comparisons and interactive schedules, use the Strong Tower EIA Diesel FSC Index Calculator.
Bracket FSC / Mile
$0.710
Continuous FSC / Mile
$0.712
Total Load FSC (Bracket)
$532.50
Loss If Capped @ $5.00
$59.25
Exported API Surface
Parity across both ES Modules (src/index.js) and Python (stc_freight_tools).
Node.js Export
Python Export
Responsibility
parseEdi(raw)
parse_edi(raw)
Parses ISA/GS/ST envelopes and 204, 214, 210, 990 loops into structured dictionaries/JSON.
validateEdi(raw)
validate_edi(raw)
Runs structural, control-number, segment-count, and EDI 210 L1 vs. B307 financial reconciliation checks.
calculateFsc(opts)
calculate_fsc(...)
Computes continuous and integer-scaled bracket DOE/EIA fuel surcharges per mile and per load.
generatePegSchedule(opts)
generate_peg_schedule(...)
Builds complete uncapped FSC tariff tables from base peg through arbitrary diesel ceilings.
calculateCostPerMile(opts)
calculate_cost_per_mile(...)
Calculates loaded/total CPM, deadhead cost, break-even linehaul, net profit, and Operating Ratio.