Chat / README.md
kishankrish19's picture
Deploy Stillwave fullstack clean
b0798af
|
Raw History Blame Contribute Delete
9.06 kB
---
title: Stillwave
emoji: 🎵
colorFrom: indigo
colorTo: purple
sdk: docker
app_port: 7860
pinned: false
---
# Stillwave
A NestJS + Next.js music application with a private upload library, an authenticated Hugging Face catalog, encrypted cloud backups, and a calm listening interface.
## Run locally
Requires **Node.js 24.5+** (the backend uses `node:sqlite`). Install with `npm ci` in `backend` and `frontend`.
In the backend directory:
```powershell
# Copy .env.example to .env only when .env does not already exist.
npm run build
npm run start:prod
```
In a second terminal, in the frontend directory:
```powershell
npm run build
npm run start -- --hostname 127.0.0.1
```
Open **http://127.0.0.1:3000**. The frontend proxies `/api/v1` to `http://127.0.0.1:5000`; set `API_PROXY_TARGET` before building if the backend address changes. Use `NEXT_PUBLIC_API_URL=/api/v1` in `frontend/.env.local`. For development, use `npm run start:dev` in the backend and `npm run dev` in the frontend.
On Windows, after building both apps, run `./Start-Stillwave.ps1` from the project root to start both servers in the background with log files in `.runtime-tmp`. It does not replace processes already using the ports. The servers need to be started again after restarting Windows.
Your existing accounts and uploads are preserved in `backend/data/stillwave.sqlite`. The first development signup becomes an administrator. Production signups are listeners; promote an existing account locally with `npm run admin -- account@example.com` after building. No default password exists.
## Your Hugging Face library
`HF_LIBRARY_REPO=kishankrish19/mySongs` is the read-only source for the existing public MP3 library. No catalog request happens on an anonymous visit. After a session is validated, the browser requests synchronization; the backend paginates the repository tree and saves file identities with their revision. Metadata is read in bounded ranges, four files at a time, with retry/backoff. Playback is served through authenticated, expiring backend links with HTTP seeking support.
The initial scan on September 29, 2026 found **488 MP3s**, plus `.gitattributes`, `catalog.csv`, and `downloaded_tracker.json`. Imported metadata and artwork persist across restarts. Opening a song's details retries unavailable metadata. Existing public MP3s remain public in their original repository; the application does not pretend to make those originals private.
On this Windows machine, Node's automatic address-family selection caused intermittent Hugging Face connection timeouts. The backend prefers IPv4 on Windows without changing system networking. Set `PREFER_IPV4=false` to opt out.
## Uploads and storage
- Select individual files, multiple files, a folder, or drag and drop nested folders.
- Files below **10,000,000 bytes** start automatically; files at or above that size wait for confirmation. The optional speed estimate sends a random sample, not the selected song.
- Transfers use resumable 1 MiB chunks, two concurrent files, progress/speed/time estimates, and server-side quotas. After reopening the browser, reselect the original file and resume it.
- The server checks actual audio, extracts tags, deduplicates within the user's library, encrypts the complete file with authenticated AES-256-GCM chunks, and creates a persistent Hugging Face backup job.
- **Ready to listen** means safely received and processed locally. **Verified on Hugging Face** means the encrypted cloud object was uploaded and its complete checksum verified. These are distinct states.
- Administrators can add multiple existing HF datasets and write tokens in **Settings → Storage administration**, change priority, pause/enable an account, test connectivity, and retry failed jobs. Tokens are encrypted and are never returned by the API.
- Temporary upload errors retry with backoff and can fall through to the next configured account. HTTP 429 pauses the attempt instead of immediately hopping tokens to evade rate limits. After eight job attempts, manual retry is available.
- A bounded local cache evicts only objects with a verified remote copy. Pending backups always remain local. A fallback account is an alternate upload destination; it is not automatic mirroring of every file.
- Removing an upload deletes its playback key from the active database; encrypted remote objects and old database backups may remain. Repository storage reclamation is a separate operator task.
New encrypted objects use opaque `.enc` paths. The dataset contains no decryption keys, song titles, or user IDs for those objects. The server decrypts only after authentication. This protects ciphertext at rest; it cannot prevent an authorized listener from recording playable audio.
HF's actual storage allowance and acceptable dataset use are controlled by the provider, not an assumed 8 TB entitlement. See [Hugging Face storage guidance](https://huggingface.co/docs/hub/storage-limits).
## Metadata and listening
Song menus include **Song details & lyrics**. The listening-room page also displays embedded artwork, artists, album/album artist, year/date, composer, genre, track/disc numbers, label, copyright, ISRC, and available codec/bitrate/sample-rate/channel information. Embedded plain and synchronized lyrics are supported; millisecond synchronized lyrics highlight during playback. Missing tags are identified as missing rather than invented. Some existing uploaded files are untagged AAC/M4A audio, so they have no embedded cover or lyrics to extract.
Songs display live cloud symbols in lists, artwork grids, the queue, and the player. A checked cloud means the encrypted backup was verified; an upload cloud means queued or uploading; a crossed cloud means backups are paused; an alert means the upload failed; a disk means server storage only. The connected public dataset has its own cloud symbol. Hover for an explanation, or open song details for a text label. Upload progress reaching “Ready to listen” does not mean its cloud backup has finished.
Metadata repair reads the complete decrypted byte stream, including M4A tags stored after the audio. Older scans are repaired after sign-in or when opening song details; manually edited fields are preserved. Cover requests retry temporary failures, and missing embedded pictures remain labeled placeholders. The activity endpoint and artwork remain restricted to songs the signed-in listener can access.
Suggestions use listening time, completion, recent history, favorites, artist/genre affinity, exploration preference, and artist diversity. On-repeat ranking decays over time and counts meaningful listens; automatic plays receive less weight. Users can suppress songs from suggestions, block autoplay, control shuffle/repeat, manage playlists, clear history, and export their library metadata.
## Downloader and deployment boundaries
The optional catalog search uses the existing Supabase catalog when `CATALOG_SUPABASE_ENABLED=true`. On-demand download jobs require `DOWNLOADS_ENABLED=true`, an installed [yt-dlp](https://github.com/yt-dlp/yt-dlp/wiki/Installation), and FFmpeg. `SPOTDL_PATH` enables the fallback executable. Configure `YTDLP_PATH`, `FFMPEG_PATH`, and an authorized `YTDLP_PROXY` as needed. Each job has its own working directory and uses argument-based execution; the old shell-based downloader is no longer registered. External download tools are not installed by this change.
Run **one backend instance** with persistent disk. SQLite, local file locks, queues, and key files are not a distributed storage design. Before a large multi-user/8 TB deployment, move high-volume metadata queries and job coordination to an indexed database/worker system and load-test the actual provider/bandwidth. Email recovery and social login remain explicitly unconfigured.
Production requires `AUDIO_MASTER_KEY` and `SESSION_SIGNING_KEY` as distinct 64-character hex secrets, HTTPS, restricted CORS, and backups of the database **and encryption keys**. Back up SQLite using its backup API or stop the backend before copying the database/WAL files. Losing the audio master key makes encrypted songs unrecoverable. Never commit `.env`, keys, or the data directory. Rotate any credentials that existed in the old source before deployment.
## Verification
```powershell
# backend
npm run test:integration
npm test -- --runInBand
# frontend
npm run lint
npm run build
```
The integration tests use an isolated temporary database and generated audio. They cover authentication, ownership, upload offsets/consent/quotas, encryption/tamper rejection, seeking, retries/failover, playlists, listening signals, ID3 artwork/lyrics, and logout revocation.
With both servers running, `node scripts/verify-live.cjs` from `backend` checks authentication through the frontend proxy and real Hugging Face metadata, artwork, playback, seeking, and logout. It creates and removes only its own temporary listener account, performs no cloud writes, and saves the result in `verification/live-check.json`.