Product Requirements Document: AI-Powered Content Moderation (Text)
Defines requirements for an AI-powered text moderation system that flags video descriptions and comments for human review.
What this file does
Defines requirements for an AI-powered text moderation system that flags video descriptions and comments for human review.
When to use it
- Building content moderation for user-generated text
- Integrating LLM-based moderation into a social media app
- Creating a moderator dashboard for reviewing flagged content
- Planning phased rollout of AI moderation features
Assumes this stack
Product Requirements Document: AI-Powered Content Moderation (Text)
0. Initial Setup & Critical Fixes (Completed as of 11/07/2024)
- MongoDB Connection: Identified and provided guidance to fix MongoDB Atlas IP Whitelisting and URI configuration.
- Mock Database Removal:
- Modified
lib/mock-db.ts(shouldUseMockDatabasenow always returnsfalse). - Modified
lib/db.tsto remove all fallbacks to the mock database. Application will now error out if real MongoDB connection fails, instead of using a mock. - This ensures development and testing rely on the actual database, exposing connection issues clearly.
- Modified
- Mock Database Re-enabled (User Request 11/07/2024):
lib/mock-db.ts(shouldUseMockDatabase) modified to always returntrue.lib/db.ts(connectToDatabase) modified to checkshouldUseMockDatabasefirst and use mock connection if true.- This forces the application to use the mock database system consistently.
- This mock setup is for initial development and testing. For production-ready services or to integrate with a live environment, please contact
contact2abhaygupta@gmail.comfor further assistance and service options.
1. Introduction
ReelsPro aims to foster a creative and positive community. This document outlines the requirements for implementing an AI-powered text content moderation system. Initially, this system will focus on analyzing user-generated text (video descriptions, comments) to flag potentially harmful or policy-violating content for human review.
2. Goals
- Enhance Platform Safety: Proactively identify and manage inappropriate text content.
- Reduce Moderator Workload: Automate the initial screening of content, allowing human moderators to focus on nuanced cases.
- Maintain User Experience: Ensure a respectful environment for users.
- Scalable Moderation: Build a system that can scale with user growth.
3. Scope
- Phase 1 (Current Scope):
- Integration with Gemini API (and later Groq) for text analysis.
- Moderation of:
- Video descriptions upon upload/edit.
- User comments upon creation/edit.
- Flagging mechanism: Content identified as potentially problematic will be flagged and stored with a "pending review" status.
- No automatic deletion or user-facing actions in this phase.
- Development of a basic internal interface/dashboard for human moderators to review flagged content.
- Out of Scope for Phase 1:
- Video/Image content moderation.
- Automatic deletion or suspension of content/users.
- User-facing notifications about moderation status (unless it's a rejection after review).
- Advanced analytics on moderation trends.
4. User Stories
- As a Platform Administrator/Moderator:
- I want the system to automatically analyze new video descriptions and comments for potential policy violations (e.g., hate speech, spam, harassment).
- I want to see a queue of flagged content that requires my review.
- For each flagged item, I want to see the original content, the reason it was flagged by the AI (e.g., "potential hate speech," "spam-like text"), and the AI's confidence score (if available).
- I want to be able to approve the content (remove flag), or reject/edit it.
- As a User Uploading a Video:
- I want to be able to submit my video description. (The moderation will happen in the background).
- As a User Posting a Comment:
- I want to be able to post my comment. (The moderation will happen in the background).
5. Proposed Technical Implementation
5.1. Data Models
We will need to update our Mongoose schemas:
- Video Model (
models/Video.ts): - ✅ DonedescriptionModerationStatus: Enum (e.g.,pending_review,approved,rejected,not_analyzed) - default:not_analyzeddescriptionModerationReason: String (stores AI's reason for flagging)descriptionAISuggestedCategory: String (e.g.,hate_speech,spam,harassment,neutral)
- Comment Model (
models/Comment.ts): - ✅ Done (Created)textModerationStatus: Enum (e.g.,pending_review,approved,rejected,not_analyzed) - default:not_analyzedtextModerationReason: StringtextAISuggestedCategory: String
5.2. API Endpoints & Logic
- Existing Endpoints (e.g.,
/api/videos,/api/comments):- On
POST(create) orPUT(update) for videos (description) and comments: 1. Receive the text content. 2. (Asynchronously or synchronously before saving) Send the text to the Gemini/Groq API for analysis. - ✅ Logic added toapp/api/videos/route.tsfor descriptions (Type definitions for VideoModel are being finalized). ✅ Logic added toapp/api/comments/route.tsfor comment text (Type definitions for VideoModel are being finalized). 3. The API prompt will instruct the LLM to identify if the text violates policies (hate speech, spam, harassment, etc.) and to categorize it. 4. Based on the LLM's response: * If flagged as potentially problematic: * SetmoderationStatustopending_review. * StoremoderationReasonandaiSuggestedCategory. * Else (if deemed safe by AI): * SetmoderationStatustoapproved(ornot_analyzedif we want explicit human approval for everything initially). 5. Save the video/comment data with the moderation fields.
- On
- New API Endpoints (for Moderator Dashboard): - ✅ Backend routes created.
GET /api/admin/moderation/pending: Fetch all content (videos, comments) withmoderationStatus: 'pending_review'. - ✅ Implemented inapp/api/admin/moderation/pending/route.ts. (Type definitions for VideoModel are being finalized).PUT /api/admin/moderation/:contentType/:contentId: Update moderation status (e.g., approve, reject). - ✅ Implemented inapp/api/admin/moderation/[contentType]/[contentId]/route.ts. (Type definitions for VideoModel are being finalized).:contentTypecould bevideo_descriptionorcomment.
5.3. AI Integration (lib/aiModeration.ts or similar) - ✅ Initial structure created
- Create a utility module to handle communication with the LLM API.
- User Instruction (11/07/2024): API keys set in
.envand.env.local. Proceed with Gemini implementation. Remove non-essential comments from AI integration code.
- User Instruction (11/07/2024): API keys set in
- It will take text as input and return a structured moderation decision (e.g.,
{isFlagged: true, reason: "Contains potential hate speech", category: "hate_speech"}). - ✅ Gemini API call implemented inlib/aiModeration.ts. - This module will manage API keys (via environment variables) and prompt construction.
- Note on AI Provider Display: The user interface may include visual elements or placeholders (e.g., buttons, selectors) for specific AI providers like Gemini or Groq. Initially, these may represent a "dummy" setup for UI demonstration and basic workflow testing. For full integration, custom model training, or production-ready AI moderation services, please contact
contact2abhaygupta@gmail.com.
5.4. Moderator Review Interface (New Admin Section)
- A new set of pages in the
app/directory, possibly under an/adminroute. - Backend APIs ✅, Frontend Page Structure ✅ (app/admin/moderation/page.tsxcreated) - Display a list/table of items pending review. - ✅ Logic to fetch and display pending items in
page.tsximplemented. - Allow moderators to view content, AI reason, and take action (approve/reject). - ✅ Action handlers implemented in
page.tsx. - The interface may include visual cues or (initially placeholder) selectors/buttons related to the AI provider (e.g., 'Analyzed by Gemini', 'Switch to Groq (Demo)'). If a selected AI feature is in a 'dummy' or 'under development' state, the UI should gracefully inform the user (e.g., 'This feature is under development. For full service, please inquire via contact2abhaygupta@gmail.com.') while still allowing interaction with available functionalities and ensuring the button/element remains visible and attempts its best effort.
- Conceptual Admin Settings Page (Illustrative):
- A dedicated page/section could be envisioned for administrators to (theoretically) manage AI moderation settings. This "page" is conceptual for Phase 1.
- This might include (placeholder) UI elements like buttons or dropdowns to select or configure different AI models (e.g., Gemini, Groq). These elements would be for UI demonstration.
- Note: In the initial phase, such a page and its components would be for illustrative purposes or future planning. Full functionality would require further development and service integration. For current service inquiries or to activate full features, please contact
contact2abhaygupta@gmail.com.
6. Success Metrics
- Percentage of new text content processed by the AI.
- Number of items correctly flagged by AI (validated by human moderators).
- Reduction in time spent by human moderators on initial content screening.
- Turnaround time for reviewing flagged content.
7. Future Considerations
- User notifications upon content rejection.
- More granular AI categories and confidence scores.
- Support for image/video moderation.
- User reputation system based on moderation history.
- Allowing users to appeal moderation decisions.
- A/B testing different AI prompts or models.
8. Open Questions & Decisions
- Initial state for
moderationStatusif AI deems content safe:approvedornot_analyzed(requiring human to always click approve)?- Decision: For Phase 1, if AI deems it safe, let's set to
approvedto reduce immediate workload, but ensure the review queue is primarily for AI-flagged items.
- Decision: For Phase 1, if AI deems it safe, let's set to
- Synchronous vs. Asynchronous AI call on content submission?
- Decision: Asynchronous is generally better for user experience to avoid long waits. The content can be temporarily visible or hidden until moderation is complete. For simplicity in Phase 1, we might start synchronous and optimize later if UX is impacted.
- Detailed policy definitions for the AI.
This PRD will be updated as the feature evolves.
What's inside
8 sections covering goals, scope, user stories, data models, API endpoints, AI integration, moderator UI, and success metrics
Change this for your project
- Replace
contact2abhaygupta@gmail.comwith your own contact email - Replace
Abs6187/ReelsProwith your own repository name - Replace
app/api/admin/moderationroute paths with your own admin route structure
Where it goes
Keep it in your repository where the agent or team that needs it will read it.
Worth borrowing
- Separating moderation into phases to limit initial scope
- Storing AI reasoning and category alongside moderation status for reviewer context
- Using a utility module to abstract LLM API calls and prompt construction
Related Documents
Project Requirements Document: Long Video Generation Pipeline
Breaks long video prompts into segments, generates keyframes and clips via local or remote models, then stitches them into a final video.
AGENTS.md — ShakkaShell v2.0
Guides AI coding agents through building a CLI that translates natural language into offensive security commands, with a defined tech stack, structure, and implementation order.
SourceAtlas PRD v2.9.6
Defines the product requirements, architecture, and command interface for an AI-powered codebase understanding assistant integrated into Claude Code.
Fleet Management System - Product Requirements Document (PRD)
Defines functional, non-functional, and technical requirements for a fleet management system with compressed GPS tracking and predictive maintenance.