Skip to content

ashutosh2652/ReplyPilot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

170 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ ReplyPilot

AI-Powered YouTube Comment Management Platform

Automate comment classification, reply generation, and publishing β€” all from one dashboard.

Features β€’ Architecture β€’ Tech Stack β€’ Getting Started β€’ Project Structure β€’ License


✨ Features

  • πŸ” Google OAuth 2.0 β€” Secure login with YouTube channel linking
  • πŸ“₯ Auto Comment Sync β€” Periodically fetches new comments from all your videos
  • πŸ€– AI Intent Classification β€” Custom fine-tuned model detects spam, praise, criticism, questions, and neutral comments
  • πŸ’¬ Smart Reply Generation β€” LLM-powered replies using Google Gemma-4-31B-it with 10 customizable tone templates
  • 🎭 Persona System β€” Create multiple reply personas with custom system prompts and tones
  • πŸ“Ή RAG-Powered Context β€” Video transcript indexing with semantic search for context-aware replies
  • πŸ“Š Dashboard & Analytics β€” Channel overview, video management, and comment insights
  • ⚑ Background Processing β€” BullMQ job queues with retry logic and exponential backoff
  • πŸ›‘οΈ Enterprise Security β€” AES-256-GCM token encryption, CSRF protection, rate limiting, Helmet headers

πŸ—οΈ Architecture

ReplyPilot uses a microservices architecture with 5 independent services:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   React +   │────▢│   Express.js    │────▢│   BullMQ Worker  β”‚
β”‚   Vite UI   β”‚     β”‚   REST API      β”‚     β”‚   (Background)   β”‚
β”‚  (Port 5173)β”‚     β”‚  (Port 5000)    β”‚     β”‚                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚                      β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚    MongoDB      β”‚    β”‚  AI Service       β”‚
                    β”‚    Redis        β”‚    β”‚  FastAPI (8000)   β”‚
                    β”‚                 β”‚    β”‚                   β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚  RAG Service      β”‚
                                          β”‚  FastAPI (8001)   β”‚
                                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Service Description
Client React 18 + Vite frontend with Tailwind CSS
Server Express.js API with Passport.js auth, session management, and cron jobs
Worker Standalone BullMQ processor for classify, generate, and post-reply jobs
AI Service FastAPI microservice for intent classification and LLM reply generation
RAG Service FastAPI microservice for video transcript ingestion and semantic retrieval

For a comprehensive deep-dive, see ARCHITECTURE.md.


πŸ› οΈ Tech Stack

Layer Technologies
Frontend React 18, Vite 8, React Router v7, Tailwind CSS 4, Axios
Backend API Node.js, Express 5, Passport.js, Mongoose, Winston
Background Jobs BullMQ (Redis-backed), node-cron
AI / NLP Python, FastAPI, HuggingFace Transformers, OpenAI SDK
LLM Google Gemma-4-31B-it (HuggingFace Inference API)
Embeddings BGE (BAAI General Embedding) via sentence-transformers
Vector DB Pinecone
Primary DB MongoDB (Mongoose ODM)
Cache / Queue Redis (sessions, caching, token store, job queue)
Auth Google OAuth 2.0, express-session + connect-redis
Security Helmet, CORS, CSRF, AES-256-GCM encryption, Rate Limiting
External API YouTube Data API v3
Infra Docker

πŸš€ Getting Started

Prerequisites

  • Node.js β‰₯ 18
  • Python β‰₯ 3.10
  • MongoDB (local or Atlas)
  • Redis (local or cloud)
  • Google Cloud Console project with YouTube Data API v3 and OAuth 2.0 credentials
  • HuggingFace API token (for LLM inference)
  • Pinecone account (for RAG vector storage)

1. Clone the Repository

git clone https://github.com/ashutosh2652/ReplyPilot.git
cd ReplyPilot

2. Environment Variables

Copy the example env file and fill in your credentials:

cp .env.example server/.env

Required variables:

Variable Description
GOOGLE_CLIENT_ID Google OAuth 2.0 client ID
GOOGLE_CLIENT_SECRET Google OAuth 2.0 client secret
GOOGLE_REDIRECT_URI OAuth callback URL
MONGODB_URI MongoDB connection string
REDIS_URL Redis connection string
SESSION_SECRET Express session secret
CLIENT_URL Frontend URL (e.g., http://localhost:5173)
AI_SERVICE_URL AI service URL (e.g., http://localhost:8000)
YOUTUBE_API_KEY YouTube Data API key

Also configure .env files for ai-service/, rag/, and worker/ β€” refer to their .env.example / .env.sample files.

3. Install & Run Each Service

Client (React Frontend)

cd client
npm install
npm run dev          # β†’ http://localhost:5173

Server (Express API)

cd server
npm install
npm run dev          # β†’ http://localhost:5000

Worker (BullMQ)

cd worker
npm install
npm run dev

AI Service (FastAPI)

cd ai-service
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --port 8000 --reload

RAG Service (FastAPI)

cd rag
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --port 8001 --reload

πŸ“ Project Structure

ReplyPilot/
β”œβ”€β”€ client/                     # React + Vite Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ api/                # Axios API modules
β”‚   β”‚   β”œβ”€β”€ components/         # Shared components (ProtectedRoute)
β”‚   β”‚   β”œβ”€β”€ context/            # AuthContext provider
β”‚   β”‚   β”œβ”€β”€ hooks/              # Custom hooks (useAuth)
β”‚   β”‚   β”œβ”€β”€ layouts/            # AppLayout wrapper
β”‚   β”‚   └── pages/              # 6 page components
β”‚   └── vite.config.js
β”‚
β”œβ”€β”€ server/                     # Express.js Backend API
β”‚   β”œβ”€β”€ server.js               # Entry point + graceful shutdown
β”‚   └── src/
β”‚       β”œβ”€β”€ config/             # env, db, redis, passport, cors
β”‚       β”œβ”€β”€ controllers/        # Route controllers
β”‚       β”œβ”€β”€ middleware/          # Auth, CSRF, rate limiter, logging
β”‚       β”œβ”€β”€ models/             # Mongoose schemas (User, Channel, Video, etc.)
β”‚       β”œβ”€β”€ routes/             # API route definitions
β”‚       β”œβ”€β”€ services/           # Business logic (Channel, Queue, Reply, AI)
β”‚       β”œβ”€β”€ mapper/             # Data transformation layers
β”‚       β”œβ”€β”€ jobs/               # Cron jobs (syncComments)
β”‚       └── utils/              # Crypto, logger, YouTube helpers
β”‚
β”œβ”€β”€ worker/                     # BullMQ Background Worker
β”‚   β”œβ”€β”€ main.js                 # Entry point + shutdown handlers
β”‚   β”œβ”€β”€ config/                 # DB, Redis, env config
β”‚   β”œβ”€β”€ models/                 # Shared Mongoose models
β”‚   β”œβ”€β”€ tasks/                  # classify, generate, postReply, youtubeSync workers
β”‚   └── utils/                  # HTTP client, logger, YouTube helpers
β”‚
β”œβ”€β”€ ai-service/                 # Python AI Microservice
β”‚   └── app/
β”‚       β”œβ”€β”€ main.py             # FastAPI application
β”‚       β”œβ”€β”€ api/v1/             # classify & generate endpoints
β”‚       β”œβ”€β”€ services/           # Classification & generation logic
β”‚       β”œβ”€β”€ model_files/        # Fine-tuned intent classifier
β”‚       β”œβ”€β”€ prompts/            # 10 tone template files
β”‚       └── schemas/            # Pydantic request/response models
β”‚
β”œβ”€β”€ rag/                        # Python RAG Microservice
β”‚   └── app/
β”‚       β”œβ”€β”€ main.py             # FastAPI application
β”‚       β”œβ”€β”€ api/routes/         # health, ingest, query endpoints
β”‚       β”œβ”€β”€ services/           # Ingest & query orchestration
β”‚       β”œβ”€β”€ pipeline/           # 9-stage ingest pipeline
β”‚       β”œβ”€β”€ retrieval/          # Query embedder, searcher, reranker
β”‚       └── core/               # Config, logger, exceptions
β”‚
β”œβ”€β”€ infra/
β”‚   └── docker/                 # Dockerfiles for client & server
β”‚
β”œβ”€β”€ ARCHITECTURE.md             # Detailed system architecture documentation
β”œβ”€β”€ .env.example                # Environment variable template
└── README.md                   # ← You are here

πŸ”„ How It Works

  1. User logs in via Google OAuth β†’ YouTube channel is linked
  2. Comments sync automatically every 30 minutes via cron job
  3. Classification worker picks up new comments β†’ AI Service classifies intent (spam / praise / criticism / question / neutral)
  4. Generation worker creates AI-powered replies using the user's selected persona and tone
  5. User reviews replies on the dashboard β†’ approves, edits, or rejects
  6. Post-reply worker publishes approved replies directly to YouTube (with idempotency safeguards)

πŸ“‘ API Endpoints

Route Method Description
/api/auth/google GET Initiate Google OAuth login
/api/auth/google/callback GET OAuth callback handler
/api/auth/logout POST Logout and destroy session
/api/channel/sync POST Sync channel info from YouTube
/api/channel/videos GET List synced videos
/api/channel/videos/:videoId/comments GET Fetch comments for a video
/api/comments GET List/filter all comments
/api/personas GET/POST CRUD for reply personas
/api/batch/classify POST Bulk classify comments
/api/batch/generate POST Bulk generate replies
/api/replies GET List generated replies
/api/replies/:id/approve POST Approve and publish a reply
/health GET Service health check

πŸ”’ Security

  • AES-256-GCM encryption for Google refresh tokens at rest
  • Redis-backed sessions with 7-day TTL and session regeneration
  • CSRF protection on all state-changing endpoints
  • Rate limiting with Redis store to prevent API abuse
  • Helmet HTTP security headers
  • CORS whitelist configuration
  • User data caching (15-min TTL) to minimize database exposure

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


Built with ❀️ by Ashutosh

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors