Skip to content
tracksensefmPublic

About

Web companion for the TrackSense.fm iOS app: listening stats dashboard, live player, and remote playback control across your devices

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

TrackSense Web

Web companion for the TrackSense iOS app. Sign in with a code from the app to get a full dashboard of your listening stats and library, and control playback on any of your devices in real time.

What it does

  • Sign in with a link code. The iOS app generates an 8-character code. Entering it at /auth exchanges it for a Firebase session, no password needed.
  • Dashboard. Library stats, listening history charts, and browsable songs, albums, artists, genres and playlists, each with a detail view.
  • Live playback. A persistent mini player, a full player, and a queue panel that mirror whatever is playing on your active device, synced through Firebase Realtime Database.
  • Remote control. Play, pause, skip, shuffle, repeat and jump around the queue. Commands go to whichever device is active.
  • Devices. See every registered iPhone and browser, and switch which one is playing. The browser itself can play through MusicKit JS once Apple Music is linked.
  • Picture-in-Picture. Pop the player out into a floating window.

The guest share-code flow (/share/:code, a read-only view of someone else's queue) is built but its routes are currently commented out in src/main.tsx.

Stack

  • React 19, React Router 7, TypeScript (strict)
  • Vite with vite-plugin-svgr for SVG icons
  • Tailwind CSS v4, dark purple theme, utility classes only
  • Firebase SDK v12: Auth, Realtime Database, Storage, Functions, Analytics
  • MusicKit JS v3 for Apple Music playback and catalog data
  • Recharts for stats charts
  • Firebase Hosting, SPA with a catch-all rewrite

Getting started

npm install

Create .env.local:

VITE_VALIDATE_AUTH_URL=<validateAuthCode Cloud Function URL>
VITE_VALIDATE_CODE_URL=<validateShareCode Cloud Function URL>
npm run dev       # localhost:5173

Commands

npm run dev       # Start dev server
npm run build     # Type-check + production build → dist/
npm run lint      # ESLint
npm run preview   # Preview the production build locally
npm run deploy    # Build + deploy to Firebase Hosting (site: tracksense)

Routes

Path View
/auth Code sign-in
/stats Listening stats
/library Library overview
/songs, /songs/i/:id Songs, library song detail
/songs/c/:id Catalog song detail
/albums, /albums/l/:id Albums, album detail
/artists Artists
/genres Genre breakdown
/playlists/p/:id Playlist detail
/account Account and profile

Everything except /auth is nested under DashboardPage, which redirects signed-out users to /auth.

Project structure

src/
  main.tsx                # Router and all routes
  firebase.ts             # Firebase init; ensureSignedIn() / getIdToken() for authenticated function calls
  views/
    AuthPage.tsx          # 8-character code sign-in
    App.tsx, SharePage.tsx  # Guest share-code flow (routes disabled)
    dashboard/
      DashboardPage.tsx   # Shell: sidebar, players, auth guard, data wiring
      shared.tsx          # Shared Stats + DashboardContext types
      StatsView, LibraryView, SongsView, SongDetailView, CatalogSongView,
      AlbumsView, AlbumDetailView, ArtistsView, GenresView,
      PlaylistDetailView, AccountView
  components/
    MiniPlayer.tsx        # Bottom now-playing bar
    FullPlayer.tsx        # Full player sidebar
    QueueView.tsx         # Queue sidebar
    DevicesSheet.tsx      # Device list and switcher
    PiPPlayer.tsx         # Picture-in-Picture player
    useQueueData.ts       # Session/playback listeners and command dispatch
    useWebPlayback.ts     # Browser playback and claiming the active device
    usePiP.ts, useSmoothTime.ts
    ui/, musicItems/      # Shared UI pieces
  lib/
    musickit.ts           # MusicKit JS setup
    songCache.ts, albumCache.ts

Data flow

  1. The user enters a code on /auth. VITE_VALIDATE_AUTH_URL (validateAuthCode) returns a Firebase custom token, and signInWithCustomToken signs them in.
  2. DashboardPage opens Realtime Database listeners under users/{uid}/.
  3. Playback controls write to users/{uid}/command. The active device carries out the command and updates session and playback, which flows back to every listener.
  4. Cloud Functions that need auth (getMusicToken, getCredits, validateShareCode) are called with Authorization: Bearer <Firebase ID token>.

Realtime Database paths

All under users/{uid}/:

Path Contents
session queueIDs, queueMeta (keyed by song ID), currentSongID, shuffleMode, repeatMode
playback isPlaying, playbackTime, playbackTimestamp, activeDevice, audioOutput
command { action, issuedAt, issuerID } for the active device
devices Registered iOS and web devices (type, name, model, lastSeen)
libraryPlayedHours, songsCount, albumsCount, artistsCount, totalPlays Library stats, each under /value
profile/username Username

The avatar is read from Firebase Storage at users/{uid}/profile/avatar.jpg. The iOS app still writes the legacy queue path, but this app no longer reads it.

Firebase

  • Project: resonate-ra
  • Hosting site: tracksense
  • Cloud Functions and database rules live in the separate ../firebase/ repo.

License

See LICENSE.

About

Web companion for the TrackSense.fm iOS app: listening stats dashboard, live player, and remote playback control across your devices

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages