How pedguedes090/api-vip works
Project Type and Purpose
• This is a backend‐focused, full‐stack-ish Node.js microservice exposing a RESTful API to download and process social‐media videos.
• Its core purpose is to accept video URLs (Facebook, Instagram, Threads, TikTok), fetch media, generate thumbnails, store them briefly in a local filesystem, and serve download links.
File Structure
• Top‐level files:
• server.js – the Express application entrypoint
• index.html – a simple static UI or test‐page (served from public)
• package.json / package-lock.json – dependency management
• Directories:
• module/ – per‐platform downloader modules (facebook.js, instagram.js, threads.js, tiktok.js)
• downloads/ – temporary storage for raw videos and thumbnails (subfolders for each platform)
• No explicit “routes” directory: routes are defined in server.js.
• No database—storage is purely filesystem based.
• Configuration via environment variables (PORT).
Readme Insights
• Exposes endpoints under /api: /media-info, /download, /platforms, /validate-url.
• Automatic cleanup after 5 minutes.
• Error handling for invalid/unsupported URLs and filesystem failures.
Components
a. Main Components
1. API Gateway (Express server in server.js)
2. Platform Handler Modules (facebook.js, instagram.js, threads.js, tiktok.js)
3. Filesystem Storage (downloads/ directory)
4. Cleanup Scheduler (timer in server.js performing 5-minute purges)
5. Client (could be index.html or external API consumers)
6. External Services (social‐media platforms’ video hosting endpoints)
b. Relationships and Interactions
• Client → sends HTTP request → API Gateway
• API Gateway → invokes Platform Handler → calls External Service
• Platform Handler → writes video + thumbnail → Filesystem Storage
• API Gateway → responds with download URLs pointing to Filesystem
• Cleanup Scheduler → periodically deletes old files from Filesystem
c. Architectural Patterns / Principles
• Modular design: one handler per platform → plug-and-play extensibility
• Single Node.js process runs API + scheduler
• Stateless request handling; persistence in local FS only (ephemeral)
d. Key Technologies
• Node.js & Express
• Native fs module for file I/O
• cron or setInterval for cleanup
• npm modules for HTTP requests and media processing (e.g., axios, ffmpeg wrappers)
Essential Detail Checklist
• Four platform modules as separate components feeding into the same API layer.
• Ephemeral nature of the downloads directory and its 5-minute TTL.
• Error handling paths (e.g., invalid URL → error response).