sidon.dev

llm-trade-audit.md · sidon.dev

LLM-powered trade audit platform: from MVP to production

Part of: Senior Developer · Backend & AI, Petrobras

Web application for internal audit. The auditor uploads a history of commercial conversations (tens of thousands of messages per analysis). The system removes noise and uses an LLM to identify and classify offers and closed deals. It then produces a dashboard and a consolidated summary per counterparty.

I owned both the backend and the frontend. I led the move from an MVP (a notebook, Pandas, and a prototype frontend that was never meant for production) to a production codebase:

  • Layered architecture (web → services → domain ← infra) with dependency injection through Protocol, src layout and uv.
  • Server-side rendered frontend with FastAPI + Jinja2, with no Node.js or build step: upload, a dashboard with metrics and filters, run history, side-by-side comparison of runs, and prompt management.
  • Decisions recorded with alternatives and trade-offs: Polars instead of Pandas, Jinja2 server-side rendering instead of a second SPA repository, and Nginx + Uvicorn in a single container, with a debt item recorded for moving to a sidecar.
  • Parallel LLM calls with retry/backoff, plus a documented analysis of the LLM gateway’s latency and rate limits.
  • DocumentDB persistence with graceful degradation, immutable prompt versioning and side-by-side comparison of runs.
  • A privacy invariant (message content is never persisted) enforced by an automated test.
  • More than 250 automated tests, a central technical debt register, and an architecture concepts guide for the team.
  • Python 3.14
  • FastAPI
  • Jinja2
  • Polars
  • LLM via LiteLLM
  • DocumentDB
  • Nginx
  • AWS ECS