Initial situation
ANDROS s.r.o. — a wholesale distributor of food and hygiene products in Komárno — operated its own NEX Genesis ERP system built in the early 2000s. Built on Pascal, Btrieve database and a desktop GUI in PySide6, it ran reliably but hit a ceiling:
- 249 interlinked Btrieve tables with ~2 million rows became uncontrollably slow as order volume grew.
- Mobile WMS (warehouse application) was connected via a SOAP wrapper with high latency.
- Manual supplier invoice processing — the accountant transcribed PDFs into the system, 30–50 documents daily, with frequent VAT and product code errors.
- No automated process for matching incoming goods with the purchase order.
Goal
Migrate the production system to a modern Python/PostgreSQL stack without disrupting daily operations, and at the same time automate supplier invoice processing using local AI so that accounting can handle the current volume without headcount increase.
Solution
Architecture: Gradual side-by-side migration. The new NEX Automat backend (FastAPI + asyncpg
- raw SQL per D-006) runs in parallel with legacy NEX Genesis via an ETL pipeline that synchronizes Btrieve → PostgreSQL incrementally every 15 minutes. Module by module is flipped from old to new.
AI invoice processing pipeline:
- PDF arrives in a watched mailbox
- Text extraction (
pdfplumber+pdf2image+ Tesseract for scanned) - Local Llama 3.x (Ollama on ANDROS) classifies the document and extracts structured fields
- Matching against open deliveries in PG via fuzzy match on item names + EAN
- Auto-write to ERP including VAT split by groups
- Edge cases → queue for the accountant
Important technical decisions:
- Local AI instead of cloud API — sensitive business data (prices, suppliers) never leaves ANDROS.
- Raw SQL without ORM (D-006) — control over query plans at 50M+ rows.
- Tailscale between server and remote dispatchers — no public exposure of the ERP.
Results
- Match rate: Main supplier — 100% automatic write without human review. Other suppliers averaging 77–81% depending on PDF format quality.
- Headcount savings: roughly 2 full-time positions in accounting freed up for higher-value work.
- Mobile WMS latency dropped from ~1500 ms (SOAP) to ~80 ms (REST + asyncpg).
- Zero incidents during migration — no production outage during the 18-month transition.
Stack and infrastructure
Operates on ANDROS proprietary hardware (Dell PowerEdge R740XD, 256 GB RAM). Local AI via
Ollama covers two models — llama3.1:8b for classification, nomic-embed-text for RAG indexes
over the supplier catalog. Backup via restic to an off-site B2 location.