Skip to content

Commit 9be8ae3

Browse files
committed
Initial commit for v1.0.0
0 parents  commit 9be8ae3

34 files changed

+1347
-0
lines changed

.env.example

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# .env.local
2+
# Environment variables for the Jukebox application
3+
4+
# Server port
5+
PORT=4000
6+
7+
# Relative path to the music folder from the project root
8+
MUSIC_FOLDER=music
9+
10+
# Database filename (LokiJS)
11+
DB_FILENAME=jukebox.db.json
12+
13+
# Number of days for stats graph
14+
STATS_DAYS=7
15+
16+
# --- Optional ---
17+
# Playlist title prefix to remove (client-side display only currently)
18+
# Leave empty if no prefix removal is needed in JS
19+
# PLAYLIST_PREFIX_FILTER="^Tuesday Boys\s+"

.gitignore

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Node.js dependencies
2+
node_modules/
3+
4+
# Logs
5+
logs
6+
*.log
7+
npm-debug.log*
8+
yarn-debug.log*
9+
yarn-error.log*
10+
pnpm-debug.log*
11+
lerna-debug.log*
12+
pnpm-lock.yaml
13+
14+
# Diagnostic reports (https://nodejs.org/api/report.html)
15+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
16+
17+
# Runtime data - LokiJS database
18+
# Use the name defined in .env.local if changed from default
19+
jukebox.db.json
20+
21+
# Optional eslint cache
22+
.eslintcache
23+
24+
# Optional REPL history
25+
.node_repl_history
26+
27+
# Output of 'npm pack'
28+
*.tgz
29+
30+
# Yarn Integrity file
31+
.yarn-integrity
32+
33+
# dotenv environment variables files
34+
# Add variations if you use them (e.g., .env.production)
35+
.env
36+
.env.*.local
37+
.env.local
38+
.env.development.local
39+
.env.test.local
40+
.env.production.local
41+
42+
# macOS specific files
43+
.DS_Store
44+
45+
# Windows specific files
46+
Thumbs.db
47+
48+
# IDE specific files
49+
.idea/
50+
.vscode/
51+
52+
# Optional build/dist output directory (if you add a build step later)
53+
dist/
54+
build/

README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# JukeBox 🎵
2+
3+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4+
[![Status: Active](https://img.shields.io/badge/status-active-success.svg)]()
5+
[![Built with: Node.js](https://img.shields.io/badge/Built%20with-Node.js-339933?logo=nodedotjs)](https://nodejs.org/)
6+
[![Database: LokiJS](https://img.shields.io/badge/Database-LokiJS-lightgrey)](https://lokijs.org/)
7+
8+
A sleek, web-based music player designed to dynamically load and play your local MP3 collection, featuring audio visualization, play/download count tracking, and usage statistics. Built with Node.js, Express, and LokiJS.
9+
10+
![Jukebox Screenshot](jukebox_screenshot.png)
11+
*(Screenshot of the running application)*
12+
13+
---
14+
15+
## ✨ Features
16+
17+
* **Dynamic Playlist:** Automatically scans a local `music` folder on the server for `.mp3` files on startup.
18+
* **Play/Download Count Tracking:** Records plays (past 50%) and downloads in a local LokiJS database (`jukebox.db.json`).
19+
* **Sorted Playlist:** Displays the playlist sorted by play count (most played first), with secondary alphabetical sorting.
20+
* **Usage Statistics:** In-app modal shows total visits, detailed track plays/downloads, and daily activity charts (visits/plays/downloads over last 14 days).
21+
* **Sleek UI:** Modern interface with controls for play/pause, previous/next, seek, volume, and play mode (repeat all/one, shuffle).
22+
* **Audio Visualization:** Real-time canvas-based visualization with multiple styles (Bars, Blocks, Waveform).
23+
* **Grid Playlist Display:** Visually appealing grid layout for the playlist with icons and play counts.
24+
* **Server-Side Logic:** Uses Node.js and Express to serve the application and handle API requests.
25+
* **Embedded DB:** Uses LokiJS (in-memory with file persistence) - no native dependencies required for the database.
26+
27+
## 🎶 Music Credits & Licensing
28+
29+
The music files used in the `music/` directory for demonstration are **license-free**. They were generated using the AI music creation platform [Suno.ai](https://www.suno.ai/).
30+
31+
## 💻 Tech Stack
32+
33+
* **Backend:** Node.js, Express.js
34+
* **Database:** LokiJS (`lokijs` npm package)
35+
* **Frontend:** HTML5, CSS3, JavaScript (ES6+), Chart.js
36+
* **Package Manager:** pnpm (Recommended, but npm/yarn work too)
37+
* **Icons:** Font Awesome
38+
39+
## 🚀 Setup & Installation
40+
41+
1. **Prerequisites:**
42+
* [Node.js](https://nodejs.org/) (LTS version recommended) installed.
43+
* [pnpm](https://pnpm.io/installation) installed globally (`npm install -g pnpm`).
44+
* `git` installed.
45+
46+
2. **Clone the Repository (Optional):**
47+
```bash
48+
git clone <your-repo-url>
49+
cd <project-folder-name>
50+
```
51+
52+
3. **Install Dependencies:** Navigate to the project directory in your terminal and run:
53+
```bash
54+
pnpm install
55+
```
56+
57+
4. **Configure Environment:**
58+
* Copy or rename `.env.local.example` (if provided) or create a new file named `.env.local`.
59+
* Edit `.env.local` to set your desired `PORT`, `MUSIC_FOLDER` (relative path), `DB_FILENAME`, and `STATS_DAYS`. Example:
60+
```dotenv
61+
PORT=4000
62+
MUSIC_FOLDER=music
63+
DB_FILENAME=jukebox.db.json
64+
STATS_DAYS=7
65+
```
66+
67+
5. **Add Music:**
68+
* Create the folder specified by `MUSIC_FOLDER` in `.env.local` (e.g., `music`).
69+
* Place your `.mp3` files inside that folder.
70+
71+
## ▶️ Running the App
72+
73+
1. **Start the Server:**
74+
```bash
75+
pnpm start
76+
```
77+
This reads `.env.local`, starts the Node.js server, and creates/updates the LokiJS database file specified by `DB_FILENAME`.
78+
79+
2. **Access the Jukebox:** Open your web browser and navigate to:
80+
```
81+
http://localhost:4000
82+
```
83+
*(Replace `4000` if you changed the `PORT` in `.env.local`. Use your server IP if not running locally)*
84+
85+
The player should load, fetch the sorted playlist, track plays/downloads/visits, and display stats in the modal.
86+
87+
## ⚙️ Configuration
88+
89+
See the `.env.local` file for configurable options:
90+
91+
* `PORT`: Network port the server listens on.
92+
* `MUSIC_FOLDER`: Path (relative to project root) containing `.mp3` files.
93+
* `DB_FILENAME`: Filename for the LokiJS database persistence.
94+
* `STATS_DAYS`: Number of past days to include in the stats graph (e.g., 7).
95+
96+
## 📄 License
97+
98+
This project is licensed under the **MIT License**. See the [LICENSE](https://opensource.org/licenses/MIT) file or badge link for details.
99+
100+
---
101+
102+
## 🤖 Development Note
103+
104+
All the code in this project was generated by **Google Gemini 2.5 Pro Experimental 03-25** based directly on iterative prompts provided by the user. The entire functional application, including setup, server logic, dynamic playlist loading, database integration (LokiJS), stats tracking and display (including charts), client-side controls, and visualization, was produced through interactive prompting over ~2 hours.

android-chrome-192x192.png

9.03 KB
Loading

android-chrome-512x512.png

17.9 KB
Loading

apple-touch-icon.png

8.18 KB
Loading

favicon-16x16.png

390 Bytes
Loading

favicon-32x32.png

911 Bytes
Loading

favicon.ico

15 KB
Binary file not shown.

index.html

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>JukeBox</title> <!-- User's Title -->
7+
<link rel="stylesheet" href="style.css">
8+
<!-- Using full FA link -->
9+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
10+
11+
<!-- User's Favicon / App Icon links -->
12+
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
13+
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
14+
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
15+
<link rel="manifest" href="/site.webmanifest">
16+
</head>
17+
<body>
18+
<div class="music-player">
19+
20+
<!-- Player Header -->
21+
<div class="player-header">
22+
<a id="download-link" href="#" download title="Download current track">
23+
<i class="fas fa-download header-icon"></i>
24+
</a>
25+
<span id="current-track-title">Loading Playlist...</span>
26+
<div class="header-controls">
27+
<select id="viz-style-selector" title="Visualization Style">
28+
<option value="bars">Bars</option>
29+
<option value="bars_blocks">Blocks</option>
30+
<option value="waveform">Waveform</option>
31+
</select>
32+
<button id="stats-icon-btn" class="icon-button" title="View Stats">
33+
<i class="fas fa-chart-line header-icon"></i>
34+
</button>
35+
</div>
36+
</div>
37+
38+
<!-- Visualization Container -->
39+
<div class="visualization-container">
40+
<canvas id="visualizer-canvas"></canvas>
41+
</div>
42+
43+
<audio id="audio-player" preload="metadata"></audio>
44+
45+
<!-- Controls Section -->
46+
<div class="controls">
47+
<button id="prev-btn" title="Previous" disabled><i class="fas fa-backward-step"></i></button>
48+
<button id="play-pause-btn" title="Play/Pause" disabled><i class="fas fa-play"></i></button>
49+
<button id="next-btn" title="Next" disabled><i class="fas fa-forward-step"></i></button>
50+
<span id="time-indicator">0:00 / 0:00</span>
51+
<input type="range" id="seek-bar" value="0" step="0.1" title="Seek" disabled>
52+
<button id="volume-icon" title="Mute/Unmute"><i class="fas fa-volume-up"></i></button>
53+
<input type="range" id="volume-bar" min="0" max="1" step="0.01" value="1" title="Volume">
54+
<button id="play-mode-btn" title="Repeat All"><i class="fas fa-repeat"></i></button>
55+
</div>
56+
57+
<!-- Playlist Section -->
58+
<div class="playlist-container">
59+
<h3>Playlist</h3>
60+
<div id="playlist" class="playlist-grid">
61+
<div class="playlist-item-loading">Loading...</div>
62+
</div>
63+
</div>
64+
65+
</div>
66+
67+
<!-- Stats Modal Structure -->
68+
<div id="stats-modal-overlay" class="modal-overlay hidden">
69+
<div id="stats-modal-content" class="modal-content stats-container">
70+
<button id="modal-close-btn" class="modal-close-btn">×</button>
71+
<h1>Jukebox Statistics</h1>
72+
<div class="stats-summary">
73+
<h2>Summary</h2>
74+
<p>Total Page Visits: <strong id="total-visits">Loading...</strong></p>
75+
</div>
76+
<h2>Track Plays & Downloads</h2>
77+
<div style="max-height: 30vh; overflow-y: auto; margin-bottom: 20px;">
78+
<table id="stats-table">
79+
<thead> <tr><th>Track</th><th>Plays</th><th>Downloads</th></tr> </thead>
80+
<tbody id="stats-table-body"><tr><td colspan="3">Loading...</td></tr></tbody>
81+
</table>
82+
</div>
83+
<h2>Activity (Last <span id="stats-days-display">7</span> Days)</h2>
84+
<div class="stats-chart-container">
85+
<canvas id="activityChart"></canvas>
86+
<!-- Placeholder text removed -->
87+
</div>
88+
</div>
89+
</div>
90+
91+
<!-- Chart.js Library -->
92+
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.1/dist/chart.umd.min.js"></script>
93+
<!-- Player Client-side JavaScript -->
94+
<script src="script.js"></script>
95+
</body>
96+
</html>

0 commit comments

Comments
 (0)