Case study / ValidaTuFactura
AI-powered electronic invoice validation SaaS
Automated Fiscal Invoice Extraction & DIAN Verification API
The Challenge
Colombian businesses process electronic invoices across inconsistent formats (XML UBL 2.1, PDFs, scanned images, and ZIP bundles) and must manually cross-check every CUFE against the DIAN fiscal registry—a slow, error-prone workflow for accounting teams.
The Architecture & Engineering Highlights
Multi-Format Ingestion Pipeline
Built a layered extractor architecture (routers → services → extractors) returning a unified schema across XML UBL 2.1, PDF, images, and ZIP archives. ZIP ingestion prioritizes XML over PDF and enforces decompression limits.
Applied AI (OCR) & Reconciliation
Integrated Azure Document Intelligence for scanned invoices and images, normalizing Colombian and US currency formats and reconciling extracted totals against official DIAN records within a 1 COP tolerance.
Security-First Design
Hardened XML parsing against XXE (resolve_entities=False, no_network=True), sanitized file uploads against path traversal, and enforced per-user daily quotas, IP rate limiting, and HTTP security headers.
Observability & Auditability
Stored validation history in PostgreSQL (JSONB payloads, match flags, and processing latency) and added structured logging with X-Request-ID and X-Process-Time-Ms.
Automated Fiscal Verification
Containerized an isolated browser worker (Chrome + Xvfb) that runs as a subprocess to verify CUFEs against the DIAN portal.
The Result
Validation went from minutes of manual checks to seconds, with a record of each request and its outcome.