
hello-ediflowSeries: Building EDIFlow - A Clean Architecture Journey in TypeScript (Part 1/6) Author:...
Series: Building EDIFlow - A Clean Architecture Journey in TypeScript (Part 1/6)
Author: EDIFlow
Published: February 2026
Reading Time: ~7 minutes
I've been working in data integration for over 20 years. SOAP, REST APIs, and yesβEDI. Lots of EDI.
If you've ever worked with EDIFACT, you know the pain:
UNH+1+ORDERS:D:96A:UN'
BGM+220+ORDER12345+9'
DTM+137:20240201:102'
NAD+BY+BUYER123::92'
What does BGM+220 mean? What is DTM+137? What's ::92?
This is the "old school EDI" world:
And the existing parsers? They don't help much:
// β Typical EDI Parser - Generic segments
const bgm = message.segments.find(s => s.tag === 'BGM');
const docNumber = bgm?.elements[1]?.value; // What is element[1]? π€·
No type safety. No IntelliSense. No business logic.
After 20+ years of this, I had enough. I wanted to build an EDI library that:
So I started EDIFlow.
But here's the honest truth: I didn't just want to build a library. I wanted to LEARN Clean Architecture by doing.
I first encountered Clean Architecture around 2020. Read the books:
I was hooked. The principles made so much sense:
But then I tried to apply it at work...
Typical problems I faced:
The structures were too entrenched. No trust in "new" architectures. The typical corporate fears.
Sound familiar?
I realized: The best way to learn Clean Architecture is to build something real from scratch.
Not a TODO app. Not a toy example. A real-world library that solves a real problem.
So when I decided to build EDIFlow, I made a commitment:
Could I have hacked it together in a weekend? Sure!
But where's the learning in that? π€·
This is the question everyone asks: "Is Clean Architecture worth the extra effort?"
My answer: YES! But it wasn't without challenges.
What went well:
But there were challenges too:
The verdict? For a library like EDIFlow: Absolutely worth it! Every hour spent on architecture saved me days in maintenance.
For a throwaway script? Probably overkill.
(We'll dive into the honest pros & cons, with real examples, in Part 5!)
EDI parsing is complex. You're dealing with:
Without type safety, this becomes a nightmare.
// β JavaScript - Runtime errors waiting to happen
const delimiters = {
component: ':',
element: '+',
segment: "'"
};
delimiters.component = delimiters.element; // Oops! No error! π₯
// β
TypeScript - Caught at compile time
export class Delimiters {
private constructor(
public readonly component: string,
public readonly element: string,
public readonly segment: string
) {
if (component === element) {
throw new Error("Delimiters must be different!");
}
}
}
// β
Auto-completion works!
const order = mapper.mapToBusinessObject(message);
console.log(order.documentNumber); // IntelliSense suggests fields
console.log(order.parties.buyer.id); // Type-safe navigation
console.log(order.lineItems[0].quantity); // No guessing!
// Domain Layer - Just an interface, no implementation details
export interface IEDIParser {
parse(message: string): EDIMessage;
}
// Infrastructure Layer - Implements the interface
export class EdifactMessageParser implements IEDIParser {
parse(message: string): EDIMessage {
// EDIFACT-specific logic here
}
}
This is Dependency Inversion in action! The domain doesn't know about EDIFACT. The domain just knows "I need a parser."
TypeScript compiles to JavaScript, so it works everywhere:
npm install @ediflow/core # Works in Node.js
import { EdifactParser } from '@ediflow/core'; # Works in browsers (with bundler)
Plus, TypeScript generates .d.ts files automaticallyβusers get IntelliSense out of the box!
Before EDIFlow, EDI development was:
element[3] meansWith TypeScript:
TypeScript isn't just a nice-to-have for EDIFlow. It's essential.
I could have built EDIFlow as a private project. But I chose open source for several reasons:
When you know others might read your code, you write better code.
No shortcuts. No "I'll fix this later." Everything has to be production-ready.
Open source means:
The best products are built WITH the community, not just FOR them.
Let's be honest: If I'm spending 100+ hours building this, I want to:
Open source is the ultimate resume.
I'm not the only one struggling with EDI libraries. By open-sourcing EDIFlow, I hope to:
EDIFlow is MIT licensed:
Why MIT? Because I want maximum adoption. The more people use it, the better it gets.
Okay, enough about motivation. What IS EDIFlow?
Companies exchange business documents electronically:
Instead of paper, they send structured messages like:
UNH+1+ORDERS:D:96A:UN'
BGM+220+ORDER12345+9'
DTM+137:20240201:102'
...
EDIFACT (Electronic Data Interchange For Administration, Commerce and Transport) is the United Nations standard for EDI.
It's used globally, especially in:
EDIFlow is:
Built with:
And this is just the beginning! π
Right now, EDIFlow supports EDIFACT (4 versions). But the journey continues:
The Clean Architecture foundation makes adding new formats easy. That's the power of good design!
import { DIContainer } from '@ediflow/core';
// 1. Parse EDIFACT string
const container = DIContainer.getInstance();
const parseUseCase = container.resolve('ParseEDIUseCase');
const result = parseUseCase.execute({
message: edifactString,
standard: 'EDIFACT'
});
console.log(result.message.messageType); // "ORDERS"
// 2. Map to business object (type-safe!)
const mapper = container.resolve('BusinessObjectMapper');
const order = mapper.mapToBusinessObject(result.message);
console.log(order.documentNumber); // "ORDER12345"
console.log(order.parties.buyer.id); // "BUYER123"
console.log(order.lineItems[0].productId); // IntelliSense works!
// 3. Modify with type safety
order.lineItems[0].quantity = 150;
// 4. Build back to EDIFACT
const buildUseCase = container.resolve('BuildEDIUseCase');
const ediString = buildUseCase.execute({
message: mapper.mapFromBusinessObject(order),
standard: 'EDIFACT'
});
This is what "modern EDI" looks like. β¨
Let me give you a sneak peek at what we've built so far:
Current (EDIFACT):
Coming Soon:
Current Total: 618 EDIFACT message types supported (and growing!)
any types!βββββββββββββββββββββββββββββββββββββββββ
β Presentation Layer β CLI, API, UI (Future)
β β
β βββββββββββββββββββββββββββββββββββ β
β β Infrastructure Layer β β Parsers, Repositories
β β β β
β β βββββββββββββββββββββββββββββ β β
β β β Application Layer β β β Use Cases, Services
β β β β β β
β β β βββββββββββββββββββββββ β β β
β β β β Domain Layer β β β β Entities, Value Objects
β β β βββββββββββββββββββββββ β β β
β β βββββββββββββββββββββββββββββ β β
β βββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββ
Dependency direction: Always inward β β β β
Note: Presentation Layer (CLI, REST API, Web UI) is planned for future releases!
This is just Part 1 of 6! Here's what's next:
Each article: 1000-1800 words, deep technical dive with real code!
EDIFlow is more than just a library. It's my journey of:
I'm not claiming EDIFlow is perfect. I've made mistakes. I've refactored. I've learned.
And that's exactly what this series is about.
In the next 4 articles, I'll show you:
I built EDIFlow with GitHub Copilot as my pair programming partner. Now I'm sharing the journey with you.
Follow along, and let's learn together!
Try EDIFlow:
Join the Community:
Read More:
This series is for you. What topics should I cover?
Comment below! π
Next week, we'll dive into the Domain Layer:
See you next week! π
If you found this helpful:
Let's make EDI development great again! π
This article is part of the "Building EDIFlow: A Clean Architecture Journey in TypeScript" series. Follow along as we build a production-ready EDIFACT library from scratch using Clean Architecture principles.
Word Count: ~1,650 words
Reading Time: ~7 minutes
Series: Part 1 of 6
Coming Soon: