Skip to content

prathamesh-6099/Refract-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌈 Refract AI

Convert YouTube videos into multi-platform content in 30 seconds.

Refract AI License TypeScript FastAPI

Refract AI takes any YouTube video and instantly generates:

  • πŸ“ SEO-optimized blog posts (1500-2000 words)
  • 🐦 Viral Twitter threads (8-12 engaging tweets)
  • πŸ’Ό LinkedIn articles (800-1200 words with hashtags)
  • πŸ–ΌοΈ Custom thumbnails (1280x720 YouTube-optimized)

πŸš€ Quick Start

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • Google Gemini API key (Get one free)

Backend Setup

cd backend

# Create virtual environment
python -m venv .venv

# Activate (Windows)
.\.venv\Scripts\activate
# Activate (macOS/Linux)
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Configure environment
cp .env.example .env
# Edit .env and add your GEMINI_API_KEY

# Start server
uvicorn main:app --reload --port 8000

Frontend Setup

cd frontend

# Install dependencies
npm install

# Configure environment (optional)
cp .env.example .env

# Start development server
npm run dev

Open http://localhost:5173 in your browser.


βš™οΈ Environment Variables

Backend (backend/.env)

Variable Description Required Default
GEMINI_API_KEY Google Gemini API key βœ… Yes -
ENVIRONMENT development or production No development
CORS_ORIGINS Allowed CORS origins (comma-separated) No http://localhost:5173
LOG_LEVEL Logging level No INFO

Frontend (frontend/.env)

Variable Description Required Default
VITE_API_URL Backend API URL No http://localhost:8000

🎯 Features

Content Generation

  • Smart transcript extraction from any YouTube video
  • Trend-aware content using real-time DuckDuckGo search
  • Multiple output formats optimized for each platform
  • AI-powered thumbnails with gradient backgrounds

User Experience

  • 🎨 Beautiful dark mode UI with prism gradient accents
  • ⚑ Real-time progress tracking with stage indicators
  • πŸ“‹ One-click copy for all content types
  • πŸ“₯ Download blog posts as Markdown files
  • πŸ–ΌοΈ Download thumbnails as PNG files

Technical

  • πŸ”’ Secure API with rate limiting
  • πŸ“± Fully responsive (mobile, tablet, desktop)
  • β™Ώ WCAG 2.1 accessible
  • πŸš€ Performance optimized with React.lazy and memoization

πŸ—οΈ Tech Stack

Backend

  • FastAPI - Modern Python web framework
  • Google Gemini AI - Content generation (1.5 Pro model)
  • youtube-transcript-api - Transcript extraction
  • DuckDuckGo Search - Trend research
  • Pillow - Thumbnail generation
  • Pydantic - Data validation

Frontend

  • React 18 - UI library
  • TypeScript - Type safety
  • Vite - Build tool
  • Tailwind CSS - Styling
  • Framer Motion - Animations
  • Zustand - State management
  • React Router - Navigation
  • React Markdown - Blog rendering

πŸ“ Project Structure

refract-ai/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   └── routes.py      # API endpoints
β”‚   β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”‚   └── config.py      # Settings
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”‚   └── schemas.py     # Pydantic models
β”‚   β”‚   └── services/
β”‚   β”‚       β”œβ”€β”€ ai_service.py       # Gemini integration
β”‚   β”‚       β”œβ”€β”€ youtube_service.py  # Transcript extraction
β”‚   β”‚       β”œβ”€β”€ search_service.py   # Trend research
β”‚   β”‚       └── thumbnail_service.py # Image generation
β”‚   β”œβ”€β”€ main.py
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── .env.example
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/        # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ pages/            # Route pages
β”‚   β”‚   β”œβ”€β”€ services/         # API client
β”‚   β”‚   β”œβ”€β”€ store/            # Zustand state
β”‚   β”‚   β”œβ”€β”€ hooks/            # Custom hooks
β”‚   β”‚   └── types/            # TypeScript types
β”‚   β”œβ”€β”€ package.json
β”‚   └── .env.example
└── README.md

πŸ”Œ API Reference

POST /api/refract

Generate multi-platform content from a YouTube video.

Request:

{
  "youtube_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}

Response:

{
  "video_info": {
    "video_id": "dQw4w9WgXcQ",
    "title": "Video Title",
    "channel_name": "Channel Name",
    "transcript": "...",
    "thumbnail_url": "..."
  },
  "blog_post": "# Blog Title\n\n...",
  "twitter_thread": ["Tweet 1...", "Tweet 2...", ...],
  "linkedin_article": "Professional intro...\n\n#hashtags",
  "thumbnail_url": "data:image/png;base64,...",
  "generation_time": 12.5,
  "trends_used": ["trend1", "trend2"],
  "created_at": "2024-01-15T10:30:00Z"
}

GET /api/health

Health check endpoint.

GET /api/test-gemini

Test Gemini API connectivity.


πŸ§ͺ Testing

Test Complete Flow

  1. Start both backend and frontend servers
  2. Navigate to http://localhost:5173
  3. Paste a YouTube URL (e.g., https://www.youtube.com/watch?v=dQw4w9WgXcQ)
  4. Click "Refract" and wait for processing
  5. Switch between tabs to view Blog, Twitter, LinkedIn, and Thumbnail
  6. Test copy buttons and download functionality

Test Error Handling

  • Try an invalid URL β†’ Should show validation error
  • Try a video without subtitles β†’ Should show API error
  • Try while offline β†’ Should show network error

πŸ“ License

MIT License - see LICENSE for details.


🀝 Contributing

  1. Fork the repository
  2. Create a 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 a Pull Request

πŸ™ Acknowledgments

  • Google Gemini for AI capabilities
  • Lucide for beautiful icons
  • Built with ❀️ for the hackathon

Transform one video into a content empire 🌈

About

Convert YouTube videos into multi-platform content in 30 seconds.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors