Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

tarunkumar-sys/Redditreel

Repository files navigation

๐ŸŽฌ Reddit Reel AI

AI-Powered TikTok-Style Video Feed from Reddit

Transform Reddit into an infinite scroll video experience with intelligent AI search

Next.js TypeScript Prisma React License: MIT

Features โ€ข Screenshots โ€ข Quick Start โ€ข Tech Stack


๐Ÿ“ธ Screenshots

๐Ÿ  Landing Page

Landing Page

๐Ÿ” Authentication

Authentication

๐Ÿ“ฑ Dashboard

Dashboard

๐Ÿ‘จโ€๐Ÿ’ผ Admin Panel

Admin Panel


โœจ Features

๐Ÿค– Smart AI Search

Natural language queries powered by Ollama LLM with intelligent rule-based fallback

๐Ÿ“ฑ Zero-Lag Reel Feed

Virtual 3-slot DOM window โ€” swipe changes only CSS translateY. No unmount, no refetch, no rebuffer.

๐ŸŽฌ HLS.js Streaming

Full Reddit video playback with tuned buffer lengths: 30s active, 8s preload

๐Ÿ’พ Notepad & Boards

Save and organize favorite reels with tags and collections

๐Ÿ” Secure Auth

JWT sessions with bcrypt encryption and role-based access control

๐Ÿ“ถ Offline-Ready PWA

Service worker caches last 10 viewed reels โ€” instant load on slow or no connection

๐Ÿ”ž NSFW Mode

Age-gated adult content with 500+ subreddit coverage

๐Ÿ‘จโ€๐Ÿ’ผ Admin Dashboard

User management, analytics, and content moderation


๐Ÿš€ Quick Start

Prerequisites

Node.js 18+ | npm | PostgreSQL 14+ | Ollama (optional)

Installation

# Clone the repository
git clone https://github.com/tarunkumar-sys/next_llm.git
cd next_llm
# Install dependencies
npm install
# Setup environment
cp .env.example .env.local
# Edit .env.local with your configuration
# Initialize database (PostgreSQL required)
npx prisma generate
npx prisma db push
# Start development server
npm run dev

Visit http://localhost:3000 ๐ŸŽ‰


โš™๏ธ Configuration

Create .env.local in the root directory:

# Authentication (Required)
AUTH_SECRET=your-secret-key-here # Generate: npx auth secret
DATABASE_URL=postgresql://user:pass@host:5432/db?sslmode=require
# Reddit API (Optional - improves rate limits)
REDDIT_CLIENT_ID=your-client-id
REDDIT_CLIENT_SECRET=your-client-secret
# AI Features (Optional)
OLLAMA_URL=http://localhost:11434
OLLAMA_MODEL=llama3.2
๐Ÿ”‘ Getting Reddit API Credentials
  1. Go to reddit.com/prefs/apps
  2. Click "Create App" or "Create Another App"
  3. Select "web app"
  4. Set redirect URI to http://localhost:3000
  5. Copy your client ID and secret

๐Ÿ› ๏ธ Tech Stack

Frontend

Next.js React TypeScript Framer Motion HLS.js PWA

Backend

Node.js Prisma PostgreSQL

Authentication & Security

Auth.js JWT bcrypt

AI & APIs

Ollama Reddit API


๐Ÿ“ Project Structure

reddit-reel-ai/
โ”œโ”€โ”€ app/
โ”‚ โ”œโ”€โ”€ api/
โ”‚ โ”‚ โ”œโ”€โ”€ reddit/ # Reddit content fetcher + personalization
โ”‚ โ”‚ โ””โ”€โ”€ interpret/ # AI query interpreter (Ollama)
โ”‚ โ”œโ”€โ”€ actions/
โ”‚ โ”‚ โ”œโ”€โ”€ auth.ts # Register / login server actions
โ”‚ โ”‚ โ”œโ”€โ”€ db.ts # SavedReel / Note / Board CRUD
โ”‚ โ”‚ โ””โ”€โ”€ admin.ts # Admin operations
โ”‚ โ”œโ”€โ”€ admin/ # Admin dashboard
โ”‚ โ”œโ”€โ”€ dashboard/ # User dashboard
โ”‚ โ””โ”€โ”€ _landing.tsx # Landing page
โ”œโ”€โ”€ components/
โ”‚ โ”œโ”€โ”€ ReelFeed.tsx # Virtual 3-slot reel window + HLS.js
โ”‚ โ”œโ”€โ”€ ChatPanel.tsx # AI search interface
โ”‚ โ”œโ”€โ”€ Notepad.tsx # Saved reels manager
โ”‚ โ”œโ”€โ”€ LoginModal.tsx # Auth modal
โ”‚ โ””โ”€โ”€ ...
โ”œโ”€โ”€ lib/
โ”‚ โ”œโ”€โ”€ feedEngine.ts # Weighted round-robin feed algorithm
โ”‚ โ””โ”€โ”€ ...
โ”œโ”€โ”€ prisma/
โ”‚ โ”œโ”€โ”€ schema.prisma # PostgreSQL schema
โ”‚ โ””โ”€โ”€ migrations/
โ”œโ”€โ”€ public/
โ”‚ โ”œโ”€โ”€ sw.js # Service worker (10-reel LRU cache)
โ”‚ โ”œโ”€โ”€ manifest.json # PWA manifest
โ”‚ โ””โ”€โ”€ demo_img/
โ”œโ”€โ”€ next.config.ts # next-pwa + security headers
โ””โ”€โ”€ next-pwa.d.ts # Type shim for next-pwa

๐ŸŽฏ Key Features Explained

๐Ÿ“บ Virtual Reel Window

Only 3 <video> elements ever exist in the DOM. On swipe, only CSS translateY changes โ€” no component unmount, no network request, no HLS.js reinit. Zero-lag swipe at any speed.

๐ŸŽฅ HLS.js with Smart Buffering

  • Active slot: maxBufferLength: 30s, maxMaxBufferLength: 60s
  • Preload slots: maxBufferLength: 8s
  • HLS instance reused across swipes โ€” destroyed only when the URL changes

๐Ÿค– AI-Powered Feed

Query in natural language: "Show me funny cat videos" โ†’ Ollama interprets โ†’ fetches from 2000+ subreddits

Two-tier system:

  1. Ollama LLM โ€” Advanced natural language understanding
  2. Rule-based fallback โ€” Always available, regex-based matching

๐Ÿ“Š Intelligent Feed Algorithm

  • Weighted round-robin for subreddit variety
  • Personalization weights from watch history (last 200 events)
  • startTransition background prefetch when user is 5 reels from end

๐Ÿ“ถ Offline PWA

Service worker at /sw.js caches:

  • App shell (JS/CSS/fonts) โ€” CacheFirst, long TTL
  • Last 10 viewed reels media โ€” LRU eviction, instant revisit
  • /api/reddit JSON โ€” NetworkFirst with stale fallback

๐Ÿ›ก๏ธ Security Features

  • ๐Ÿ”’ JWT Authentication with HttpOnly cookies
  • ๐Ÿ” bcrypt Password Hashing (10 rounds)
  • ๐Ÿ›ก๏ธ HTTP Security Headers (X-Frame-Options, nosniff, XSS-Protection)
  • ๐Ÿ‘ฎ Role-Based Access Control (USER / ADMIN)
  • ๐Ÿšซ API Route Protection with server-side auth guards
  • ๐Ÿ” Input Validation on all server actions
  • ๐Ÿ“ Row-level data isolation via userId filtering
  • โœ… All security is server-side โ€” no client-side DevTools blocking

๐Ÿ“œ Available Scripts

npm run dev # Start development server
npm run build # Build for production
npm start # Start production server
npm run lint # Run ESLint
npm run seed # Seed admin user
npx prisma studio # Open database GUI
npx prisma db push # Push schema to PostgreSQL
npx prisma generate # Regenerate Prisma Client

๐Ÿš€ Deployment

Deploy to Vercel
  1. Push your code to GitHub
  2. Import project in Vercel
  3. Add environment variables (see SYSTEM.md)
  4. Deploy โ€” Vercel auto-detects NEXTAUTH_URL, do NOT set it manually

See DEPLOYMENT.md for detailed instructions.

Docker Deployment
# Build image
docker build -t reddit-reel-ai .
# Run container
docker run -p 3000:3000 --env-file .env reddit-reel-ai

๐Ÿค Contributing

Contributions are welcome! Please read CONTRIBUTING.md for guidelines.

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

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • Reddit API for content delivery
  • Ollama for local AI capabilities
  • HLS.js for robust video streaming
  • Next.js Team for the amazing framework
  • Vercel for hosting platform

Made with โค๏ธ by Tarun Kumar

โญ Star this repo if you find it useful!

Report Bug โ€ข Request Feature โ€ข Documentation

About

AI-Powered TikTok-Style Video Feed from Reddit - Transform Reddit into an infinite scroll video experience with intelligent AI search.

Topics

Resources

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

AltStyle ใซใ‚ˆใฃใฆๅค‰ๆ›ใ•ใ‚ŒใŸใƒšใƒผใ‚ธ (->ใ‚ชใƒชใ‚ธใƒŠใƒซ) /