Skip to main content
Normalized for Mintlify from knowledge-base/aiconnected-apps-and-modules/modules/aiConnected-paper/paper-developer-prd.mdx.

Content Strategist AI

Developer PRD (Product Requirements Document)

Version: 2.0
Last Updated: January 2, 2026
Target Platform: Dokploy on DigitalOcean
Primary Developer Tool: Claude Code
Estimated Build Time: 1 Weekend (Focused)

Table of Contents

  1. Project Overview
  2. Technology Stack
  3. System Architecture
  4. Database Design
  5. Authentication & Authorization
  6. API Design
  7. Content Generation Pipeline
  8. PDF Generation System
  9. Distribution System
  10. File Storage System
  11. White-Label System
  12. CSV Import System
  13. Scheduled Tasks
  14. WebSocket Real-Time Updates
  15. Error Handling
  16. Rate Limiting
  17. Logging & Monitoring
  18. Security Considerations
  19. Environment Configuration
  20. Deployment
  21. Testing Requirements

1. Project Overview

1.1 Purpose

Content Strategist AI is a white-label SaaS platform that generates professional thought leadership content for marketing agencies and their clients. The platform produces executive-quality PDF documents with original research, statistics, data visualizations, and professional design.

1.2 Key Differentiators

1.3 User Types and Descriptions

1.4 Business Rules

Seat Limits

  • Agencies cannot exceed their plan’s seat (client) limit
  • Attempting to add a client beyond the limit returns an error
  • Deactivated clients do not count toward the limit
  • Reactivating a client checks the limit before allowing

Template Access

  • Pro plans: Limited to 5 templates (assigned by Super Admin)
  • Enterprise plans: Access to all templates
  • New templates can be published by Super Admin
  • Agencies cannot access templates not assigned to them

API Usage

  • Pro plans: BYOK (Bring Your Own Key) - agency provides their own Anthropic/Freepik keys
  • Enterprise plans: Included credits ($1,000/month worth)
  • Usage is tracked per document generation
  • Enterprise agencies receive warnings at 80% usage

Document Retention

  • All documents expire after 3 years from creation
  • Expired documents are soft-deleted first, then hard-deleted after 30 days
  • Agencies can export their data before expiration
  • PDFs are removed from storage when documents are hard-deleted

Custom Domains

  • Only available on Enterprise plans
  • Requires DNS verification (TXT record)
  • SSL certificates auto-provisioned via Let’s Encrypt
  • One custom domain per agency

Image Upload

  • Client-uploaded cover images only available on Enterprise plans
  • Pro plans use Freepik stock images only
  • Uploaded images stored for document retention period
  • Maximum image size: 10MB
  • Supported formats: JPG, PNG, WebP

2. Technology Stack

2.1 Core Technologies

2.2 External Services

2.3 Complete Python Dependencies


3. System Architecture

3.1 High-Level Architecture Diagram

3.2 Directory Structure

3.3 Request Flow (Detailed)


4. Database Design

4.1 Entity Relationship Diagram

4.2 Complete Schema Definitions

4.2.1 Plans Table

4.2.2 Agencies Table

4.2.3 Users Table

4.2.4 Clients Table

4.2.5 Templates Table

4.2.6 Agency Templates Junction Table

4.2.7 Documents Table

4.2.8 Scheduled Content Table

4.2.9 Generation Jobs Table

4.2.10 API Keys Table

4.2.11 Audit Logs Table

4.3 Database Functions and Triggers

4.3.1 Auto-Update Timestamp Trigger

4.3.2 Seat Limit Enforcement Trigger

4.3.3 Client Statistics Update Trigger

4.3.4 Generate Slug Function


5. Authentication & Authorization

5.1 Authentication Overview

The system uses JWT (JSON Web Tokens) for stateless authentication with the following characteristics:
  • Access Tokens: Short-lived (15 minutes), used for API requests
  • Refresh Tokens: Long-lived (7 days), stored in HTTP-only cookies
  • API Keys: For programmatic access, hashed in database

5.2 JWT Token Specifications

5.2.1 Access Token Structure

5.2.2 Refresh Token Structure

5.2.3 Token Configuration

5.3 Authentication Flow Diagrams

5.3.1 Login Flow

5.3.2 Token Refresh Flow

5.3.3 API Key Authentication Flow

5.4 Authorization (RBAC)

5.4.1 Permission Definitions

5.4.2 Permission Checking Implementation

5.4.3 Resource-Level Access Control


6. API Design

6.1 API Overview

Base URL Structure

Common Headers

Response Format

6.2 Authentication Endpoints

POST /api/v1/auth/login

Login with email and password. Request:
Response (200 OK):
Set-Cookie Header:
Error Responses:
  • 401 Unauthorized: Invalid credentials
  • 403 Forbidden: Account locked or inactive
  • 422 Unprocessable Entity: Invalid request format

POST /api/v1/auth/refresh

Refresh access token using refresh token cookie. Request: (no body, uses cookie) Response (200 OK):

POST /api/v1/auth/logout

Logout and invalidate tokens. Response (200 OK):
Set-Cookie Header:

GET /api/v1/auth/me

Get current user information. Response (200 OK):

POST /api/v1/auth/password/forgot

Request password reset email. Request:
Response (200 OK):

POST /api/v1/auth/password/reset

Reset password with token. Request:
Response (200 OK):

6.3 Client Management Endpoints

GET /api/v1/clients

List all clients for the agency. Query Parameters: Response (200 OK):

POST /api/v1/clients

Create a new client. Request:
Response (201 Created):
Error Responses:
  • 400 Bad Request: Seat limit exceeded
  • 422 Unprocessable Entity: Validation errors

GET /api/v1/clients/{client_id}

Get client details. Response (200 OK):

PUT /api/v1/clients/{client_id}

Update client details. Request:
Response (200 OK):

PUT /api/v1/clients/{client_id}/branding

Update client branding (logos, colors). Request:
Response (200 OK): Updated client object
Upload client logo. Request: multipart/form-data Response (200 OK):

DELETE /api/v1/clients/{client_id}

Deactivate a client (soft delete). Response (200 OK):

6.4 Document Generation Endpoints

POST /api/v1/clients/{client_id}/documents/generate

Start content generation for a client. Request:
Response (202 Accepted):

GET /api/v1/documents/{document_id}/status

Get generation status (for polling). Response (200 OK) - In Progress:
Response (200 OK) - Complete:

GET /api/v1/documents/{document_id}

Get full document details. Response (200 OK):

GET /api/v1/documents/{document_id}/content

Get full structured content (for editing/display). Response (200 OK):

GET /api/v1/documents/{document_id}/pdf

Download the PDF file. Response: Binary PDF file with appropriate headers

POST /api/v1/documents/{document_id}/distribute

Distribute document to social channels. Request:
Response (202 Accepted):

GET /api/v1/clients/{client_id}/documents

List documents for a client. Query Parameters: Response (200 OK):

6.5 Schedule Management Endpoints

GET /api/v1/clients/{client_id}/schedule

List scheduled content for a client. Query Parameters: Response (200 OK):

POST /api/v1/clients/{client_id}/schedule

Create a single scheduled content item. Request:
Response (201 Created):

POST /api/v1/clients/{client_id}/schedule/import

Import scheduled content from CSV. Request: multipart/form-data CSV Format:
Response (200 OK) - Dry Run:
Response (201 Created) - Actual Import:

PUT /api/v1/clients/{client_id}/schedule/{schedule_id}

Update a scheduled content item. Request:
Response (200 OK): Updated schedule object Error: 400 Bad Request if status is not ‘pending’

DELETE /api/v1/clients/{client_id}/schedule/{schedule_id}

Cancel a scheduled content item. Response (200 OK):
Error: 400 Bad Request if already processing or completed

DELETE /api/v1/clients/{client_id}/schedule/batch/{batch_id}

Cancel all pending items from an import batch. Response (200 OK):

6.6 Template Endpoints

GET /api/v1/templates

List available templates for the agency. Response (200 OK):

GET /api/v1/templates/{template_code}

Get template details. Response (200 OK):

6.7 Agency Settings Endpoints

GET /api/v1/agency

Get current agency details. Response (200 OK):

PUT /api/v1/agency

Update agency settings. Request:
Response (200 OK): Updated agency object

PUT /api/v1/agency/branding

Update agency branding (colors, logos). Request:
Response (200 OK): Updated branding object
Upload agency logo. Request: multipart/form-data Response (200 OK):

PUT /api/v1/agency/api-keys

Update agency API keys (BYOK mode). Request:
Response (200 OK):

POST /api/v1/agency/api-keys/test

Test API key validity. Request:
Response (200 OK):

GET /api/v1/agency/api-keys/list

List programmatic API keys for the agency. Response (200 OK):

POST /api/v1/agency/api-keys

Create a new programmatic API key. Request:
Response (201 Created):

DELETE /api/v1/agency/api-keys/{key_id}

Revoke an API key. Response (200 OK):

POST /api/v1/agency/custom-domain

Configure custom domain (Enterprise only). Request:
Response (200 OK):

POST /api/v1/agency/custom-domain/verify

Verify custom domain DNS configuration. Response (200 OK):

6.8 Team Management Endpoints

GET /api/v1/agency/team

List team members. Response (200 OK):

POST /api/v1/agency/team

Invite new team member. Request:
Response (201 Created):

PUT /api/v1/agency/team/{user_id}

Update team member. Request:
Response (200 OK): Updated user object

DELETE /api/v1/agency/team/{user_id}

Deactivate team member. Response (200 OK):

6.9 Admin Endpoints (Super Admin Only)

GET /api/v1/admin/agencies

List all agencies. Query Parameters: Response (200 OK):

POST /api/v1/admin/agencies

Create new agency. Request:
Response (201 Created): Full agency object with admin user

GET /api/v1/admin/agencies/{agency_id}

Get agency details (admin view). Response (200 OK): Full agency object with all settings, usage stats, and notes

PUT /api/v1/admin/agencies/{agency_id}

Update agency (admin actions). Request:

POST /api/v1/admin/agencies/{agency_id}/templates

Assign templates to agency (Pro plan only). Request:

GET /api/v1/admin/templates

List all templates. Response (200 OK): All templates with usage statistics

POST /api/v1/admin/templates

Create new template. Request:

PUT /api/v1/admin/templates/{template_id}

Update template.

GET /api/v1/admin/system/stats

Get system statistics. Response (200 OK):

7. Content Generation Pipeline

7.1 Pipeline Overview

The content generation pipeline is the core of the system. It transforms a topic into a professionally designed PDF document through a series of coordinated steps.

7.1.1 Generation Steps Summary

Total Typical Duration: 2-5 minutes

7.1.2 Pipeline Architecture

7.2 Step Details

7.2.1 Step 1: Topic Analysis

Purpose: Understand the topic scope and determine research depth. Input:
Process:
Output:

7.2.2 Step 2: Keyword Research

Purpose: Expand and prioritize keywords for research targeting. Process:

7.2.3 Step 3: Web Research (CRITICAL STEP)

Purpose: Conduct deep, comprehensive research. This is the primary differentiator. Key Principle: Research depth is NOT predetermined. It scales with topic complexity. Process:
Source Scoring Algorithm:

7.2.4 Step 4: Industry Analysis

Purpose: Extract industry-specific insights and benchmarks.

7.2.5 Step 5: Outline Creation

Purpose: Structure the document based on research findings.

7.2.6 Step 6: Content Writing

Purpose: Generate all written content based on outline and research.

7.2.7 Step 7: Statistics Integration

Purpose: Format and verify all statistics for display.

7.2.8 Step 8: Chart Generation

Purpose: Create data visualizations from statistics.

7.2.9 Step 9: Cover Image

Purpose: Select and prepare cover image.

7.2.10 Step 10: Template Application

Purpose: Combine content with design template.

7.2.11 Step 11: PDF Rendering

Purpose: Convert HTML to PDF.

7.2.12 Step 12: Quality Review

Purpose: Final validation before completion.

7.3 Celery Task Implementation


8. PDF Generation System

8.1 Template Architecture

8.1.1 Template Directory Structure

8.1.2 Base Template Structure

8.1.3 Executive Template Example

8.2 Color System for PDFs

8.2.1 Color Derivation

8.2.2 Chart Color Schemes


9. Distribution System

9.1 Distribution Overview

The distribution system handles posting generated content to social media platforms on behalf of clients.

9.1.1 Supported Platforms

9.1.2 Distribution Flow

9.2 Platform-Specific Implementations

9.2.1 LinkedIn Distribution

9.2.2 Facebook Distribution

9.2.3 Twitter/X Distribution

9.3 Celery Distribution Task


10. File Storage System

10.1 Storage Architecture

10.2 Public URL Configuration

For unbranded document hosting:

11. White-Label System

11.1 Domain Routing Architecture

The white-label system allows agencies to present Content Strategist under their own branding with custom domains.

11.1.1 Domain Types

11.1.2 Domain Resolution Middleware

11.1.3 Branding Resolution

11.1.4 Custom Domain Setup


12. CSV Import System

12.1 CSV Schema Definition

12.2 CSV Import Service


13. Scheduled Tasks

13.1 Celery Beat Configuration

13.2 Scheduled Content Processor


14. WebSocket Real-Time Updates

14.1 WebSocket Handler


15. Error Handling

15.1 Error Code Registry

15.2 Global Exception Handler


16. Rate Limiting

16.1 Rate Limiter Implementation


17. Logging & Monitoring

17.1 Structured Logging Configuration

17.2 Request Logging Middleware


18. Security Considerations

18.1 Security Checklist

18.2 Encryption Service


19. Environment Configuration

19.1 Environment Variables


20. Deployment

20.1 Docker Configuration

20.2 Docker Compose

20.3 Dokploy Configuration


21. Testing Requirements

21.1 Test Categories

21.2 Test Configuration

21.3 Example Tests


Appendix A: API Quick Reference

Endpoints Summary


Document Version History


END OF DEVELOPER PRD

22. Frontend Architecture

22.1 Frontend Technology Stack

22.2 Frontend Project Structure

22.3 State Management Architecture

22.3.1 State Categories

22.3.2 Zustand Store Implementations

22.4 API Client Layer

22.4.1 Axios Configuration

22.4.2 API Service Modules

22.5 TanStack Query Integration

22.5.1 Query Client Configuration

22.5.2 Query Hooks

22.6 WebSocket Integration

22.6.1 WebSocket Hook

22.6.2 Generation Progress Hook

22.7 Form Handling

22.7.1 Form Schema Definitions

22.7.2 Form Component Example

22.8 Authentication Flow (Frontend)

22.8.1 Auth Provider

22.8.2 Login Page

22.9 Protected Route Components

22.9.1 Permission Guard

22.9.2 Role-Based Layout

22.10 TypeScript Type Definitions

22.10.1 Core Types

22.11 Environment Configuration

22.11.1 Environment Variables

22.11.2 Next.js Configuration

22.12 Package.json Dependencies