# Marcos Souza — Comprehensive Technical Dossier & Architecture Dossier ## 1. Professional Overview & Identity - **Name:** Marcos Souza - **Role:** Product Engineer / Systems Architect - **Website:** https://marcossouza.dev - **GitHub:** https://github.com/marcossouzadotdev - **Dev.to:** https://dev.to/marcossouzadotdev - **LinkedIn:** https://linkedin.com/in/marcossouzadotdev - **Email:** marcosfromrio@protonmail.com - **WhatsApp:** +55 21 97264-2433 (https://wa.me/5521972642433) - **Location:** Brazil (UTC-3) · Global Remote - **Track Record:** Lead contributor with 1,850+ commits and 200+ merged PRs across production healthcare platforms supporting dozens of autism therapy clinics. --- ## 2. Core Philosophy & Product Stance ### Loop Engineering & End-to-End Workflow Automation Engineering is not a sequence of isolated tickets; it is the discipline of closing continuous feedback loops. By automating the entire cycle—from problem framing and interactive contract mockups to automated documentation and deterministic test harnesses—teams achieve extreme velocity without architectural degradation. ### Contract-First, Code Last Validating user workflows, interface boundaries, and data schemas with disposable high-fidelity mockups before touching production databases. Rebuilding features twice is the single most expensive waste in product engineering. ### Deterministic AI Safety Nets LLMs are probabilistic reasoning engines. In mission-critical environments (such as clinical healthcare), probabilistic systems must be contained within deterministic nets: strict Pydantic schemas, automated regression eval suites, and mandatory human-in-the-loop validation queues. ### Quality as a Velocity Engine Rigid type safety, duration-balanced Playwright test sharding, and decoupled service layers are not compliance roadblocks—they are the engine that enables teams to deploy continuously to production with zero fear. --- ## 3. Flagship Architectural Case Studies & Production War Stories ### Case 01: Autonomous Help Center Generation via Custom AI Agent Skill - **Context & Business Pain:** Maintaining user documentation and onboarding tutorials manually (taking screenshots, recording steps, and updating help articles) consumed dozens of engineering and product hours after every release. Outdated docs led to high customer support ticket volumes. - **Architecture & Seam:** Created a custom agent skill that treats Markdown user journey scripts as the single source of truth. The AI agent spins up a local web instance in development, autonomously navigates through the exact user flow via browser automation, captures crisp screenshots and video recordings at critical interaction points, and compiles the official 22-tutorial interactive Help Center. - **Trade-off:** Invested upfront in deterministic script definitions in exchange for near-zero ongoing documentation maintenance. - **Measured Impact:** 80% reduction in documentation maintenance time, instant interactive onboarding for clinical staff, and measurable decrease in operational support tickets. ### Case 02: Clinical AI Agent Pipelines & Human-in-the-Loop Safeguards (ProABA) - **Context & Business Pain:** Autism therapy clinicians spent over 1 hour daily transcribing session audio notes and formatting clinical evolution charts. Unconstrained language models presented intolerable hallucination risks in regulated patient records. - **Architecture & Seam:** Asynchronous FastAPI microservices combining Whisper speech-to-text with Claude reasoning models. Structured outputs are strictly validated against Pydantic schemas conforming to ABA clinical taxonomy, routed into a side-by-side clinician review queue before database persistence. - **Trade-off:** Sacrificed 1-click automatic publishing in favor of 100% clinician auditability and zero legal liability in medical records. - **Measured Impact:** 75% reduction in manual note charting time; 100% human-verified audit trail with zero unverified hallucinations across dozens of clinics. ### Case 03: Playwright E2E Test Harness as Containment Net for AI Coding - **Context & Business Pain:** Manual QA before releases took 1+ hour, slowing deployment cadence. Furthermore, using AI coding assistants without strict verification risked silent business regressions ("vibe coding"). - **Architecture & Seam:** Built a comprehensive E2E test harness using Playwright, ephemeral Docker Compose database fixtures, pre-seeded role accounts, and strict Page Object Models. Zero retries allowed in CI to enforce zero tolerance for flaky tests. - **Trade-off:** Maintained strict fixture isolation in exchange for an unshakeable safety net. - **Measured Impact:** QA validation cycle cut from 60 minutes to under 10 minutes; AI agents can safely generate and verify pull requests against real end-to-end flows. ### Case 04: Cloudflare R2 Direct Media Storage & Signed URL Security - **Context & Business Pain:** Routing multi-megabyte therapy audio/video recordings through API servers caused memory exhaustion, 504 proxy timeouts on mobile clinic networks, and high egress bandwidth bills. - **Architecture & Seam:** Client-to-cloud direct uploads via Cloudflare R2 pre-signed URLs. Enforced maximum file size limits (20MB) and cryptographic checksums directly inside pre-signed extensionHeaders, bypassing server memory completely. - **Trade-off:** Added client-side direct upload state orchestration in exchange for zero server RAM consumption and zero egress fees. - **Measured Impact:** Zero application server memory overhead for media transfers; $0 bandwidth egress fees; sub-second upload handshakes. ### Case 05: Next.js Production Resiliency & Deployment Skew Mitigation - **Context & Business Pain:** During zero-downtime rolling deployments, active users with open browser tabs triggered Server Actions pointing to stale build hashes, resulting in fatal runtime errors and lost form state. - **Architecture & Seam:** Implemented a client-side error boundary interceptor that detects deployment skew signatures, serializes dirty user inputs into temporary storage, and triggers a seamless state-preserving page reload. Middleware suppresses internal Next.js control-flow exceptions in Sentry. - **Trade-off:** Intercepted framework-level routing errors at runtime rather than forcing hard maintenance windows or user session cutoffs. - **Measured Impact:** Zero user-perceived downtime during active mid-day deployments; 100% elimination of lost user form data across releases; high-SNR Sentry error streams. ### Case 06: Multi-Tenant RBAC & Anti-IDOR Domain Security - **Context & Business Pain:** In a multi-tenant healthcare SaaS, an Insecure Direct Object Reference (IDOR) could expose confidential patient evolutions between competing clinics or unauthorized staff. - **Architecture & Seam:** Layered authorization barriers at the service/BFF level with explicit organization ownership guards. Built visual permission matrix UI on staff forms, prevented duplicate organization memberships, and enforced strict therapist-to-patient assignment checks. - **Trade-off:** Enforced defense-in-depth permission verification on every query rather than relying solely on frontend route protection. - **Measured Impact:** Zero data leakage across multi-tenant boundaries; robust audit trail of clinical permission assignments.