InvoiceFLOW
B2B SaaS platform for automated fiscal invoicing and Verifactu compliance.

🔍 Overview
Multi-tenant B2B SaaS platform engineered for tax invoice generation, fiscal verification, and billing lifecycle automation compliant with the Spanish Verifactu regulatory framework. The solution enforces clear separation of concerns: lightweight cryptographic checks on Next.js Edge Runtime and heavy business logic in NestJS backed by PostgreSQL.
🌟 Key Features
- Cryptographic Validation on Edge Runtime: Near-instant signature and digital fingerprint validation on Next.js Edge Runtime, dropping verification latency by 40%.
- Distributed PDF Generation (BullMQ + Redis): Asynchronous background worker fleet for dynamic PDF compilation tied to Stripe subscription tiers, preserving server latencies below 200ms under load.
- ACID Transactions via Unit of Work: Strict invoice lifecycle state management using Prisma ORM under the Unit of Work pattern, ensuring audit-proof immutability and regulatory compliance.
- Mini-CRM & Balance Reconciliation: Relational data layer allowing tenants to monitor invoice lifecycles (pending > paid > overdue) and automate balance reconciliation in real time.
🧠 Challenges & Learnings
Event Loop Blocking on PDF Renders: Dynamic PDF document compilation created CPU spikes that degraded the HTTP API. Isolated CPU-heavy tasks into background worker queues with BullMQ and Redis, enforcing rate limits and exponential backoff.
Regulatory Immutability (Anti-Tampering): Ensuring chained, tamper-evident fiscal audit logs required row-level transaction locks and cryptographically hashed verification before transaction commits in PostgreSQL.
🎯 Outcome
An enterprise-grade billing engine providing strict ACID consistency, tenant isolation, and sub-150ms API response times under high concurrency.