{"slug": "designing-a-privacy-first-architecture-for-sensitive-data-zero-ip-logging-rls-ai", "title": "Designing a Privacy-First Architecture for Sensitive Data: Zero-IP Logging, Postgres RLS, and AI Safety", "summary": "Victor Vieira, CTO and co-founder of Sigilo Profissional, detailed a privacy-first architecture for the B2B workplace-survey and whistleblowing platform, combining PostgreSQL row-level security with application-level tenant isolation, zero-IP logging, and protocol-token access for anonymous reporting. The system uses large language models to help employees structure reports and summarize eNPS sentiment while stripping PII before any data reaches external AI models, and it maintains immutable, cryptographically hashed audit logs for ISO 37002 compliance.", "body_md": "When building software that handles sensitive human data (like workplace feedback, satisfaction surveys, and compliance reports), security and privacy cannot be treated as optional features or mere legal disclaimers. They must be embedded into the core system design.\n\nAt **Sigilo Profissional** ([sigiloprofissional.com.br](https://sigiloprofissional.com.br)), a B2B SaaS platform focused on **Workplace Climate Surveys, eNPS, and Whistleblowing Channels** compliant with **ISO 37002** and **GDPR / LGPD**, privacy is the fundamental prerequisite for psychological safety. If employees do not trust the platform's anonymity, engagement drops to zero.\n\nHere is a breakdown of the security architecture and privacy controls we implemented in our Python (FastAPI) and PostgreSQL stack.\n\nTo prevent cross-tenant data leakage, we enforce tenant isolation at two independent layers:\n\n`firm_id` within SQLAlchemy.`SET LOCAL app.firm_id` per database session.\n\n```\n-- Enforcing PostgreSQL Row Level Security (RLS)\nALTER TABLE tenant_complaints ENABLE ROW LEVEL SECURITY;\n\nCREATE POLICY firm_isolation ON tenant_complaints\n  USING (firm_id = current_setting('app.firm_id')::uuid);\n```\n\n*Why both?* Even if a bug or missing filter occurs in application code, the database engine natively blocks access to data outside the active tenant context.\n\nTo ensure complete whistleblower anonymity:\n\n`X-Forwarded-For` and client IP headers. No IP addresses are saved in NGINX logs, application memory, or database records.`SGL-2026-7X3K`). Whistleblowers can check updates using their protocol token without ever creating an account or storing session cookies.\nWe use Large Language Models (LLMs) to assist employees in structuring clear reports and to summarize qualitative eNPS sentiment for management.\n\nTo prevent sensitive Personally Identifiable Information (PII) from being sent to external AI models:\n\nCompliance frameworks (such as ISO 37002) require full auditability for compliance officers. We maintain immutable audit logs for administrative actions (e.g., status updates, report triage) using cryptographic hashing, ensuring complete transparency without compromising whistleblower anonymity.\n\nAs we continue scaling our engineering stack, we are reviewing our security roadmap.\n\nWe would love feedback from the Dev.to community:\n\nLooking forward to your thoughts and suggestions in the comments!\n\n**Victor Vieira** | CTO & Co-founder @ [Sigilo Profissional](https://sigiloprofissional.com.br)\n\n🔗 [LinkedIn: Victor Vieira](https://www.linkedin.com/in/victorbvieira/)", "url": "https://wpnews.pro/news/designing-a-privacy-first-architecture-for-sensitive-data-zero-ip-logging-rls-ai", "canonical_source": "https://dev.to/bidu/designing-a-privacy-first-architecture-for-sensitive-data-zero-ip-logging-postgres-rls-and-ai-3g23", "published_at": "2026-09-14 18:32:41+00:00", "updated_at": "2026-09-14 21:36:40.268070+00:00", "lang": "en", "topics": ["ai-safety", "ai-ethics", "large-language-models", "ai-products", "developer-tools"], "entities": ["Sigilo Profissional", "Victor Vieira", "PostgreSQL", "FastAPI", "Python", "ISO 37002", "GDPR", "LGPD"], "alternates": {"html": "https://wpnews.pro/news/designing-a-privacy-first-architecture-for-sensitive-data-zero-ip-logging-rls-ai", "markdown": "https://wpnews.pro/news/designing-a-privacy-first-architecture-for-sensitive-data-zero-ip-logging-rls-ai.md", "text": "https://wpnews.pro/news/designing-a-privacy-first-architecture-for-sensitive-data-zero-ip-logging-rls-ai.txt", "jsonld": "https://wpnews.pro/news/designing-a-privacy-first-architecture-for-sensitive-data-zero-ip-logging-rls-ai.jsonld"}}