Case study 08 · Backend · multimodal AI

Hold,don't guess

A real-time moderation service for text, images, audio and video. Each kind of content goes through its own pipeline, one decision engine turns scores into BLOCK, REVIEW or ALLOW, and every call is logged. When something fails, content waits for a human instead of slipping through.

DeployedFastAPI · async · WebSockets

NameThe repo calls the app AntiGravity AI. It has a dashboard, a test console, a human review queue and a policy panel.

4Content pipelines
3Verdicts
0Auto-approvals on error
7Safety principles
Data flow · how a record moves

Upload to audited decision

Content is routed by type into its own pipeline. Every pipeline ends in the same risk score and the same audit trail. Click a stage to read what happens there.

01 · Architecture

Follow a request through

Pick a content type to send a packet through the system. Audio is transcribed and then reuses the text pipeline. Video is split into keyframes and an audio track, which reuse the image and audio paths.

Endpoints/api/v1/moderate/ text, image, audio and video, each async, with results pushed to the dashboard over a WebSocket.

02 · Decision engine

Two thresholds, three outcomes

Every pipeline ends in a risk score from 0 to 1. At 0.80 and above, content is blocked. Between 0.50 and 0.80 it goes to the human review queue. Below 0.50 it's allowed. Try it, then break the pipeline.

ALLOWscore below 0.50

Fail-safeAn error never becomes an ALLOW. It becomes a REVIEW, and the audit log records why.

03 · Pipelines

Cheap checks first

TTextAho-Corasick keyword pass catches known terms in one scan, then a transformer toxicity classifier scores the rest.
IImagePIL preprocessing, then Google Cloud Vision SafeSearch.
AAudioWhisper speech-to-text, then the text pipeline on the transcript.
VVideoKeyframes on scene change plus the audio track, each sent down the image and audio paths.
→AuditEvery decision written to the database (SQLAlchemy 2 async) and pushed live to the dashboard.

PolicyThresholds and rules are editable through a config API, so moderators can tune without a deploy.

04 · Latency budget

Design targets, per modality

The p95 latency each pipeline is designed to stay under. These are the targets in the README, not benchmark results.

Text · per item200ms
Image · per item500ms
Video · per keyframe1s
Audio · per 10s chunk2s

Target · p95 · not measured here

FastAPIUvicornSQLAlchemy 2Pydantic v2WebSocketsWhisperCloud VisionDockerVercelpytest

TestsSeparate test modules for each pipeline, the decision engine, the rule engine and the config API.