v2

Content Domain

Purpose

The Content domain manages the entire lifecycle of user-generated posts, media, polls, comments, and taxonomies (niches, categories, tags). It handles upload, processing, moderation, publishing, and archival workflows.

Core Responsibilities

  • Post Management — CRUD operations for posts with rich text, media attachments, and polls
  • Media Processing — Automated variant generation for images, videos, and audio
  • AI Moderation — Pre-screening content before publication
  • Taxonomy — Niches, categories, and tags for discovery and filtering
  • Polls & Voting — Multi-option polls with real-time vote tracking
  • Comments — Threaded discussions on posts
  • Collections — Curated groups of posts

Owned Entities

Entity Purpose
Post Creator-published content with media, polls, tags, and access rules
Media Image, video, or audio files attached to posts
Poll Multi-option voting attached to posts
PollOption Individual choices in a poll
PollVote User vote record
Comment User comment on a post
Niche Top-level content category (e.g., Fitness, Tech)
Category Sub-category under a niche (e.g., Yoga under Fitness)
Tag User-generated labels for cross-cutting topics
Collection Curated sets of posts by creators

Key Workflows

Post Creation & Publishing

┌──────────────┐
│ Create Draft │
└──────┬───────┘
       │
       ▼
┌──────────────┐
│ Upload Media │ ← ImagePostProcessor, VideoPostProcessor, AudioPostProcessor
└──────┬───────┘
       │
       ▼
┌──────────────┐
│ Add Metadata │ ← Tags, niche, category, access rules
└──────┬───────┘
       │
       ▼
┌──────────────┐
│   Publish    │
└──────┬───────┘
       │
       ├──────────→ If moderation_mode = "manual_prescreen":
       │            Post → status=pending_moderation
       │            Admin reviews via Filament
       │
       ├──────────→ If moderation_mode = "ai_prescreen":
       │            PostAiReviewJob dispatched
       │            AI returns: allow/flag/block
       │            Allow → published, Flag → pending_moderation, Block → rejected
       │
       └──────────→ If moderation_mode = "none":
                    Post → status=published immediately

Media Processing Pipeline

Upload Media (via POST /v1/posts/media)
  │
  ├─→ Store original file (S3 or local)
  │
  ├─→ Create Media record (status=pending)
  │
  ├─→ Dispatch ProcessImageMediaJob / ProcessVideoMediaJob / ProcessAudioMediaJob
  │
  └─→ Processor runs:
       1. Validate source
       2. Inspect dimensions/duration
       3. Build variant manifest (thumb, small, medium, large)
       4. Update Media.metadata & Media.variants
       5. Set status=ready

Public Contracts

Contract Purpose
IPostProcessor Media processing interface (image, video, audio)
IProcessorExecutionLogger Logs processing steps for observability
PostMediaProcessingRunner Orchestrates processor execution
PostAiReviewRunner Dispatches and manages AI moderation
ContentProcessingSettingsService Platform-wide toggle for processing

Events

Event Fired When
PostPublished Post status changes to published
PostMediaUploaded Media file stored, processing queued
PostMediaProcessed Media variant generation complete
PostModerated Admin or AI moderation decision made
PollVoteCast User votes on a poll
CommentPosted User comments on a post

Key Invariants

  • One Processing Status — Media can only be in one status at a time: pending, processing, ready, failed
  • Moderation State Transitionspending_moderationpublished or rejected (no reversals without admin action)
  • Poll Vote Uniqueness — One vote per user per poll option (enforced by unique constraint)
  • Media Ownership — Media can only be attached to one post (enforced by mediable_type/mediable_id polymorphic relation)

Dependencies

  • Upstream: Identity (creator authentication), Moderation (AI review)
  • Downstream: Discovery (ranking signals), Access (gating), Social (likes, shares)

Further Reading

Configuration

Setting Default Purpose
content.post_processing_enabled true Master toggle for media processing
content.moderation_mode ai_prescreen none, manual_prescreen, ai_prescreen
content.ai_review_provider openai Which AI service to use for moderation
content.ai_review_model gpt-4o-mini Model version
content.ai_review_threshold 0.7 Confidence score to auto-allow (0.0-1.0)

Testing

  • Unit Tests: tests/Unit/Content/
  • Feature Tests: tests/Feature/Content/
  • Integration Tests: tests/Feature/Content/Infrastructure/ (requires MongoDB for processor logging)