# euron-sudh/ai-video-intelligence-content-moderation-platform architecture

> Architecture diagram of the GitHub repository euron-sudh/ai-video-intelligence-content-moderation-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/euron-sudh/ai-video-intelligence-content-moderation-platform
- Repository: https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform

## Overview

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: [`backend/app/services`](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/app/services) (Domain services), [`frontend/src/app`](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/frontend/src/app) (Next.js app), [`backend/app/ai`](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/app/ai) (AI workflows), [`backend/app/workers`](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/app/workers) (Celery workers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_fe_app["Next.js app<br/>presentation+BFF"]
  node_fe_proxy["API proxy<br/>route proxy"]
  node_fe_state(("Client state<br/>ui state"))
  node_fe_components["UI modules<br/>components"]
end

subgraph group_backend["Backend"]
  node_be_main["ASGI entry<br/>FastAPI app<br/>[main.py]"]
  node_be_router["API routers<br/>HTTP routing<br/>[router.py]"]
  node_be_core{{"Core infra<br/>cross-cutting"}}
  node_be_services["Domain services<br/>business logic"]
  node_be_ai{{"AI workflows<br/>orchestration"}}
  node_be_workers["Celery workers<br/>async jobs"]
  node_be_models[("Data model<br/>SQLAlchemy models")]
  node_be_schemas["Schemas<br/>Pydantic DTOs"]
  node_be_migrations["Migrations<br/>Alembic"]
  node_be_integration{{"External services<br/>integrations"}}
end

subgraph group_infra["Infrastructure"]
  node_aws["AWS stack<br/>cloud infra<br/>[main.tf]"]
  node_tf_modules["Terraform modules<br/>IaC modules"]
  node_docker["Compose runtime<br/>local env<br/>[docker-compose.yml]"]
end

subgraph group_docs["Docs & Automation"]
  node_gha["GitHub Actions<br/>delivery pipeline<br/>[workflows]"]
  node_docs_arch["Architecture docs<br/>documentation<br/>[ARCHITECTURE.md]"]
  node_readme["Repo guide<br/>overview<br/>[README.md]"]
end

node_fe_app -->|"calls same-origin API"| node_fe_proxy
node_fe_app -->|"uses state"| node_fe_state
node_fe_app -->|"renders"| node_fe_components
node_fe_proxy -->|"forwards requests"| node_be_main
node_be_main -->|"mounts"| node_be_router
node_be_router -->|"delegates"| node_be_services
node_be_services -->|"persists"| node_be_models
node_be_services -->|"calls"| node_be_integration
node_be_services -->|"orchestrates"| node_be_ai
node_be_services -->|"enqueues jobs"| node_be_workers
node_be_workers -->|"runs workflows"| node_be_ai
node_be_workers -->|"updates"| node_be_models
node_be_ai -->|"uses model/search"| node_be_integration
node_be_ai -->|"writes artifacts"| node_be_models
node_be_core -->|"supports"| node_be_main
node_be_schemas -->|"contracts"| node_be_router
node_be_schemas -->|"types"| node_be_services
node_be_migrations -->|"evolves"| node_be_models
node_aws -->|"assembles"| node_tf_modules
node_gha -->|"deploys"| node_aws
node_docker -->|"mirrors"| node_be_main
node_docker -->|"runs"| node_be_workers
node_docker -->|"runs"| node_fe_app
node_docs_arch -.->|"describes"| node_be_router
node_readme -.->|"introduces"| node_fe_app

click node_fe_app "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/frontend/src/app"
click node_fe_proxy "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/frontend/src/app/api"
click node_fe_state "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/frontend/src/hooks"
click node_fe_components "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/frontend/src/components"
click node_be_main "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/blob/development/backend/app/main.py"
click node_be_router "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/blob/development/backend/app/api/v1/router.py"
click node_be_core "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/app/core"
click node_be_services "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/app/services"
click node_be_ai "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/app/ai"
click node_be_workers "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/app/workers"
click node_be_models "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/app/models"
click node_be_schemas "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/app/schemas"
click node_be_migrations "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/alembic"
click node_be_integration "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/app/services"
click node_aws "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/blob/development/terraform/main.tf"
click node_tf_modules "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/terraform/modules"
click node_docker "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/blob/development/docker-compose.yml"
click node_gha "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/blob/development/.github/workflows"
click node_docs_arch "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/blob/development/docs/ARCHITECTURE.md"
click node_readme "https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/blob/development/README.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_fe_app,node_fe_proxy,node_fe_state,node_fe_components toneBlue
class node_be_main,node_be_router,node_be_core,node_be_services,node_be_ai,node_be_workers,node_be_models,node_be_schemas,node_be_migrations,node_be_integration toneAmber
class node_aws,node_tf_modules,node_docker toneMint
class node_gha,node_docs_arch,node_readme toneRose
```

## Components

### Frontend

Next.js operator UI and same-origin API proxy layer

- [Next.js app](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/frontend/src/app): presentation+BFF · App Router UI for operators, admins, and public pages · `frontend/src/app`
- [API proxy](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/frontend/src/app/api): route proxy · Same-origin proxy and v1 route handlers for browser traffic · `frontend/src/app/api`
- [Client state](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/frontend/src/hooks): ui state · Query, local stores, sockets, and API helpers · `frontend/src/hooks`
- [UI modules](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/frontend/src/components): components · Shared layout, moderation, live, video, and analytics components · `frontend/src/components`

### Backend

FastAPI system of record plus async AI and worker subsystems

- [ASGI entry](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/blob/development/backend/app/main.py): FastAPI app · Backend application bootstrap and Socket.IO wiring · `backend/app/main.py`
- [API routers](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/blob/development/backend/app/api/v1/router.py): HTTP routing · Versioned domain endpoints for auth, content, billing, live, reports, and governance · `backend/app/api/v1/router.py`
- [Core infra](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/app/core): cross-cutting · Middleware, security, logging, rate limiting, and exceptions · `backend/app/core`
- [Domain services](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/app/services): business logic · Transactional operations coordinating storage, queues, and integrations · `backend/app/services`
- [AI workflows](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/app/ai): orchestration · Agents, chains, graphs, tools, prompts, and shared state · `backend/app/ai`
- [Celery workers](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/app/workers): async jobs · Background task consumers for video, moderation, analytics, reports, streams, and cleanup · `backend/app/workers`
- [Data model](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/app/models): SQLAlchemy models · Persistent domain entities for identity, moderation, media, billing, audits, and support · `backend/app/models`
- [Schemas](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/app/schemas): Pydantic DTOs · Request and response contracts shared across the backend · `backend/app/schemas`
- [Migrations](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/alembic): Alembic · Schema evolution for the relational store · `backend/alembic`
- [External services](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/backend/app/services): integrations · Stripe, SendGrid, Twilio, OpenAI, Pinecone, storage, and realtime dependencies · `backend/app/services`

### Infrastructure

Deployment, cloud resources, and environment automation

- [AWS stack](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/blob/development/terraform/main.tf): cloud infra · VPC, ECS, RDS, Redis, S3, CloudFront, SQS, WAF, and monitoring · `terraform/main.tf`
- [Terraform modules](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/tree/development/terraform/modules): IaC modules · Reusable infrastructure modules for compute, network, storage, cache, and edge · `terraform/modules`
- [Compose runtime](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/blob/development/docker-compose.yml): local env · Local topology for frontend, backend, worker, Postgres, and Redis · `docker-compose.yml`

### Docs & Automation

Repository-level guidance and delivery workflows

- [GitHub Actions](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/blob/development/.github/workflows): delivery pipeline · CI, staging, production deploy, and rollback workflows · `.github/workflows`
- [Architecture docs](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/blob/development/docs/ARCHITECTURE.md): documentation · Reference material for architecture, schema, deployment, and product design · `docs/ARCHITECTURE.md`
- [Repo guide](https://github.com/euron-sudh/ai-video-intelligence-content-moderation-platform/blob/development/README.md): overview · Top-level project orientation and setup guidance · `README.md`

## Connections

- 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
