Skip to content

AI-Powered Script Writing and Content Creation Platform Yoink AI is a Full-Stack web application that combines the power of OpenAI's GPT-4 with advanced content generation capabilities. Create scripts, generate images, and produce videos through an intuitive chat-based interface.

Notifications You must be signed in to change notification settings

HarshSharma0801/YoinkAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Yoink AI

AI-Powered Script Writing and Content Creation Platform

Yoink AI is a Full-Stack web application that combines the power of OpenAI's GPT-4 with advanced content generation capabilities. Create scripts, generate images, and produce videos through an intuitive chat-based interface.

✨ Features

  • πŸ€– AI-Powered Chat Interface - Conversation-driven content creation with OpenAI GPT-4
  • πŸ“ Script Writing - Generate professional scripts with AI assistance
  • 🎨 Image Generation - Create stunning visuals with DALL-E 3
  • 🎬 Video Generation - Transform images into videos (placeholder mode)
  • ☁️ Cloud Storage - Automatic asset management with Cloudinary
  • πŸ’Ύ Data Persistence - PostgreSQL database with full conversation history
  • ⚑ Real-time Updates - WebSocket-powered live collaboration
  • πŸ“± Responsive Design - Modern UI built with Next.js and Tailwind CSS

Video

Screen.Recording.2025-08-07.at.3.53.06.PM.mp4

πŸ—οΈ Architecture Overview

graph TD
    %% Frontend Layer
    A[Web UI] -->|renders| B[Editor Component]
    A -->|renders| C[Renderer Component]
    
    %% Communication Layer
    B -->|uses| D[WebSocket Client]
    A -->|uses| E[HTTP Client]
    
    %% Backend Gateway
    F[Server] -->|has| G[WebSocket Gateway]
    F -->|has| H[REST API]
    
    %% Service Layer
    G -->|communicates| I[AI Service]
    H -->|manages| J[User Service]
    H -->|manages| K[Project Service]
    
    %% External Connections
    I -->|requests| L[OpenAI API]
    K -->|uploads| M[Cloudinary API]
    
    %% Database Layer
    J -->|queries| N[(PostgreSQL)]
    K -->|queries| N
    
    %% Infrastructure
    F -->|runs in| O[Docker Container]
    N -->|hosted in| O
    
    %% Real-time Flow
    D -->|connects to| G
    E -->|requests to| H

Loading

πŸ“‹ Technical Stack

Frontend

  • Framework: Next.js 15 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS
  • UI Components: Custom components with Shadcn/ui patterns
  • HTTP Client: Axios
  • Real-time: Socket.io Client

Backend

  • Framework: NestJS
  • Language: TypeScript
  • Database: PostgreSQL with Prisma ORM
  • Real-time: Socket.io
  • Validation: class-validator
  • Architecture: Modular design with dependency injection

External Services

  • AI: OpenAI API (GPT-4, DALL-E 3)
  • Storage: Cloudinary
  • Infrastructure: Docker

πŸ”„ Application Flow

1. User Interaction Flow

User Input β†’ Frontend β†’ WebSocket β†’ NestJS Gateway β†’ OpenAI Service β†’ AI Response β†’ Real-time Updates

2. Content Generation Flow

Chat Message β†’ AI Analysis β†’ Function Calling β†’ Tool Execution β†’ Asset Creation β†’ Database Storage β†’ UI Update

3. Data Flow

Frontend (Axios) β†’ NestJS Controllers β†’ Services β†’ Prisma β†’ PostgreSQL

πŸš€ Quick Setup

Prerequisites

  • Node.js 18+
  • Docker
  • OpenAI API Key
  • Cloudinary Account

1. Clone & Install

git clone <repository-url>
cd YoinkAI

# Install dependencies
cd server && npm install
cd ../client && npm install

2. Environment Setup

Create server/.env:

DATABASE_URL="postgresql://user:password@localhost:5432/yoink_ai"
OPENAI_API_KEY="your_openai_api_key_here"

# Cloudinary Configuration
CLOUDINARY_CLOUD_NAME="your_cloud_name"
CLOUDINARY_API_KEY="your_api_key"
CLOUDINARY_API_SECRET="your_api_secret"

# Server
PORT=3001

3. Database Setup

# Start PostgreSQL with Docker
docker-compose up -d

# Run database migrations
cd server
npx prisma migrate dev

4. Start Development Servers

Terminal 1 - Backend:

cd server
npm run start:dev

Terminal 2 - Frontend:

cd client
npm run dev

5. Access Application

πŸ›οΈ Backend Architecture (NestJS)

Module Structure

src/
β”œβ”€β”€ app.module.ts           # Root module - orchestrates all modules
β”œβ”€β”€ main.ts                 # Application entry point
β”œβ”€β”€ users/                  # User management module
β”‚   β”œβ”€β”€ users.module.ts     # Module definition
β”‚   β”œβ”€β”€ users.controller.ts # HTTP route handlers
β”‚   β”œβ”€β”€ users.service.ts    # Business logic
β”‚   └── dto/                # Data transfer objects
β”œβ”€β”€ projects/               # Project management module
β”œβ”€β”€ openai/                 # AI service integration
β”œβ”€β”€ gateway/                # WebSocket real-time communication
β”œβ”€β”€ cloudinary/             # Asset storage service
β”œβ”€β”€ video/                  # Video generation (placeholder)
β”œβ”€β”€ tools/                  # Utility services
└── prisma/                 # Database service

Key Services

OpenAI Service

  • Purpose: Core AI functionality
  • Features:
    • Chat completions with GPT-4
    • Function calling for tool execution
    • Image generation with DALL-E 3
    • Retry logic for rate limiting
  • Dependencies: ProjectsService, CloudinaryService, VideoService

Projects Service

  • Purpose: Project and conversation management
  • Features:
    • CRUD operations for projects
    • Conversation history management
    • Element (content) storage
  • Dependencies: PrismaService

WebSocket Gateway

  • Purpose: Real-time communication
  • Features:
    • Live chat updates
    • Generation status notifications
    • Room-based project isolation
  • Dependencies: OpenAIService

🎨 Frontend Architecture (Next.js)

Component Structure

src/
β”œβ”€β”€ app/                    # Next.js App Router
β”‚   β”œβ”€β”€ page.tsx           # Home page - project listing
β”‚   └── projects/[id]/     # Dynamic project pages
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ editor/            # Main editor components
β”‚   β”‚   β”œβ”€β”€ editor.tsx     # Chat interface
β”‚   β”‚   └── element-renderer.tsx # Content display
β”‚   └── ui/                # Reusable UI components
β”œβ”€β”€ lib/
β”‚   └── socket.ts          # WebSocket client singleton
└── types/
    └── index.ts           # TypeScript interfaces

Key Features

Editor Component

  • Real-time chat interface
  • Dynamic content rendering
  • WebSocket event handling
  • State management for conversations

Element Renderer

  • Displays different content types (text, images, videos)
  • Handles loading states
  • Responsive design

πŸ—„οΈ Database Schema

Core Tables

  • Users: User authentication and profiles
  • Projects: Individual user projects
  • ConversationTurns: Chat history with role-based messages
  • Elements: Generated content (scripts, images, videos)

Relationships

User β†’ Projects (1:N)
Project β†’ ConversationTurns (1:N)
Project β†’ Elements (1:N)

πŸ”§ API Endpoints

REST API

GET    /projects/:id              # Get project details
POST   /projects                  # Create new project
GET    /projects/user/:userId     # Get user's projects
POST   /users/find-or-create      # User management

WebSocket Events

prompt           # Send chat message
textChunk        # Receive AI response
elementAdded     # New content generated
info            # Status updates

πŸ€– AI Function Calling

Yoink AI uses OpenAI's function calling to enable the AI to execute specific tools:

Available Functions

  1. generate_image: Creates images using DALL-E 3
  2. generate_video: Placeholder video generation
  3. add_script_element: Adds formatted script content

Function Call Flow

User Request β†’ AI Analysis β†’ Function Selection β†’ Tool Execution β†’ Result Integration β†’ Response

🎯 Key Features Explained

Real-time Collaboration

  • WebSocket-based live updates
  • Instant message delivery
  • Generation status notifications
  • Room-based project isolation

Content Generation

  • Scripts: AI-powered screenplay writing
  • Images: DALL-E 3 integration with Cloudinary storage
  • Videos: Placeholder system (cost-controlled)

Data Persistence

  • Complete conversation history
  • Generated asset storage
  • Project organization
  • User session management

πŸ”’ Security & Best Practices

  • Environment Variables: Secure API key management
  • Validation: DTO-based request validation
  • Error Handling: Comprehensive error logging
  • Rate Limiting: Built-in retry mechanisms
  • CORS: Properly configured cross-origin requests

πŸ§ͺ Development

Testing

# Backend tests
cd server && npm run test

# Frontend tests
cd client && npm run test

Building

# Backend build
cd server && npm run build

# Frontend build
cd client && npm run build

πŸš€ Deployment

Environment Variables for Production

  • Set NODE_ENV=production
  • Configure proper database URL
  • Set client URL for CORS
  • Add production API keys

Docker Production

# Build and run with Docker Compose
docker-compose -f docker-compose.prod.yml up -d

πŸ“ˆ Performance Considerations

  • Database: Indexed queries for conversation history
  • Assets: CDN delivery via Cloudinary
  • Caching: Client-side caching for static content
  • Optimization: Code splitting and lazy loading

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

πŸ“„ License

This project is licensed under the MIT License.


Built with ❀️ using NestJS, Next.js, and OpenAI

About

AI-Powered Script Writing and Content Creation Platform Yoink AI is a Full-Stack web application that combines the power of OpenAI's GPT-4 with advanced content generation capabilities. Create scripts, generate images, and produce videos through an intuitive chat-based interface.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published