How euron-sudh/ai-video-intelligence-content-moderation-platform works
1. VidShield AI is a two-tier product application with a strong async backend. The core split is a Next.js 14 frontend for operators/admins and a FastAPI backend that owns business logic, persistence, AI workflows, and realtime coordination. The repo also includes background workers, IaC, and deployment automation, so the architecture is closer to a platform than a simple API app.
2. The frontend is the presentation and BFF layer. It uses Next.js App Router with routes for dashboard, moderation, videos, live streams, reports, billing, users, and docs/marketing pages. Client state is split across TanStack Query for server data, Zustand stores for app state, and socket/websocket hooks for live updates. The frontend/src/app/api/v1/* routes and [...proxy] handler act as a proxy/rewrite layer so browser requests can stay same-origin in production.
3. The backend is the system of record. backend/app/main.py exposes FastAPI as an ASGI app and also wraps Socket.IO for realtime features. Routing is organized by domain under backend/app/api/v1, with boundaries for auth, users, videos, moderation, live, reports, analytics, billing, notifications, tickets, policies, webhooks, and audit/agent-audit. Shared backend concerns like middleware, logging, security, rate limiting, and exception handling live in backend/app/core.
4. Business logic is intentionally separated from HTTP handlers. API routers delegate into backend/app/services, which encapsulate operations such as auth, moderation, video processing, reporting, billing, storage, notifications, streaming, and analytics. This is the main boundary between transport and domain logic, and it’s where most database, Redis, S3, and external API interactions are coordinated.
5. AI capabilities are isolated in backend/app/ai. That package is organized into agents, chains, graphs, tools, prompts, schemas, and state. It supports content analysis, metadata extraction, scene classification, live moderation, report generation, safety checks, summarization, and similarity search. The graph-based workflows indicate multi-step orchestration rather than single-shot model calls.
6. The asynchronous job layer is Celery-based and domain-specific. Workers under backend/app/workers handle video tasks, moderation tasks, analytics tasks, report generation, stream processing, notifications, and cleanup. The backend enqueues work to Redis, and the Celery workers consume it to perform heavier or delayed processing without blocking the API.
7. Persistence is split by workload. PostgreSQL is the primary relational store for users, videos, moderation records, reports, tickets, notifications, billing, policies, audits, and related entities, managed via SQLAlchemy and Alembic migrations. Redis serves as the queue/broker and also supports caching, rate-limiting, and token/session-style workflows. S3 stores large artifacts such as videos, frames, generated PDFs, and other media outputs.
8. External integrations are first-class domain dependencies, not incidental add-ons. Stripe powers billing and webhooks, SendGrid handles email delivery, Twilio supports WhatsApp/SMS-style notifications, OpenAI is used for model-backed analysis and moderation, and Pinecone provides vector search for retrieval/similarity features. These integrations are called from backend services or workers depending on latency and reliability requirements.
9. The live-video and realtime path is distinct from the recorded-video path. Live-related routes and services handle stream creation, monitoring, stop actions, and moderation events, with websocket/Socket.IO support for live updates back to the UI. Recorded media flows through upload, processing, moderation, report generation, and analytics, which are more batch-oriented and worker-driven.
10. The data model reflects the product surfaces. Migrations and models cover users/access control, API keys, audits, agent audits, alerts, analytics, billing, moderation, newsletters, notifications, password resets, policies, reports, support tickets, videos, and webhooks. This makes the backend architecture highly domain-driven, with separate tables and schemas per feature area rather than a single generic content model.
11. Security and governance are explicit subsystems. The backend includes JWT auth, password hashing, access control, audit logs, API keys, password reset tokens, and rate limiting. On the product side, moderation policies and auditability are core concepts, which matters for how the system should be diagrammed: moderation is not a single endpoint, but a workflow with policy, review, logging, and notifications around it.
12. The deployment model is AWS-native. Terraform provisions VPC, ECS, RDS PostgreSQL, ElastiCache Redis, S3, CloudFront, SQS, WAF, and monitoring. Production appears to run as separate ECS services for frontend, API, and worker, with CloudFront in front of browser traffic and the frontend proxying API calls to an internal upstream. GitHub Actions builds and deploys images, updates ECS task definitions, and can invalidate CloudFront.
13. Observability, testing, and local development are built into the repository structure. Backend tests cover AI, API, services, workers, core utilities, and models; frontend tests cover components, hooks, and API utilities. Docker Compose mirrors the runtime topology locally with Postgres, Redis, backend, worker, and frontend, so the same major boundaries exist both in local and cloud deployments.
Main entry points: services Domain services · app Next.js app · ai AI workflows · workers Celery workers
Components 20
Frontend
Next.js operator UI and same-origin API proxy layer
- Next.js app · App Router UI for operators, admins, and public pages
frontend/src/app - API proxy · Same-origin proxy and v1 route handlers for browser traffic
frontend/src/app/api - Client state · Query, local stores, sockets, and API helpers
frontend/src/hooks - UI modules · Shared layout, moderation, live, video, and analytics components
frontend/src/components
Backend
FastAPI system of record plus async AI and worker subsystems
- ASGI entry · Backend application bootstrap and Socket.IO wiring
backend/app/main.py - API routers · Versioned domain endpoints for auth, content, billing, live, reports, and governance
backend/app/api/v1/router.py - Core infra · Middleware, security, logging, rate limiting, and exceptions
backend/app/core - Domain services · Transactional operations coordinating storage, queues, and integrations
backend/app/services - AI workflows · Agents, chains, graphs, tools, prompts, and shared state
backend/app/ai - Celery workers · Background task consumers for video, moderation, analytics, reports, streams, and cleanup
backend/app/workers - Data model · Persistent domain entities for identity, moderation, media, billing, audits, and support
backend/app/models - Schemas · Request and response contracts shared across the backend
backend/app/schemas - Migrations · Schema evolution for the relational store
backend/alembic - External services · Stripe, SendGrid, Twilio, OpenAI, Pinecone, storage, and realtime dependencies
backend/app/services
Infrastructure
Deployment, cloud resources, and environment automation
- AWS stack · VPC, ECS, RDS, Redis, S3, CloudFront, SQS, WAF, and monitoring
terraform/main.tf - Terraform modules · Reusable infrastructure modules for compute, network, storage, cache, and edge
terraform/modules - Compose runtime · Local topology for frontend, backend, worker, Postgres, and Redis
docker-compose.yml
Docs & Automation
Repository-level guidance and delivery workflows
- GitHub Actions · CI, staging, production deploy, and rollback workflows
.github/workflows - Architecture docs · Reference material for architecture, schema, deployment, and product design
docs/ARCHITECTURE.md - Repo guide · Top-level project orientation and setup guidance
README.md
Connections 25
- Next.js app → API proxy: calls same-origin API · Browser pages use route handlers and proxy rewrites to reach backend endpoints
- Next.js app → Client state: uses state · UI relies on query hooks, stores, and websocket helpers for live data
- Next.js app → UI modules: renders · Pages compose shared layout and domain components
- API proxy → ASGI entry: forwards requests · Frontend API routes proxy to the backend ASGI app
- ASGI entry → API routers: mounts · Application bootstrap exposes the versioned HTTP API
- API routers → Domain services: delegates · Routers hand off domain work to service layer
- Domain services → Data model: persists · Services read and write domain entities
- Domain services → External services: calls · Domain services coordinate external APIs and infrastructure clients
- Domain services → AI workflows: orchestrates · Services invoke AI pipelines for analysis, moderation, and reports
- Domain services → Celery workers: enqueues jobs · Heavy or delayed tasks are pushed to background workers
- Celery workers → AI workflows: runs workflows · Workers execute multi-step analysis and moderation jobs
- Celery workers → Data model: updates · Async tasks materialize results into persistent records
- AI workflows → External services: uses model/search · AI workflows depend on OpenAI and vector retrieval services
- AI workflows → Data model: writes artifacts · Agent audits, analysis outputs, and workflow state are stored
- Core infra → ASGI entry: supports · Shared middleware, logging, security, and rate limiting underpin the app
- Schemas → API routers: contracts · Endpoints validate and serialize through typed DTOs
- Schemas → Domain services: types · Services share domain request and response shapes
- Migrations → Data model: evolves · Alembic migrations track the relational schema behind the models
- AWS stack → Terraform modules: assembles · Root Terraform composes the infrastructure modules
- GitHub Actions → AWS stack: deploys · CI/CD builds and promotes the platform into AWS environments
- Compose runtime → ASGI entry: mirrors · Local compose reproduces the backend runtime topology
- Compose runtime → Celery workers: runs · Compose includes worker processes for async jobs
- Compose runtime → Next.js app: runs · Local compose includes the frontend runtime
- Architecture docs → API routers: describes · Architecture docs capture service boundaries and API structure
- Repo guide → Next.js app: introduces · Repository guide points to the frontend application and setup