How anujtambake936-ctrl/azure_video_compliance_analyzer works
Purpose and Entry Points
Video Compliance Analyzer audits a submitted YouTube URL against brand/regulatory guidance. It extracts video evidence, retrieves relevant rules, and returns a structured PASS/FAIL compliance report with risk score and violations.
Runtime entry points:
• CLI local audit: main.py
• FastAPI service (GET /health, POST /audit): backend/src/api/server.py
• One-time knowledge-base ingestion: backend/scripts/index_documents.py
API and Request Boundary
backend/src/api/server.py owns HTTP validation, audit invocation, and response delivery. It is the external boundary for clients: callers submit a YouTube URL and receive a session-scoped report. Telemetry initialization is separated in backend/src/api/telemetry.py, allowing API request traces and failures to be exported without embedding observability logic in workflow nodes.
Workflow Orchestration
The audit is a LangGraph StateGraph defined in backend/src/graph/workflow.py. It coordinates a linear two-stage DAG:
1. video indexing/evidence extraction;
2. compliance auditing/report generation.
Shared execution context is formalized by backend/src/graph/state.py as VideoAuditState, carrying the URL/session identity, extracted content, retrieved rules, report fields, and accumulated errors across node boundaries.
Video Evidence Extraction
The first graph stage is implemented in backend/src/graph/nodes.py and delegates Azure Video Indexer integration to backend/src/services/video_indexer.py. The service boundary encapsulates downloading the YouTube asset with yt-dlp and submitting/reading analysis from Azure Video Indexer. Its output—transcript plus on-screen OCR text—is the evidence passed to the auditor rather than exposing video-provider mechanics to graph orchestration.
Retrieval and AI Audit
The auditor node in backend/src/graph/nodes.py uses Azure OpenAI embeddings and Azure AI Search vector retrieval to find compliance guidance relevant to extracted video evidence. It then calls an Azure OpenAI chat deployment to generate the structured audit: status, risk score, summary, violations, cited/retrieved rules, and final narrative. Azure AI Search is therefore the policy knowledge boundary; the LLM consumes retrieved rule context rather than relying only on model knowledge.
Knowledge-Base Ingestion
Source regulations and ad guidance reside in backend/data/1001a-influencer-guide-508_1.pdf and backend/data/youtube-ad-specs.pdf. backend/scripts/index_documents.py is the offline ingestion path that chunks these documents, embeds them with Azure OpenAI, and populates the Azure AI Search index. Re-running it after adding PDFs refreshes/extends the corpus used by live audits.
Infrastructure and Observability
The system is Python-based, with dependencies managed by pyproject.toml and uv.lock. Required managed services are Azure OpenAI (chat and embeddings), Azure AI Search, and Azure Video Indexer; Azure credentials/endpoints are environment-driven via .env.example. Optional Azure Monitor/Application Insights instrumentation is wired through backend/src/api/telemetry.py; LangSmith traces LangGraph executions when configured.
Main entry points: workflow.py Audit StateGraph · nodes.py Generate compliance report · index_documents.py Document indexer · video_indexer.py Video Indexer service
Components 17
Entry Points
- Local audit CLI
main.py - FastAPI audit API · Serves health checks and URL audit requests.
backend/src/api/server.py
Audit Workflow
- VideoAuditState · Carries session, evidence, rules, report fields, and errors.
backend/src/graph/state.py - Audit StateGraph · Runs evidence extraction followed by compliance auditing.
backend/src/graph/workflow.py - Index video evidence
backend/src/graph/nodes.py - Generate compliance report
backend/src/graph/nodes.py - Video Indexer service · Downloads YouTube media and obtains transcript and OCR evidence.
backend/src/services/video_indexer.py
Knowledge Pipeline
- Document indexer · Chunks PDFs, embeds them, and refreshes the policy index.
backend/scripts/index_documents.py - Influencer guidance
backend/data/1001a-influencer-guide-508_1.pdf - YouTube ad specs
backend/data/youtube-ad-specs.pdf
Managed Services
- Azure Video Indexer
- Azure OpenAI · Embeds corpus/query content and produces the structured audit.
- Azure AI Search · Retrieves relevant compliance guidance.
Observability
- API telemetry
backend/src/api/telemetry.py - Azure Monitor / App Insights
- LangSmith
Other components
- YouTube video URL
Connections 19
- Local audit CLI → Audit StateGraph: starts audit
- FastAPI audit API → Audit StateGraph: validates URL and invokes
- FastAPI audit API → API telemetry: initializes
- API telemetry → Azure Monitor / App Insights: exports API telemetry
- Audit StateGraph → VideoAuditState: uses
- Audit StateGraph → Index video evidence: stage 1
- Index video evidence → Video Indexer service: extracts evidence
- Video Indexer service → YouTube video URL: downloads
- Video Indexer service → Azure Video Indexer: submits and reads analysis
- Index video evidence → Generate compliance report: transcript and OCR
- Audit StateGraph → Generate compliance report: stage 2
- Generate compliance report → Azure OpenAI: embeds evidence and generates report
- Generate compliance report → Azure AI Search: retrieves relevant rules
- Influencer guidance → Document indexer: source
- YouTube ad specs → Document indexer: source
- Document indexer → Azure OpenAI: creates embeddings
- Document indexer → Azure AI Search: populates index
- Audit StateGraph → LangSmith: traces when configured
- Audit StateGraph → FastAPI audit API: session-scoped report