Jukebar is a Node.js jukebox application that integrates with Spotify and Formbar, allowing users to search for and play music by making payments with their Digipogs.
- Spotify Integration: Search and play music directly from Spotify
- Authentication: Secure login system with JWT tokens from Formbar accounts
- Payment System: Integrated with Formbar Digipogs for song purchases and skip shields
- Skip Shield System: Purchase shields (25 Digipogs) to protect your songs from being skipped (100 Digipogs cost)
- Anonymous Mode: Add songs anonymously without tracking to your play count
- Queue Management: Real-time queue synchronization with shield protection display
- Skip Protection Sound Effects: Random audio feedback when shields block skip attempts (Raspberry Pi compatible)
- Real-time Updates: WebSocket-based live updates for queue, playback state, and currently playing
- User Management: SQLite database for user data, PIN storage, and queue metadata
- Leaderboard: Track top contributors based on songs played
- Transaction Logging: Complete audit trail of all Digipog transactions
- Session Management: Secure session handling with Express
Before running this application, ensure you have:
- Node.js (version 14 or higher)
- A Spotify Premium account
- Spotify application registered with Spotify for Developers
- Access to Formbar API for payment processing
- A device with Spotify open and active for playback
- Optional: omxplayer installed (for Raspberry Pi audio playback of shield block sound effects)
- Clone the repository:
git clone <repository-url>
cd Jukebar- Install dependencies:
npm install- Create a
.envfile in the root directory with the following variables:
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
SPOTIFY_REFRESH_TOKEN=your_spotify_refresh_token
FORMBAR_ADDRESS=https://your-formbar-instance.com
PUBLIC_KEY=your_formbar_public_key
API_KEY=your_formbar_api_key- Create the database directory:
mkdir db- Optional: Create the sound effects directory for skip shield blocked sounds:
mkdir public/sfxAdd .wav or .mp3 audio files to this directory for random playback when skips are blocked.
- Go to Spotify for Developers
- Create a new application
- Note down your Client ID and Client Secret
- Set up the redirect URI in your Spotify app settings
- Generate a refresh token for your Spotify account
The application integrates with Formbar for user authentication and payment processing. Ensure you have:
- Valid Formbar API credentials
- Public key for JWT verification
- Access to the Digipogs payment system
-
Start Formbar (either run a local instance or connect to formbeta.yorktechapps.com):
- For local development: Follow the Formbar setup instructions on the Formbar.js Wiki on starting your own version of formbar
- For testing: Use the public instance at
formbeta.yorktechapps.com
-
Start the application:
node app.js-
Navigate to
http://localhost:3000in your web browser -
Log in through the Formbar authentication system
-
Search for songs using the search interface
-
Make a payment through Digipogs to unlock song playback (75 Digipogs per song, 100 Digipogs per skip)
-
Optional: Purchase skip shields (25 Digipogs) to protect your songs from being skipped
-
Add songs to the Spotify queue or play them directly
-
Toggle anonymous mode to add songs without tracking to your play count
- Purchase shields for 25 Digipogs per song to protect it from skips
- When someone attempts to skip a shielded song (costs 100 Digipogs), the shield is consumed instead
- Shield count is displayed on each queue item with a 🛡️ badge
- Random sound effects play when shields block skip attempts (requires audio files in
/public/sfx/)
- Toggle the anonymous checkbox when adding songs
- Songs added anonymously don't increment your
songsPlayedcount on the leaderboard - Still costs the same amount of Digipogs
- Queue and currently playing track update simultaneously via WebSocket
- Progress bar shows real-time playback position
- All users see updates instantly when songs are added, skipped, or shields are purchased
- express: Web application framework
- express-session: Session middleware
- ejs: Template engine for views
- spotify-web-api-node: Spotify Web API wrapper
- socket.io: Real-time WebSocket communication
- sqlite3: SQLite database driver
- jsonwebtoken: JWT token handling
- dotenv: Environment variable management
- users: User accounts with Formbar IDs, Digipog balances, and play counts
- queue_metadata: Track metadata including who added songs, skip shield counts, and anonymous mode flags
- transactions: Complete audit log of all Digipog transactions (plays, skips, shield purchases)
GET /auth- Formbar authentication redirectGET /callback- Formbar OAuth callbackPOST /logout- End user session
POST /addToQueue- Add a song to the Spotify queuePOST /skip- Skip the currently playing trackPOST /purchaseShield- Purchase a skip shield for a specific track
POST /payment/transfer- Process Digipog payment for songs, skips, or shieldsGET /payment/getAmount- Get the cost for a specific action
GET /api/leaderboard- Fetch the top users by songs playedGET /api/queueHistory- View transaction history (teacher access only)
Contributions are welcome! Please ensure all console logs are emoji-free for Raspberry Pi compatibility.
This project is for educational purposes as part of the York Tech Apps ecosystem.