STC Strong Tower Consulting, LLC · stc-freight-tools
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).

Runtime Dependencies
0 (Stdlib Only)
ANSI X12 Transactions
204 · 214 · 210 · 990
Verified Test Suites
13 Node + 13 Python
Maintainer
Strong Tower (Est. 2008)

Core Engineering Modules

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.

Try the interactive browser validator on strongtoweronline.com →

parseEdi / parse_edi validateEdi / validate_edi 204 / 214 / 210 / 990

2. DOE/EIA Fuel Surcharge Engine

Supports continuous uncapped formulas ((doeDiesel - basePeg) / mpg), stepped bracket matrices ($0.05 or $0.06 steps), and percentage-of-linehaul tariffs. Generates full audit-ready bracket tables aligned to U.S. EIA Form EIA-888 releases.

Explore the live EIA Diesel FSC Index on strongtoweronline.com →

calculateFsc calculatePercentFsc generatePegSchedule

3. Trucking CPM & Operating Ratio

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.

Inspect the 2026 Freight TMS Monograph & EIA Dataset →

calculateCostPerMile stc-freight CLI Zero External Deps

Quickstart — Node.js, Python & CLI

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.

import {
  parseEdi,
  validateEdi,
  calculateFsc,
  generatePegSchedule,
  calculateCostPerMile,
} from './src/index.js';

// 1. Parse & structurally validate ANSI X12 204 / 214 / 210 / 990
const report = validateEdi(rawX12String);
if (!report.valid) console.error(report.errors);
const parsed = parseEdi(rawX12String);

// 2. DOE/EIA Fuel Surcharge (Bracket Peg-Scale Mode — Nov 30, 2026 U.S. $5.474/gal)
const fsc = calculateFsc({
  doeDieselPrice: 5.474,
  basePegPrice: 1.20,
  mpg: 6.0,
  priceStep: 0.06,
  rateStep: 0.01,
  miles: 750,
  linehaulPerMile: 2.65,
});
console.log(fsc.fscPerMile, fsc.totalFsc, fsc.allInTotal);
from stc_freight_tools import (
    parse_edi,
    validate_edi,
    calculate_fsc,
    generate_peg_schedule,
    calculate_cost_per_mile,
)

# 1. Validate & parse ANSI X12 interchange
parsed = parse_edi(raw_x12_string)
print(parsed["valid"], parsed["transactions"][0]["data"])

# 2. DOE/EIA Form EIA-888 Fuel Surcharge (Bracket Mode)
fsc = calculate_fsc(
    doe_diesel_price=5.474,
    base_peg_price=1.20,
    mpg=6.0,
    price_step=0.06,
    rate_step=0.01,
    miles=750,
    linehaul_per_mile=2.65,
)
print(fsc["fsc_per_mile"], fsc["total_fsc"], fsc["all_in_total"])
# 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.