YouTube Channel Growth Platform - A modern web application helping creators grow their channels through subscription exchanges
SUB4SUB is a creator growth platform that enables YouTube channel owners to organically grow their audience by exchanging subscriptions with other creators. Built with modern technologies and a YouTube-inspired design aesthetic, it provides a secure, scalable, and user-friendly environment for channel growth.
The Exchange Model:
- Creators register and link their YouTube channels
- Browse other creators in the exchange pool
- Subscribe to channels you're genuinely interested in
- Earn credits when others subscribe to your channel
- Track growth through comprehensive analytics
This creates a mutual benefit ecosystem where all creators can grow together while discovering quality content.
Growth Tools:
- π― Smart Channel Exchange - Browse and subscribe to relevant channels
- π Real-time Analytics - Track subscribers, views, and engagement
- β Subscription Verification - Automated verification system
- π Credit System - Earn credits for subscriptions, spend on growth
- π Growth Statistics - Historical data and trend analysis
- π Notifications - Stay updated on new subscribers and activity
Premium Features:
- β‘ Priority Placement - Higher visibility in exchange pool
- π Bonus Credits - Extra credits for faster growth
- π Priority Support - Faster response times
- π Unlock Advanced Features - Enhanced analytics, custom filtering
Management Dashboard:
- π₯ User Management - View, ban, verify, grant premium access
- π Subscription Verification - Manual review and approval system
- π³ Payment Tracking - Monitor all transactions
- π Content Management - Edit site pages (About, FAQ, Privacy, etc.)
- βοΈ System Settings - Configure credits, pricing, features
- π Platform Analytics - User growth, engagement metrics
Security & Performance:
- π Password hashing with bcrypt (10 rounds)
- π‘οΈ CSRF protection on all forms
- π¦ Rate limiting on APIs (100 req/15min)
- π Secure HTTP headers (Helmet.js)
- β Input validation and sanitization
- π§ Email verification (optional)
- πΎ Session persistence with MongoDB
Modern Architecture:
- π RESTful API design
- π± Mobile-responsive UI (Bootstrap 5)
- β‘ Fast database queries (indexed)
- π¨ Modern design system (YouTube-inspired)
- π SEO-friendly routing
- π Comprehensive error handling
- Node.js 16+ installed
- MongoDB 5.0+ running
- Basic command line knowledge
# 1. Install dependencies
npm install
# 2. Create environment file
cp .env.example .env
# 3. Initialize database
npm run migrate
# 4. Generate view templates
node scripts/generate-views.js
# 5. Start the server
npm run devThat's it! Visit http://localhost:3000
Default Admin Login:
- Email:
admin@sub4sub.com - Password:
admin123
π Need detailed setup instructions? See SETUP.md
π¨ Want to understand the design? See DESIGN.md
Backend:
- Runtime: Node.js 16+ (JavaScript ES6+, async/await)
- Framework: Express.js 4.x (Middleware-based architecture)
- Database: MongoDB 5.0+ (NoSQL document database)
- ODM: Mongoose 8.x (Schema validation, relationships)
Frontend:
- Templating: EJS (Server-side rendering)
- UI Framework: Bootstrap 5.3.0 (Responsive grid system)
- Icons: Font Awesome 6.4.0 (1500+ icons)
- Fonts: Google Fonts (Inter, Poppins)
- Rich Text: Quill.js 1.3.6 (Free, no API key)
Security:
- Authentication: bcryptjs (Password hashing)
- Sessions: express-session + connect-mongo
- HTTP Security: Helmet.js (Secure headers)
- Rate Limiting: express-rate-limit (DoS protection)
- Input Validation: express-validator
- CSRF Protection: csurf
Optional Services:
- Email: Nodemailer (SMTP)
- Payments: Stripe, PayPal
- File Upload: Multer
Core Collections:
// Users Collection
{
_id: ObjectId,
email: String (unique, indexed),
username: String (unique, indexed),
password: String (hashed),
youtubeChannel: String,
credits: Number (default: 10),
isPremium: Boolean,
isAdmin: Boolean,
isBanned: Boolean,
isVerified: Boolean,
subscriptionCount: Number,
createdAt: Date
}
// Subscriptions Collection
{
_id: ObjectId,
userId: ObjectId (ref: User),
targetUserId: ObjectId (ref: User),
status: String (pending|verified|rejected),
verificationScreenshot: String,
createdAt: Date,
verifiedAt: Date
}
// Payments Collection
{
_id: ObjectId,
userId: ObjectId (ref: User),
amount: Number,
credits: Number,
paymentMethod: String (stripe|paypal),
transactionId: String,
status: String (completed|pending|failed),
createdAt: Date
}
// Notifications Collection
{
_id: ObjectId,
userId: ObjectId (ref: User),
message: String,
type: String (info|success|warning|error),
isRead: Boolean,
createdAt: Date
}
// Content Collection (Static Pages)
{
_id: ObjectId,
page: String (about|faq|privacy|tos|contact),
title: String,
content: String (HTML),
updatedAt: Date
}Route Hierarchy:
server.js (Entry Point)
β
βββ / β routes/main.js (Public pages)
β βββ GET / β Landing page
β βββ GET /about β About page
β βββ GET /faq β FAQ page
β βββ GET /contact β Contact page
β βββ GET /privacy β Privacy policy
β βββ GET /tos β Terms of service
β
βββ /auth β routes/auth.js (Authentication)
β βββ GET /auth/login β Login form
β βββ POST /auth/login β Process login
β βββ GET /auth/register β Registration form
β βββ POST /auth/register β Process registration
β βββ GET /auth/logout β Logout
β βββ GET /auth/verify/:token β Email verification
β
βββ /account β routes/main.js (User dashboard)
β βββ GET /account β User dashboard
β βββ GET /exchange β Subscription exchange
β βββ GET /analytics β Growth analytics
β βββ GET /notification β Notifications
β βββ GET /purchase β Premium purchase
β βββ POST /purchase-success β Payment callback
β
βββ /admin β routes/admin.js (Admin panel)
β βββ GET /admin/dashboard β Admin dashboard
β βββ GET /admin/users β User management
β βββ POST /admin/users/:id/ban β Ban/unban user
β βββ POST /admin/users/:id/premium β Toggle premium
β βββ GET /admin/verify-users β Subscription verification
β βββ POST /admin/verify/:id β Approve subscription
β βββ GET /admin/payments β Payment history
β βββ GET /admin/content-management β Content editor
β βββ POST /admin/content/:page β Update page content
β βββ GET /admin/settings β System settings
β
βββ /api β routes/api.js (REST API)
βββ GET /api/ β API documentation
βββ GET /api/user β Current user data
βββ GET /api/users β All users (admin)
βββ GET /api/subscriptions β User subscriptions
βββ GET /api/notifications β User notifications
βββ GET /api/stats β Platform statistics
Request Flow:
HTTP Request
β
[1] helmet (Security headers)
β
[2] compression (Gzip compression)
β
[3] express.json() (Parse JSON)
β
[4] express.urlencoded() (Parse forms)
β
[5] express-session (Session management)
β
[6] csrf (CSRF protection)
β
[7] morgan (Request logging)
β
[8] custom middleware (User context)
β
[9] Route handler
β
[10] errorHandler (Error handling)
β
HTTP Response
Multi-Level Protection:
-
Password Security
- bcrypt hashing (10 rounds)
- Salt generated per password
- Comparison timing-safe
-
Session Security
- HTTP-only cookies
- Secure flag in production
- SameSite: strict
- 14-day expiration
-
Input Validation
// Example validation body('email').isEmail().normalizeEmail(), body('password').isLength({ min: 8 }), body('username').matches(/^[a-zA-Z0-9_]{3,20}$/)
-
Rate Limiting
// API routes: 100 requests per 15 minutes // Auth routes: 5 attempts per 15 minutes
-
SQL Injection Prevention
- MongoDB (NoSQL) - No SQL injection possible
- Mongoose sanitizes all queries
Sub4Sub/
β
βββ π assets/ # Static files (served publicly)
β βββ css/
β β βββ style.css # Main stylesheet (YouTube theme)
β βββ js/
β βββ app.js # Client-side JavaScript
β
βββ π config/ # Configuration
β βββ config.js # Environment-based config
β
βββ π middleware/ # Express middleware
β βββ auth.js # Authentication checks
β βββ errorHandler.js # Global error handler
β βββ upload.js # Multer file upload config
β βββ validation.js # Input validation rules
β
βββ π models/ # Mongoose schemas
β βββ User.js # User account model
β βββ Subscription.js # Subscription exchange model
β βββ Payment.js # Payment transaction model
β βββ Notification.js # User notification model
β βββ Content.js # Static page content model
β
βββ π routes/ # Express route handlers
β βββ main.js # Public pages + user dashboard
β βββ auth.js # Authentication routes
β βββ admin.js # Admin panel routes
β βββ api.js # REST API endpoints
β
βββ π scripts/ # Utility scripts
β βββ migrate.js # Database initialization
β βββ generate-views.js # Create EJS templates
β βββ cleanup-php-files.js # Remove old PHP files
β
βββ π utils/ # Helper functions
β βββ emailService.js # Email sending service
β βββ helpers.js # General utility functions
β
βββ π views/ # EJS templates
β βββ partials/ # Reusable components
β β βββ header.ejs # Site header/nav
β β βββ footer.ejs # Site footer
β βββ auth/ # Authentication pages
β β βββ login.ejs
β β βββ register.ejs
β β βββ forgot-password.ejs
β β βββ verify.ejs
β βββ admin/ # Admin panel pages
β β βββ dashboard.ejs
β β βββ users.ejs
β β βββ verify-users.ejs
β β βββ payments.ejs
β β βββ content-management.ejs
β β βββ settings.ejs
β βββ errors/ # Error pages
β β βββ 404.ejs
β β βββ 500.ejs
β βββ index.ejs # Landing page
β βββ about.ejs # About page
β βββ faq.ejs # FAQ page
β βββ contact.ejs # Contact page
β βββ privacy.ejs # Privacy policy
β βββ tos.ejs # Terms of service
β βββ account.ejs # User dashboard
β βββ exchange.ejs # Subscription exchange
β βββ analytics.ejs # Growth analytics
β βββ notification.ejs # Notifications
β βββ purchase.ejs # Premium purchase
β
βββ π uploads/ # User-uploaded files
β βββ (dynamically created)
β
βββ π .env # Environment variables (NOT in git)
βββ π .env.example # Environment template
βββ π .gitignore # Git ignore rules
βββ π package.json # Dependencies & scripts
βββ π package-lock.json # Locked dependency versions
βββ π server.js # Application entry point
β
βββ π README.md # This file (Core documentation)
βββ π SETUP.md # Detailed setup guide
βββ π DESIGN.md # Design principles & concepts
Informational Pages:
- Home:
/ - About Us:
/about - FAQ:
/faq - Contact:
/contact - Privacy Policy:
/privacy - Terms of Service:
/tos
Authentication:
- Login:
/auth/login - Register:
/auth/register - Forgot Password:
/auth/forgot - Email Verification:
/auth/verify/:token - Logout:
/auth/logout
Dashboard & Tools:
- User Dashboard:
/account - Subscription Exchange:
/exchange - Analytics & Stats:
/analytics - Notifications:
/notification - Purchase Premium:
/purchase - Payment Success:
/purchase-success
Management Interface:
- Admin Dashboard:
/admin/dashboard - User Management:
/admin/users - Verify Subscriptions:
/admin/verify-users - Payment History:
/admin/payments - Content Management:
/admin/content-management - System Settings:
/admin/settings
Endpoints:
- API Info:
GET /api/ - Current User:
GET /api/user - All Users:
GET /api/users(admin) - Subscriptions:
GET /api/subscriptions - Notifications:
GET /api/notifications - Platform Stats:
GET /api/stats
# Production
npm start # Start production server (PORT 3000)
# Development
npm run dev # Start with nodemon (auto-reload on changes)
# Database
npm run migrate # Initialize/reset database + create admin user
# Utilities
node scripts/generate-views.js # Generate all EJS templates
node scripts/cleanup-php-files.js # Remove old PHP files (one-time)
# Package Management
npm install # Install all dependencies
npm update # Update packages to latest compatible
npm audit fix # Fix security vulnerabilitiesMinimal Configuration (.env):
NODE_ENV=development
PORT=3000
MONGODB_URI=mongodb://localhost:27017/sub4sub
SESSION_SECRET=change-this-to-random-string-in-production
ADMIN_EMAIL=admin@sub4sub.com
ADMIN_PASSWORD=admin123Full Configuration (Optional Features):
# Email Service (Optional - app works without it)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-app-password
# Payment Gateways (Optional - demo mode available)
STRIPE_SECRET_KEY=sk_test_...
STRIPE_PUBLISHABLE_KEY=pk_test_...
PAYPAL_CLIENT_ID=...
PAYPAL_CLIENT_SECRET=...
PAYPAL_MODE=sandbox
# File Upload Settings
MAX_FILE_SIZE=5242880
UPLOAD_DIR=uploads# 1. Clone repository
git clone <repo-url>
cd Sub4Sub
# 2. Install dependencies
npm install
# 3. Start MongoDB (if not running)
# Windows: net start MongoDB
# Linux/Mac: sudo systemctl start mongod
# 4. Configure environment
cp .env.example .env
# Edit .env with your settings
# 5. Initialize database
npm run migrate
# 6. Generate views (if needed)
node scripts/generate-views.js
# 7. Start development server
npm run dev
# 8. Open browser
# Visit http://localhost:3000After editing code:
- Server auto-restarts (nodemon watching)
- Refresh browser to see changes
- Check terminal for errors
After editing views:
- Just refresh browser
- EJS compiles on each request in development
After editing models:
- Restart server
- May need to run
npm run migrateif schema changed
Before deploying:
- Set
NODE_ENV=productionin environment - Use strong
SESSION_SECRET(64+ random characters) - Change admin password from default
- Use production MongoDB (MongoDB Atlas recommended)
- Enable MongoDB authentication
- Configure HTTPS/SSL
- Set up domain name and DNS
- Configure email service (optional but recommended)
- Test all features thoroughly
- Set up monitoring and logging
- Configure automated backups
- Review security settings
Option 1: Railway.app (Easiest)
- Sign up at railway.app
- Click "New Project" β "Deploy from GitHub"
- Connect repository
- Add MongoDB plugin (automatic)
- Set environment variables in dashboard
- Deploy automatically on push
Option 2: Heroku
# Install Heroku CLI
heroku login
heroku create your-app-name
# Add MongoDB
heroku addons:create mongolab:sandbox
# Configure
heroku config:set NODE_ENV=production
heroku config:set SESSION_SECRET=your-secret
# Deploy
git push heroku main
heroku openOption 3: DigitalOcean/VPS
# SSH into server
ssh root@your-server-ip
# Install Node.js 16+
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
# Install MongoDB
# (See SETUP.md for detailed instructions)
# Clone project
git clone your-repo-url
cd Sub4Sub
# Install dependencies (production only)
npm install --production
# Configure environment
nano .env
# Add production settings
# Initialize database
npm run migrate
# Install PM2 (process manager)
npm install -g pm2
# Start application
pm2 start server.js --name sub4sub
# Configure PM2 to start on boot
pm2 startup
pm2 save
# Set up Nginx reverse proxy
# (See SETUP.md for Nginx configuration)
# Set up SSL with Let's Encrypt
sudo apt-get install certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.comOption 4: Docker (Advanced)
# Dockerfile example
FROM node:16-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
EXPOSE 3000
CMD ["npm", "start"]Admin Account:
- Email:
admin@sub4sub.com - Password:
admin123
To reset admin password:
npm run migrate
# This recreates the admin user with default passwordError:
MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017
Solutions:
# Windows
net start MongoDB
# Linux/Mac
sudo systemctl start mongod
# Verify MongoDB is running
mongosh --eval "db.version()"Error:
Error: listen EADDRINUSE: address already in use :::3000
Solutions:
Option A: Change port in .env
PORT=3001Option B: Kill the process (Windows)
netstat -ano | findstr :3000
taskkill /PID <PID> /FOption C: Kill the process (Linux/Mac)
lsof -ti:3000 | xargs kill -9Error:
Error: Failed to lookup view "index"
Solution:
node scripts/generate-views.jsError:
Error: Cannot find module 'express'
Solution:
rm -rf node_modules package-lock.json
npm installError:
Session store unavailable
Solutions:
- Ensure MongoDB is running
- Check
MONGODB_URIin.env - Restart the server
- Clear browser cookies
Complete Guides:
- README.md (this file) - Overview, features, quick start, architecture
- SETUP.md - Detailed installation, configuration, deployment, troubleshooting
- DESIGN.md - Design principles, color system, UI patterns, accessibility
Code Documentation:
- package.json - Dependencies, scripts, metadata
- Inline Comments - All complex logic documented in code
This application follows a YouTube-inspired design aesthetic:
- Primary Color: Vibrant Red (#FF0000) - Action, urgency, brand recognition
- Background: Purple Gradient (#667eea β #764ba2) - Modern, depth, engagement
- Dark Elements: Professional darks (#1a1a2e, #16213e) - Authority, sophistication
- Typography: Inter (body), Poppins (headings) - Clean, modern, readable
- Animations: Smooth transitions (0.3s ease) - Responsive, alive, quality
Core Principles:
- Creator-First - Every design decision serves creator growth
- Progressive Disclosure - Information revealed based on user journey
- Visual Hierarchy - Clear path from attention β conversion
- Micro-Interactions - Every action provides feedback
- Accessibility - WCAG AA compliant, keyboard navigable
π Learn more: See DESIGN.md for complete design system documentation
Authentication & Authorization:
- Password hashing with bcrypt (10 rounds + salt)
- Session-based authentication (HTTP-only cookies)
- Role-based access control (user, admin)
- CSRF tokens on all forms
Input Security:
- Input validation with express-validator
- Sanitization of user input
- Mongoose schema validation
- XSS protection (EJS auto-escapes)
Network Security:
- Rate limiting (100 req/15min on API)
- Helmet.js security headers
- CORS configuration
- HTTPS enforcement in production
Database Security:
- MongoDB authentication (production)
- Connection string encryption
- Query sanitization (Mongoose)
- Indexed queries (performance + security)
Production Deployment:
- Use strong
SESSION_SECRET(64+ random characters) - Enable MongoDB authentication
- Use HTTPS/TLS (Let's Encrypt)
- Change default admin credentials
- Keep dependencies updated (
npm audit fix) - Set
NODE_ENV=production - Configure firewall rules
- Monitor logs for suspicious activity
- Regular database backups
- Implement rate limiting on all public endpoints
| Aspect | PHP (v1.x) | Node.js (v2.0) |
|---|---|---|
| Language | PHP 7+ | JavaScript ES6+ |
| Framework | Plain PHP | Express.js 4.x |
| Database | MySQL 5.7 | MongoDB 5.0+ |
| ORM/ODM | PDO | Mongoose 8.x |
| Templating | PHP includes | EJS |
| Sessions | File-based | MongoDB-backed |
| Architecture | Monolithic | MVC pattern |
| API | Basic endpoints | RESTful + rate limiting |
| Security | Basic | Enterprise-grade |
| Performance | Good | Excellent (event-driven) |
| Scalability | Limited | High (horizontal scaling) |
| Real-time | No | Ready (Socket.io compatible) |
| Deployment | cPanel/shared hosting | Cloud-native (Railway, Heroku, VPS) |
β
All features preserved
β
User experience maintained
β
Admin capabilities retained
β
Design language improved but familiar
β
Core logic reimplemented in Node.js
For Developers:
- Single language (JavaScript) for frontend + backend
- Modern async/await syntax
- Rich npm ecosystem (1.8M+ packages)
- Better debugging tools
- Faster development iterations
For Users:
- Faster page loads
- Better performance
- More reliable sessions
- Enhanced security
- Smoother animations
For Business:
- Lower hosting costs (Node.js is efficient)
- Better scalability (horizontal scaling)
- Future-proof (modern stack)
- Mobile app ready (REST API)
- Real-time features possible (WebSockets)
If you encounter issues:
-
Check Documentation
-
Common Issues
- MongoDB not running β Start MongoDB service
- Port in use β Change PORT in
.env - Views not found β Run
node scripts/generate-views.js - Module not found β Run
npm install
-
Debugging
- Check terminal output for errors
- Use
console.log()for debugging - Check MongoDB logs
- Verify
.envconfiguration
-
Production Issues
- Check server logs
- Verify environment variables
- Test MongoDB connection
- Review security headers
Minimum:
- Node.js 16+
- MongoDB 5.0+
- 2GB RAM
- 500MB disk space
Recommended:
- Node.js 18+ (LTS)
- MongoDB 6.0+
- 4GB RAM
- 2GB disk space
- SSD storage
This project is proprietary and private. All rights reserved.
Usage Restrictions:
- No redistribution
- No commercial use without permission
- Source code viewing allowed for licensed users only
Technologies Used:
- Node.js - JavaScript runtime
- Express.js - Web framework
- MongoDB - NoSQL database
- Mongoose - MongoDB ODM
- EJS - Templating engine
- Bootstrap - UI framework
- Font Awesome - Icon library
- Quill.js - Rich text editor
Special Thanks:
- YouTube for design inspiration
- Bootstrap team for excellent documentation
- MongoDB for powerful database
- Node.js community for incredible ecosystem
- Complete PHP to Node.js migration
- Modern design implementation
- Security enhancements
- Admin panel improvements
- Content management system
- Payment gateway integration
- REST API implementation
v2.1 - Enhanced Analytics
- Advanced analytics dashboard
- Export data to CSV/PDF
- Custom date ranges
- Subscriber growth charts
v2.2 - Social Features
- User profiles
- Creator messaging
- Community forums
- Content recommendations
v2.3 - Mobile App
- React Native mobile app
- Push notifications
- Offline mode
- Enhanced API
v2.4 - Automation
- Auto-verification (YouTube API)
- Scheduled reports
- Automated emails
- Smart recommendations
Built with β€οΈ using Node.js, Express.js, MongoDB, and modern web technologies
Successfully migrated from PHP/MySQL to Node.js/MongoDB - January 2026
Version: 2.0
Last Updated: January 2026
Status: Production Ready β