Skip to content

Latest commit

 

History

History
105 lines (88 loc) · 7.19 KB

File metadata and controls

105 lines (88 loc) · 7.19 KB

Research Brief Generator

Overview

This is a full-stack application that generates comprehensive research briefs for content creation. Users input a topic, audience, and content requirements, and the system uses multiple AI providers (Perplexity, Claude, OpenAI) to research, synthesize, and create content outlines, scripts, and graphics recommendations. The application follows a multi-phase workflow: research gathering, strategy recommendation, outline generation, script drafting, and graphics planning.

User Preferences

Preferred communication style: Simple, everyday language. Project editing: Users should be able to edit project settings (tone, audience, etc.) mid-workflow Dropdown options: Include "Other" option in dropdowns with custom text input capability Outline editing: Users should be able to add/remove sections in the outline with full editing capabilities Graphics phase: Users expect the graphics phase to show content and interface when reached Graphics editing: Users should be able to fully edit all graphics elements (lower thirds, diagrams, thumbnails) with add/remove/modify capabilities Image Modification Studio: Users expect drag-and-drop image modification functionality powered by Google's nano-banana model via Replicate for actual image editing Structured Intro Requirement: All outlines must include a mandatory 30-second intro section following Promise → Progress → Payoff framework with specific beat timing and template structure

System Architecture

Frontend Architecture

  • Framework: React with TypeScript using Vite as the build tool
  • UI Library: Radix UI components with shadcn/ui styling system
  • Styling: Tailwind CSS with CSS variables for theming
  • State Management: TanStack Query for server state management
  • Routing: Wouter for client-side routing
  • Form Handling: React Hook Form with Zod validation

Backend Architecture

  • Runtime: Node.js with Express.js server
  • Language: TypeScript with ES modules
  • API Pattern: RESTful endpoints with JSON responses
  • Middleware: Request logging, JSON parsing, error handling
  • Development: Hot reload with Vite middleware integration

Data Storage Solutions

  • Database: PostgreSQL with Neon Database serverless driver for persistent storage
  • ORM: Drizzle ORM for type-safe database operations
  • Schema: Projects, runs, artifacts, and sources tables with foreign key relationships
  • Storage Pattern: Database storage implementation with IStorage interface for consistency
  • Migration: Drizzle Kit for schema migrations and database setup
  • Persistence: Full project persistence across server restarts and sessions

Authentication and Authorization

  • Current State: No authentication system implemented
  • Session Management: Express session middleware configured but not actively used
  • Future Consideration: Ready for session-based authentication implementation

Workflow Orchestration

  • Multi-Provider AI Integration: Parallel processing of research queries across different AI providers
  • Phase Management: Sequential workflow phases (research → strategy → outline → script → graphics)
  • Artifact Versioning: Each workflow phase produces versioned artifacts stored in the database
  • Content Editing: Full CRUD operations for outline sections with real-time updates and drag-and-drop reordering
  • Caching Strategy: Memoization of provider calls to avoid duplicate requests
  • Structured Intro Generation: Automatic inclusion of 30-second Promise → Progress → Payoff intro with beat timing (0-2s, 2-8s, 8-15s, 15-25s) and production checklist
  • Comprehensive Context Flow: Script generation now includes complete research findings and strategic approach for informed, data-driven content creation
  • Server Restart Resilience: Automatic startup recovery detects and handles runs stuck in "running" state from previous sessions, marking them as "failed" with clear retry message to prevent permanent stuck states

AI Provider Integration Strategy

  • Research Phase: Perplexity for web search with citations
  • Primary Content Generation: Anthropic Claude 4.5 Sonnet (claude-sonnet-4-5-20250929) for all reasoning, synthesis, and structured content generation
  • Automatic Fallback System:
    • OpenRouter (Claude 3.5 Sonnet via anthropic/claude-3.5-sonnet) automatically engages when Anthropic fails
    • Every content generation call tries Anthropic first, falls back to OpenRouter on error
    • Applies to all phases: synthesis, approach, outline, script, graphics
    • Tracks which provider succeeded for each phase independently
  • Comprehensive Provider Tracking:
    • Dynamic providersUsed array updated throughout workflow
    • Tracks providers for ALL phases (not just initial synthesis)
    • Handles edge cases where different phases use different providers
    • Prevents duplicate entries while maintaining complete audit trail
  • Script Generation: Enhanced with complete context including research findings, strategic approach, and content outline for informed script creation
  • Image Modification: Google's nano-banana model via Replicate for actual image editing and modification
  • Parallel Processing: Multiple providers run simultaneously where safe, serialized where dependencies exist
  • Provider Abstraction: Common interface for different AI providers enabling easy swapping

External Dependencies

AI Services

  • Anthropic Claude: Primary reasoning model (claude-sonnet-4-5-20250929) for synthesis and content generation
  • OpenRouter: Automatic fallback provider (Claude 3.5 Sonnet) for content generation resilience
  • Perplexity: Online search with citations for research gathering
  • Google Gemini: Flash Image Preview model (gemini-2.0-flash-exp) for intelligent image analysis and modification guidance

Video Processing (Script Studio)

  • Server-Side Processing: Large video files (>100MB) are processed on the server using ffmpeg for audio extraction
  • Client-Side Processing: Smaller videos (<100MB) are processed in-browser using Web Audio API
  • FFmpeg Integration: System-level ffmpeg package for reliable audio extraction from any video format
  • Multer Upload: Streaming multipart uploads to /tmp for efficient large file handling
  • Progress Tracking: Real-time progress updates via session polling (uploading → extracting → transcribing → revising → analyzing → completed)
  • Automatic Cleanup: Temporary files removed after processing completes or fails

Database and Storage

  • Neon Database: Serverless PostgreSQL database hosting
  • Drizzle ORM: Type-safe database operations and migrations

UI and Development

  • Radix UI: Accessible component primitives for form controls and overlays
  • Tailwind CSS: Utility-first CSS framework with design system integration
  • Vite: Build tool and development server with hot module replacement
  • TanStack Query: Server state management with caching and synchronization

Utilities and Tooling

  • Zod: Runtime type validation for API requests and database schemas
  • date-fns: Date manipulation and formatting utilities
  • Replit Integration: Development environment specific plugins and error handling