DEV Community

luis eduardo
luis eduardo

Posted on

How I Built a 100% AI-Generated Document Translator with WCAG AAA & Zero-Data Retention

๐Ÿš€ Building a 100% AI-Generated Document Translator

Overview: A full-stack, production-grade web application created entirely via AI/Vibe Coding. It converts complex legal terms, fine print, and bureaucratic bills into everyday Portuguese while enforcing WCAG AAA accessibility and strict LGPD compliance.


1. ๐Ÿ“Œ Introduction

Recently, I set out to test the limits of Vibe Coding by building an end-to-end software product using AI-driven development.

The result is the Real-World Document Translator (Tradutor de Documentos da Vida Real). Its goal is to bridge the accessibility gap for elderly individuals, people with low vision, and folks with limited literacyโ€”allowing anyone to understand legal and financial contracts without needing a lawyer.


2. ๐ŸŽฏ The Challenge

Translating legal documents through AI presents two major technical hurdles:

Challenge Impact / Risk
Privacy & LGPD Raw documents contain sensitive PII (CPFs, bank accounts, emails). Standard regex fails due to OCR noise (broken numbers, homoglyphs).
Accessibility Most web tools ignore low-vision users and the elderly, lacking high contrast, scalable typography, and native screen reader tools.

3. ๐Ÿ’ก Technical Solution & Architecture

Through iterative prompting and AI engineering, we designed a zero-trust, highly accessible architecture.

๐Ÿ›ก๏ธ Cybersecurity & Privacy (LGPD by Design)

  • BFF (Backend for Frontend): Built with FastAPI to keep API keys secure inside .env variables.
  • OCR-Resilient PII Sanitizer: Automatically normalizes homoglyphs and masks sensitive data before sending prompts to the LLM.
  • Zero-Data Retention: 100% ephemeral processingโ€”no database, no disk storage, instant memory sanitization.
  • Upload Security: Inspects Magic Bytes and enforces strict file limits to block malicious uploads.

๐Ÿ‘๏ธ Universal Accessibility (WCAG AAA)

  • Dynamic Typography: Controls ($A-$, $A$, $A+$) paired with a minimum $48\text{px}$ touch area for mobile/keyboard usability.
  • Native Text-to-Speech (TTS): Web Speech API integration with slowed playback controls tailored for elderly users.

๐Ÿ—๏ธ System Architecture Flow

[ User ] โ”€โ”€โ”€โ–ถ๏ธ [ Accessible Frontend (HTML/CSS/JS) ]
โ”‚
โ–ผ
[ Secure BFF (FastAPI) ]
โ”œโ”€โ”€ File Validation (Magic Bytes)
โ”œโ”€โ”€ PII Sanitization (OCR-Resilient)
โ””โ”€โ”€ API Key Guard (.env)
โ”‚
โ–ผ
[ Google Gemini API / Mock AI ]


4. ๐ŸŒ Real-World Application

  1. Digital Inclusion: Empowers vulnerable groups to independently review financial, rental, and legal agreements.
  2. Enterprise Privacy Standards: The OCR-resilient PII masking module can be integrated into banking, healthcare, and HR platforms handling sensitive documentation.
  3. Zero-Cost Local Sandbox: Features a Smart Mock AI mode, allowing developers to run and test full accessibility workflows locally without incurring API charges.

5. ๐Ÿง  Reflection & Career Impact

Building this project 100% through AI was a major technical milestone. It proved that Vibe Coding isn't just about speeding up syntaxโ€”it's about directing AI to construct secure, accessible, and architecturally sound systems.

Key takeaways from this build:

  • Advanced FastAPI backend structure and custom security pipelines.
  • Accessible front-end design complying with WCAG AAA standards.
  • Stress testing anonymization logic against dirty OCR data using PyTest.

๐Ÿ› ๏ธ Quick Start Guide

Want to test it locally? Follow these simple steps using Python 3.10+:


๐Ÿ”— Links & Live Demo



bash
# 1. Clone repo & install dependencies
pip install -r backend/requirements.txt

# 2. Run the application
python backend/server.py

# 3. Open [http://127.0.0.1:8000](http://127.0.0.1:8000) in your browser
Note: If no Gemini API key is configured, the server automatically defaults to Smart Mock AI mode for instant offline testing!


Enter fullscreen mode Exit fullscreen mode

Top comments (0)