Self-Hosting Guide
You can run your own Watermelon server for complete control over your music streaming backend. This guide covers local development and production deployment.
Prerequisites
- Node.js 18+ or later
- npm, pnpm, or yarn
- Supabase account (free tier works fine)
- (Optional) Telegram Bot Token for bot integration
- (Optional) Razorpay account for premium subscriptions
- yt-dlp binary — The server spawns yt-dlp as a child process
Local Setup
1. Clone the Repository
git clone https://github.com/watermelon-music/Watermelon-apk.git
cd watermelon-api2. Install Dependencies
pnpm install3. Set Up Supabase
- Go to supabase.com and create a new project
- Copy your Project URL and anon/public key
- Create the required tables (users, playlists, favorites, etc.) using the SQL schema in the repo
4. Configure Environment Variables
Create a .env file in the project root:
PORT=3000
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-anon-key
RAZORPAY_KEY_ID=your_razorpay_key_id
RAZORPAY_KEY_SECRET=your_razorpay_key_secret
TELEGRAM_BOT_TOKEN=your_telegram_bot_tokenOnly
SUPABASE_URLandSUPABASE_KEYare required for basic functionality. Razorpay and Telegram are optional.
5. Install yt-dlp
The server needs yt-dlp available in the system PATH:
# macOS/Linux
pip install yt-dlp
# Or download the binary directly
wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O /usr/local/bin/yt-dlp
chmod +x /usr/local/bin/yt-dlp6. Start the Server
pnpm startThe API server will start on http://localhost:3000.
Deploy to Render
Render is the recommended platform for hosting Watermelon.
- Fork the repository on GitHub
- Create a new Web Service on render.com
- Connect your GitHub repository
- Set the build command:
pnpm install - Set the start command:
pnpm start - Add all environment variables from the
.envexample - Click Create Web Service
The server will auto-deploy on every push to your main branch.
Update the Android App
After deploying your server, update the API URL in the Android app:
- Open the project in Android Studio
- Find the
Constants.ktor network configuration file - Change the base URL to your deployed server
- Rebuild and reinstall the APK
Troubleshooting
yt-dlp not found
Make sure yt-dlp is installed and available in the server environment. On Render, you might need to add a custom build script that installs yt-dlp.
Search returns empty results
Check that yt-dlp is working:
yt-dlp --dump-json "ytsearch3:test" | head -c 500Supabase connection errors
Verify your SUPABASE_URL includes https:// and the SUPABASE_KEY is the anon key (not the service role key unless you know what you’re doing).
CORS errors
The Express server should already have CORS configured. If you see CORS errors, make sure the origin in the CORS config matches your Android app’s domain or use * for development.
Credits
Self-hosting Watermelon is possible thanks to generous free tiers from these platforms:
| Service | What it provides | Link |
|---|---|---|
| Render | Free web service hosting | render.com |
| Supabase | Free PostgreSQL database tier | supabase.com |
| GitHub | Source code hosting & releases | github.com |
| yt-dlp | Open-source music extraction engine | github.com/yt-dlp/yt-dlp |
⭐ All of these offer generous free tiers for hobby projects. We recommend upgrading to paid plans as your usage grows.