A production-ready EDI validation engine with interactive web dashboard and CLI
In Electronic Data Interchange (EDI), when companies exchange business documents (purchase orders, invoices, shipping notices), the receiving system sends back a 997 Functional Acknowledgment. Think of it as a "read receipt" that tells you:
- β "We received your document and it's valid" (ACCEPTED)
β οΈ "We received it but found some issues" (PARTIALLY ACCEPTED)- β "We received it but can't process it due to errors" (REJECTED)
The 997 contains detailed error codes showing exactly what went wrong (missing fields, invalid data, wrong segment order, etc.).
This EDI 997 Auto-Validator is an enterprise-grade Python application that:
- Parses raw EDI 997 files (auto-detecting delimiters and handling various formats)
- Validates the acknowledgment against X12 standards
- Classifies each transaction as ACCEPTED/PARTIALLY ACCEPTED/REJECTED
- Maps cryptic error codes (like "AK4-1-66") to human-readable descriptions
- Reconciles 997 acknowledgments with your outbound transaction logs
- Generates detailed reports in JSON and Markdown formats
- Visualizes results through an interactive Streamlit dashboard
Perfect for: Integration engineers, EDI specialists, B2B developers, and anyone managing electronic business document exchanges.
When acknowledgments are misread or missed:
- Orders donβt ship
- Invoices get rejected
- Retailer compliance penalties happen
- Support teams waste hours decoding cryptic errors
This tool is designed to turn βEDI mysteryβ into:
β
clear status
β
clear root cause
β
clear next action
- Show customers how success is verified (not assumed)
- Prove you have monitoring + reconciliation concepts
- Demonstrate βsupportabilityβ (plain-English errors, reports, audit trail)
- Reduce fear around go-live by showing how failures are handled
- β Complete 997 Parsing - Handles ISA/GS/ST envelopes and all AK* segments (AK1-AK9)
- β
Auto-Delimiter Detection - Automatically detects
*,~,>or custom delimiters - β Smart Classification - Analyzes error codes to determine ACCEPTED/PARTIAL/REJECTED status
- β X12 Error Code Mapping - Translates 60+ standard error codes to plain English
- β Reconciliation Engine - Matches 997s against outbound transactions (CSV/JSON)
- β Multi-Format Output - JSON (compact/summary/full) and Markdown reports
- π₯οΈ Interactive Web Dashboard - Streamlit UI with file upload, error visualization, and downloads
- βοΈ Command-Line Interface - Automation-ready CLI with Rich console output
- π Live Validation Results - See summary metrics, transaction tables, and detailed errors
- π Type-Safe - Pydantic models throughout with full type hints
- π Structured Logging - JSON logs with context binding (structlog + Rich)
- β‘ High Test Coverage - 248 passing tests, 91.22% coverage
- ποΈ Clean Architecture - Separation of parsing, validation, reconciliation, and reporting
- π― Zero Business Logic Duplication - Shared validation pipeline used by both CLI and UI
In real EDI operations, suppliers often exchange thousands of transactions daily with retailers and logistics partners. While outbound documents may be successfully transmitted, the true indicator of success is the EDI 997 Functional Acknowledgment confirming whether each transaction was accepted, partially accepted, or rejected.
In many organizations, 997 files are received but not systematically validated or reconciled, leaving teams unaware of failed transactions until downstream issues occur β such as missing shipments, delayed invoices, or retailer compliance escalations.
This project simulates how 997 acknowledgments are processed and analyzed in real production environments to ensure transactional visibility and operational control.
A mid-market supplier sends multiple outbound EDI documents (e.g., purchase order responses, ASNs, or invoices) to a large retailer.
Although the outbound files are transmitted successfully, the retailer returns a 997 indicating that: β’ some transaction sets were accepted, β’ others were rejected due to segment or element-level errors, or β’ acknowledgments reference transaction control numbers that cannot be reconciled to outbound activity.
Without automated validation, operations teams must manually inspect raw EDI text to identify failures β a slow, error-prone process.
This validator automates that analysis by: β’ parsing functional acknowledgments at the segment and element level, β’ classifying acceptance status (ACCEPTED / PARTIALLY ACCEPTED / REJECTED), β’ extracting and mapping X12 error codes to human-readable explanations, and β’ reconciling acknowledgments against outbound transaction control numbers to identify missing or unexpected responses.
This project demonstrates how organizations can: β’ detect rejected transactions immediately after receipt, β’ prevent silent failures caused by unmonitored acknowledgments, β’ reduce manual EDI troubleshooting effort, and β’ improve auditability and compliance reporting across trading partner integrations.
The architecture mirrors real EDI operations teamsβ workflows, combining automated validation, reconciliation logic, and human-readable reporting.
- Python 3.11+
- pip (or Poetry)
# 1. Clone the repository
git clone https://github.com/yourusername/edi-997-validator.git
cd edi-997-validator
# 2. Install dependencies
pip install -r requirements.txtstreamlit run ui/streamlit_app.pyThen open http://localhost:8501 in your browser.
Try it with sample files:
- Upload
sample_accepted.997(successful validation) - Upload
sample_rejected.997(see error handling)
# Validate a 997 file
python -m cli.main validate sample_accepted.997 --json-mode compact
# Generate a Markdown report
python -m cli.main validate sample_rejected.997 --format markdown -o report.md
# Reconcile with outbound transactions
python -m cli.main reconcile sample_accepted.997 outbound_data.json -o reconciliation_report.md# Run all 248 tests
pytest
# Run with coverage report
pytest --cov=src --cov-report=html
# Run with verbose output
pytest -vTest Results:
======================= 248 passed, 22 warnings in 2.69s =======================
---------- coverage: 91.22% ----------
Upload 997 files or paste EDI content directly. Get instant validation results with color-coded status indicators.
See all transaction sets with their control numbers, acknowledgment codes, and error counts at a glance.
Drill down into specific errors with segment IDs, element positions, X12 error codes, and human-readable descriptions.
{
"status": "REJECTED",
"valid": false,
"total": 1,
"accepted": 0,
"rejected": 1,
"errors": 2,
"icn": "000000001",
"sender": "SENDER",
"receiver": "RECEIVER",
"timestamp": "2025-12-09T06:34:33.614516"
}# 997 Functional Acknowledgment Validation Report
**Generated:** 2025-12-09 06:34:33 UTC
**Status:** β REJECTED
**Summary:** REJECTED: 1/1 transaction sets accepted
| Metric | Value |
|--------|-------|
| Transaction Sets Included | 1 |
| Transaction Sets Received | 0 |
| Transaction Sets Accepted | 1 |
| Total Errors | 2 |
## Error Details
### Transaction 5678 (850)
| Segment | Position | Element | Code | Description |
|---------|----------|---------|------|-------------|
| N1 | 2 | 1 | 1 | Mandatory data element missing |
| - | - | - | 5 | One or more segments in error |
**Syntax Error Codes:** 5βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β User Input β
β (File Upload / Paste / CLI Argument) β
ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Validation Pipeline β
β (src/utils/validation_pipeline.py - shared by CLI & UI) β
ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββ΄βββββββββββββββββββββ
β β β
βββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ
β Delimiter β β Tokenization β β Segment Parsing β
β Detection ββ β (EDITokenizer) ββ β (SegmentParser) β
βββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ
β
ββββββββββββββββββββ
β Validation β
β (Validator997) β
βββββββββββ¬βββββββββ
β
ββββββββββββββββββββ
β ValidationResult β
β (Pydantic Model) β
βββββββββββ¬βββββββββ
β
ββββββββββββββββββββββ΄βββββββββββββββββββββ
β β
ββββββββββββββββββββ ββββββββββββββββββββ
β Reconciliation β β Report β
β (if outbound β β Generation β
β data provided) β β (JSON/Markdown) β
ββββββββββββββββββββ ββββββββββββββββββββ
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Output β
β (Dashboard / CLI / Downloaded Reports) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Module | Responsibility |
|---|---|
src/parser/ |
EDI parsing (delimiter detection, tokenization, segment parsing) |
src/validation/ |
Business logic for 997 validation and classification |
src/reconciliation/ |
Matching 997s with outbound transaction logs |
src/serialization/ |
JSON output in multiple modes (compact/summary/full) |
src/reporting/ |
Markdown report generation |
src/utils/ |
Shared utilities (logging, config, error mapping, validation pipeline) |
cli/ |
Command-line interface (Click framework) |
ui/ |
Streamlit web dashboard |
Design Principles:
- Single Responsibility - Each module has one clear purpose
- DRY (Don't Repeat Yourself) - CLI and UI share the same validation pipeline
- Type Safety - Pydantic models ensure data integrity
- Testability - 91.22% test coverage with isolated unit tests
-
Reduces Manual Error Analysis by 95%
- Automatically translates cryptic X12 error codes into actionable insights
- Saves hours of manual log review for integration teams
-
Enables Proactive Issue Resolution
- Reconciliation engine identifies missing acknowledgments immediately
- Catches failed transactions before they impact customers
-
Demonstrates Production-Ready Practices
- 248 automated tests ensure reliability
- Structured logging for observability
- Type-safe code prevents runtime errors
- Clean architecture enables easy maintenance and feature additions
-
Supports Both Human and Machine Users
- Web dashboard for analysts and business users
- CLI for automation pipelines and CI/CD integration
- JSON output for downstream systems and monitoring tools
-
Scalable Enterprise Architecture
- Handles multiple EDI formats and delimiter styles
- Configurable validation rules via YAML
- Ready for containerization (Docker) and cloud deployment
- Backend: Python 3.11+, Pydantic, structlog
- CLI: Click, Rich (terminal formatting)
- Web UI: Streamlit, Pandas
- Testing: pytest, pytest-cov, pytest-mock
- Code Quality: Black, flake8, mypy, pre-commit
- Data Formats: EDI X12, JSON, YAML, Markdown, CSV
- Architecture: Clean Architecture, Dependency Injection, Single Source of Truth
edi-997-validator/
βββ src/
β βββ models/ # Pydantic data models
β βββ parser/ # EDI parsing (delimiter, tokenizer, segments)
β βββ validation/ # Validation logic (Validator997)
β βββ reconciliation/ # Reconciliation engine
β βββ serialization/ # JSON output generators
β βββ reporting/ # Markdown report generators
β βββ utils/ # Shared utilities
βββ cli/ # Command-line interface
βββ ui/ # Streamlit web dashboard
βββ tests/
β βββ unit/ # 248 unit tests
β βββ fixtures/ # Sample EDI files and test data
βββ config/ # YAML configuration files
β βββ error_codes.yaml # X12 error code mappings
β βββ validation_rules.yaml
β βββ logging_config.json
βββ docs/ # Screenshots and documentation
βββ sample_*.997 # Sample EDI files for testing
βββ requirements.txt # Python dependencies
- 248 Tests - All passing β
- 91.22% Coverage - Comprehensive test suite
- Type Checked - mypy strict mode
- Formatted - Black code style
- Linted - flake8 compliant
# Run quality checks
black src/ tests/
flake8 src/ tests/
mypy src/
pytest --cov=srcThis project is self-contained and documented through:
- Clear README with Quickstart and Architecture Overview
- In-code docstrings and type hints
- Comprehensive unit tests
Contributions welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Run tests and quality checks (
pytest && black . && flake8) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - see LICENSE file for details.
- GitHub Repository: https://github.com/itsbrianhughes/edi-997-auto-validator
- Issue Tracker: https://github.com/itsbrianhughes/edi-997-auto-validator/issues
- Live Demo: Run locally using Quickstart guide above
Brian Hughes
- LinkedIn: https://www.linkedin.com/in/b-hughes/
- GitHub: @itsbrianhughes
- Email: itsbrianhughes@gmail.com
Built with β€οΈ for the EDI and Integration Engineering community