Menu

Post image 1
Post image 2
1 / 2
0

Building a Multi-Tenant NF-e API with Laravel + SEFAZ: 6 Hard Lessons

DEV Community·Paulo Fox·about 1 month ago
#t2lJsedS
Reading 0:00
15s threshold

Brazil mandates that every business issuing goods or services emit an NF-e (Nota Fiscal Eletrônica) — a government-signed XML submitted to SEFAZ in real-time. The protocol is SOAP-based, from 2006, documented only in Portuguese, and the homologation environment goes offline on weekends. I spent 6 months building FoxNFe — a multi-tenant SaaS that abstracts all of this into a simple REST API. Here is everything I learned the hard way. The Architecture Tenant App ──REST──► FoxNFe Laravel API ──SOAP/XML──► SEFAZ (27 states) │ PostgreSQL RLS Redis + Queues Certificate Store Enter fullscreen mode Exit fullscreen mode Laravel 11 — API backend, queued jobs, service layer PostgreSQL + RLS — row-level security per tenant Redis + Laravel Queues — async processing (SEFAZ takes 2–30s per request) A1 Digital Certificates — encrypted per-tenant, loaded at runtime 27 SEFAZ endpoints — one per Brazilian state, routed by CNPJ UF Lesson 1: PostgreSQL RLS finally Is Not Optional Multi-tenant apps on PostgreSQL often use…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More