There was a morning in Karachi I still think about.
A junior documentation officer — maybe 23 years old, first real job — had typed “Cotton Jersey Fabric” on the commercial invoice. The LC said “100% Cotton Jersey Knitted Fabric.” Seven words versus five. To a human reading it, identical. To a bank processing a Letter of Credit under UCP 600, a discrepancy. The shipment was USD 75,000. The bank rejected the documents. The buyer in Germany waited. The mill owner spent three days on the phone. The relationship survived — barely.

That officer did nothing wrong. He just didn’t know the rule. Nobody had told him that LC document descriptions must match word for word. Nobody had built him a system that would catch it before it became a crisis.
I was the QA engineer in the room that day. I remember the look on his face when he understood what had happened.
Ten Years of Watching the Same Mistakes Happen
I graduated from NEDUET in 2014 with a BE in Textile Engineering. I went straight to the factory floor and stayed there for a decade — QA, production, export sales engineering, working with mills across Karachi and Faisalabad.
In those ten years I saw one pattern repeat itself constantly. Pakistani textile manufacturers — many of them genuinely world-class in fabric quality — were losing money, losing buyers, and losing confidence not because their product was wrong. Because their paperwork was wrong.

I watched a shipment of towels sit at Dubai customs for eleven days because the Certificate of Origin wasn’t attested by the Saudi Embassy. I watched a first-time exporter ship to a UK buyer without knowing that Pakistan qualifies for UK DCTS duty preferences — he paid 12% duty when he could have paid 0%. I watched mills use the wrong HS code for years, sometimes overpaying duty, sometimes triggering customs inspections that delayed shipments by weeks.
The knowledge to avoid all of this exists. It’s in trade agreement documents, customs authority websites, UCP 600 guidelines, Chamber of Commerce procedures. But it’s scattered across dozens of sources, written in language that assumes you already know what you’re doing, and it changes often enough that keeping up is itself a full-time job.
Small and medium mills don’t have a full-time trade compliance officer. They have one documentation person, sometimes a junior one, doing their best.
That’s the problem I carried with me when I started learning AI.
The Trilogy — Three Projects, One Story
When I decided to build an AI portfolio for the textile industry, I made a deliberate choice. I wasn’t going to build random projects to collect GitHub stars. I was going to build three systems that solve the full export journey — in order.
TextileBot came first. It’s a WhatsApp AI agent that qualifies international buyer leads automatically. Seven LangGraph nodes, Groq API, ChromaDB, RAG. It solves the first problem: finding and qualifying the right buyer.
DPPBot came second. The EU now requires Digital Product Passports for textile products — a complex compliance framework most Pakistani exporters have never heard of. DPPBot checks compliance, scores readiness, and generates action plans. Eight nodes. It solves the second problem: proving you’re compliant to the buyer you just found.
TradeBot is the third. You’ve found your buyer. You’ve proved your compliance. Now you need to actually ship the order — with the right documents, the right HS codes, the right certifications, the right format for that specific country’s customs authority. Nine nodes. It solves the third problem: executing the export.

TextileBot finds the buyer. DPPBot proves you deserve them. TradeBot ships the order.
I didn’t plan this trilogy from day one. But somewhere during DPPBot I realised that what I was building was a complete system — and that felt worth finishing properly.
What TradeBot Actually Does — In Plain Language
Imagine you’re a mill owner in Faisalabad. You’ve got a buyer in Germany who wants 20,000 metres of bed linen. You open TradeBot, fill in a form — your company name, the product, the composition, the GSM, the destination, the buyer, the quantity, the FOB value, the Incoterm, the payment method, your certifications.
You click Generate.
In about 90 seconds, TradeBot runs your input through a 9-node AI pipeline. It checks what documents Germany specifically requires. It identifies the correct HS code for your product. It calculates whether Pakistan’s EU GSP+ status gives you a duty advantage — and tells you exactly how much money that saves your buyer. It checks your document package against LC requirements if you’re on LC payment. It flags anything missing.
Then it hands you five documents: a commercial invoice, a packing list, an HS code report with duty calculations, a compliance report with specific risk flags, and an export readiness score from 0 to 100 with a prioritised action list.
For that Germany bed linen shipment, TradeBot identified a USD 5,400 duty saving through EU GSP+ that the exporter could pass to the buyer as a competitive advantage. It flagged that CIF terms require a marine insurance certificate. It noted that OEKO-TEX and GOTS certifications should be attached to the document package for that buyer profile.
That’s what it does. No jargon. No consulting invoice. Ninety seconds.

Building It — The Honest Version
I want to be straight about how this actually went, because the polished GitHub repo doesn’t show the full picture.
The technical stack is Python 3.11, LangGraph for the agent pipeline, Claude API for document generation, ChromaDB as an in-memory vector database, sentence-transformers for embeddings, Jinja2 for document templates, and Streamlit for the web interface. I built it across three Jupyter notebooks over several sessions, going cell by cell.
It did not go smoothly.
The first real frustration was ChromaDB. When I restarted a notebook session and tried to create the collection again, it threw an InternalError — collection already exists. In-memory ChromaDB doesn’t persist between restarts but it does persist within a session, and I kept hitting that wall. The fix was one line: get_or_create_collection instead of create_collection. But finding that line cost me forty minutes.
The second frustration was JSON parsing. Claude’s responses are reliable but not perfectly consistent — sometimes a response would include a trailing character or an incomplete string that caused JSONDecodeError. This happened mid-pipeline during Scenario C testing, at Node 7, with the compliance checker. The fix was increasing max_tokens from 800 to 1200. But when I went back to edit that one line, I introduced an indentation error that broke the entire cell. I had to rewrite the whole node.
The third frustration was the Streamlit launch. I tried running streamlit run app.py from the regular Windows Command Prompt instead of Anaconda Prompt — and got “streamlit is not recognised as an internal or external command.” Then when I finally used Anaconda Prompt correctly, the cd command didn’t switch drives because I forgot that Windows requires you to type D: first before cd works on a different drive. The app was loading a completely different project from my home directory for twenty minutes before I figured out what was happening.
None of this is embarrassing. It’s just what building software actually looks like. Every one of these problems had a logical solution once I understood what was actually happening. That’s the job.

The Five Documents and Why Each One Matters
TradeBot generates five documents per shipment. Each one represents a specific failure mode I watched happen in real mills.
The Commercial Invoice is where LC discrepancies are born. TradeBot generates it with the correct formal product description, the HS code, the Incoterm application, and the exact payment terms — structured to match LC requirements.
The Packing List seems simple until a customs officer at Jebel Ali asks for a carton-wise breakdown and you realise your document just says “500 cartons” with no dimensions or weights. TradeBot calculates realistic carton specifications based on product type and quantity.
The HS Code Report is the one that surprises people most. Most exporters pick an HS code once and use it forever, often incorrectly. TradeBot classifies the product, gives the 6-digit international code and the destination-specific extended code, states the MFN duty rate, checks GSP applicability, and calculates the actual dollar saving on that specific shipment.
The Compliance Report is the pre-shipment checklist nobody has. It flags LC discrepancy risks against UCP 600 rules, identifies certification gaps for that buyer profile, and notes country-specific regulatory requirements.
The Export Readiness Score is a 0-100 number with a grade and a prioritised action list. Scenario E — an organic cotton shipment to Patagonia with GOTS and OEKO-TEX certifications present — scored 68. Scenario C — a denim shipment with no certifications on CAD payment — scored 28. The score tells you honestly where you stand before you ship.

What This Means for a Textile Business
I’m not going to tell you this system will transform your export operation overnight. I’m going to tell you what I think it actually does.
It gives a junior documentation officer a second opinion before the documents leave the building. It tells a first-time exporter what Germany specifically requires versus what UAE requires versus what the USA requires — without them having to research it across fifteen websites. It finds GSP duty savings that experienced exporters sometimes miss and first-time exporters almost always miss.
The mill owner in Faisalabad who had that USD 75,000 LC rejection — if he had run that shipment through something like TradeBot, the description mismatch would have been flagged before the documents went to the bank. That’s the whole idea.
What Comes Next
The code is on GitHub at github.com/Junaid1991-maker/tradebot-export-agent. It’s open source. The knowledge base covers USA, UK, Germany, France, Italy, UAE, Saudi Arabia, and Australia. It can be extended to any destination country by adding a text file.
I’m looking for textile businesses — mills, export houses, trading companies — who want to test this against real shipments. Not for payment. For feedback. Real-world testing is the only way to know what I’ve missed.
The trilogy is complete. But the work is not finished.
Ten Years to Ninety Seconds
I started this AI journey about eight months ago. I had a textile engineering degree, a decade of factory floor experience, and zero machine learning background. I didn’t start with the easy projects. I started with the problems I knew personally.
That’s the only thing I’d tell anyone who asks how to break into AI from a non-CS background. Don’t start with the tutorials. Start with the problem you’re angry about. The one that kept you up at night in your previous career. The one where you thought — someone should really fix this.
Then build the fix.
The ten years weren’t wasted. They were the knowledge base.
If you work in textile exports and want to test this — find me on LinkedIn.
— Junaid



Leave a comment