How krex381/youtube-sub-checker works
Project type and purpose
• This is a full-stack Node.js application combining a Discord bot with a lightweight web interface to verify YouTube channel subscriptions.
• Purpose: guide Discord users through a screenshot-based verification process, detect fraud via OCR and watermarks, then assign roles in a Discord guild.
File structure
• Top-level files:
– server.js: Express server entry point
– discord-bot.js: Discord.js bot logic
– config.json & banned-users.json: runtime configuration and simple JSON datastore
– translations.json: i18n support
– package.json / package-lock.json: dependencies and scripts
• Directories:
– frontend/: static web UI (HTML, CSS, JS) served by Express
– utils/: core modules (youtube API integration, watermark detection)
– watermarks/: watermark images or reference assets
• No separate “database” directory: simple JSON files are used for storage.
README for additional insights
• Tech stack: Node.js v16+, Discord.js, YouTube Data API v3, OCR (e.g., Tesseract)
• Key features: screenshot watermark detection, anti-fraud measures, secure token system, real-time processing
• Commands: /verify, /setup, /watermark
How to represent this architecture
a. Main components
– Discord Bot Service (discord-bot.js)
– Web Server (server.js + Express)
– Frontend UI (frontend/index.html, script.js, style.css)
– OCR & Watermark Detection Module (utils/youtube.js, utils/watermarks)
– JSON Data Store (config.json, banned-users.json, translations.json)
– External Services: Discord API, YouTube Data API, OCR engine
b. Relationships & data flow
1. User invokes /verify in Discord → Discord Bot generates a secure token → replies with a verification link to Web UI
2. User opens Web UI → frontend collects screenshot and token → POST to Web Server
3. Web Server validates token → invokes OCR & watermark detection → queries YouTube Data API to confirm subscription → updates banned-users.json or assigns a Discord role
4. On success: Web Server calls Discord API via the Bot Service to assign “subscribed” role
c. Architectural patterns & design principles
– Event-driven design: Discord webhook events trigger workflows
– Modular design: utility modules isolated under utils/ for YouTube and watermark logic
– Separation of concerns: frontend static assets vs. backend API
– Secure token pattern: one-time tokens stored in memory or JSON for session management
d. Key technologies & frameworks
– Node.js + Express for backend
– discord.js for bot interactions
– YouTube Data API v3 for subscription checks
– OCR library (e.g., Tesseract.js) for text detection
– JSON files as a lightweight datastore
Detail
• Every module under utils/ to show where business logic resides
• Token generation & validation step as a discrete component