How aaronhubhachen/spotify-fortune-cookie works
Spotify Fortune Cookie lets a user sign in with Spotify, request a daily fortune derived from listening history, and view the fortune with its selected track. The page caches the daily result in browser storage; the API fetches recent and top tracks, normalizes a selected track, and builds the fortune. The README also describes responsive dark-mode UI and secure authentication. Source excerpts confirm the main page, authentication, and fortune API wiring; other presentation details are documented but not independently inspected.
Main entry points: page.tsx Home page · route.ts Fortune endpoint · auth.config.ts Spotify auth config · layout.tsx Root layout
Components 13
Web experience
- Home page
app/page.tsx - Fortune display
components/FortuneDisplay.tsx - Page layout
components/Layout.tsx - Root layout
app/layout.tsx - Browser local storage
Spotify authentication
- Session provider
components/SessionProvider.tsx - Auth handler
app/api/auth/[...nextauth]/route.ts - Spotify auth config
app/api/auth/auth.config.ts
Fortune generation
- Fortune endpoint
app/api/fortune/route.ts - Listening history fetch
app/api/fortune/route.ts - Track selection and fortune
app/api/fortune/route.ts
Other components
- User
- Spotify services
Connections 16
- User → Home page: uses
- Home page → Session provider: reads session
- Home page → Auth handler: signs in or out
- Root layout → Session provider: provides session
- Root layout → Home page: renders
- Home page → Page layout: renders within
- Home page → Fortune display: passes fortune
- Home page → Browser local storage: reads and writes
- Auth handler → Spotify auth config: configures handler
- Spotify auth config → Spotify services: authorizes account
- Home page → Fortune endpoint: requests fortune
- Fortune endpoint → Spotify auth config: gets session
- Fortune endpoint → Listening history fetch: fetches listening data
- Listening history fetch → Spotify services: requests recent and top tracks
- Fortune endpoint → Track selection and fortune: generates fortune
- Track selection and fortune → Fortune endpoint: returns result