Arquitetura e Funcionamento

Por baixo: microsserviços, cache inteligente, proteção PII, filas assíncronas, otimização adaptativa.

System Overview

BTOVEN Translate is a translation middleware platform layered on LibreTranslate (Argos models), adding production-grade features: PII protection, smart caching, async queues, advisory debugging, and multi-SDK distribution — all with zero data retention.

Layer Diagram

Client Layer: Astro SDK · CLI · Python SDK · Node SDK · REST API · MCP Server
Edge Middleware: Proxy (btoven.middleware.app) → Advisory headers (X-Btoven-Advisory) → Insights (/insights)
Job Queue: Redis-backed (btoven.middleware.jobs) → Priority · Dedup · Supersede · Webhooks · TTL
PII Protector: 52-pattern detection (MCP Protector) → {TYPE N} placeholders → Restore post-translation
Translation Engine: LibreTranslate v1.9.6 (Argos) — 50+ languages · HTML/Text formats · /translate, /detect, /languages
Storage: Redis (shared L0KL) for jobs/insights · SQLite fallback · No translation persistence

Request Flow

  1. Client calls SDK.translate() or POST /jobs/translate (async) or POST /translate (sync)
  2. Edge Middleware receives request → observes (latency, chars, errors) → generates advisories (X-Btoven-Advisory header)
  3. PII Protector (if enabled) scans payload → replaces 52 PII patterns with {TYPE N} placeholders
  4. Glossary Protection (SDK) wraps brand terms in {GL N} placeholders that survive translation
  5. Job Queue (async): enqueues with priority, dedup by content hash, supersede queued twins
  6. Worker (bounded concurrency) picks job → calls LibreTranslate internal → saves result
  7. Restore: placeholders → original terms; PII restored if enabled
  8. Response: JSON result + advisory headers + optional webhook callback
  9. Insights: observation persisted to Redis JSONL → /insights aggregates (p50, p95, throughput, repeats, errors)

Key Design Decisions

Redis JobStore (not in-memory)

Cross-process visibility, survives edge restarts, zset priority queue, content-hash index for dedup.

Protected-mode Redis on host

L0KL shared redis (127.0.0.1:6379) runs protected-mode → container needs password or dedicated redis. Documented in compose.

Single worker per edge (--workers 1)

JobStore is in-memory in worker process; >1 worker splits state. Priority queue is per-process zset in Redis.

No translation persistence

Zero data retention by design. Only job metadata (TTL 1hr) and insights (aggregated) stored.