How marco-vanin/betterhit works
BetterHit is a mobile-first web app for scanning Hitster QR codes and identifying songs. Its main workflow loads a local song database, scans a QR code, parses its URL, looks up the song, and displays the result with optional details and a short YouTube preview. The graph follows the sampled app and component calls; the README documents scanning and identification, while the song database path is confirmed by the hook. Other unsampled wiring is omitted.
Main entry points: App.tsx App state and orchestration · useSongsDatabase.ts Song database lookup · useQRScanner.ts QR scanner lifecycle · MusicPlayer.tsx Music player
Components 17
App flow
- React entry
src/main.tsx - App state and orchestration
src/App.tsx - Welcome screen
src/components/Welcome.tsx - Error display
src/components/ErrorDisplay.tsx
QR scanning
- Scanner view
src/components/Scanner.tsx - QR scanner lifecycle
src/hooks/useQRScanner.ts
Song lookup
- QR URL parser
src/utils/hitster.ts - Song database lookup
src/hooks/useSongsDatabase.ts - French song database
public/songs/french/summer-party.json - App configuration
src/config/constants.ts - Scan logic hook
src/hooks/useScanLogic.ts
Results and playback
- Song result view
src/components/Result.tsx - Music player
src/components/MusicPlayer.tsx - YouTube URL parser
src/utils/youtube.ts
Other components
- User
- Device camera
- YouTube player service
Connections 19
- User → React entry: opens app
src/main.tsx - React entry → App state and orchestration: renders
src/main.tsx - App state and orchestration → Song database lookup: loads lookup
src/App.tsx - Song database lookup → App configuration: reads path
src/hooks/useSongsDatabase.ts - Song database lookup → French song database: fetches data
src/hooks/useSongsDatabase.ts - App state and orchestration → QR scanner lifecycle: starts scanner
src/App.tsx - QR scanner lifecycle → Device camera: requests access
src/hooks/useQRScanner.ts - QR scanner lifecycle → App state and orchestration: calls scan callback
src/hooks/useQRScanner.ts - App state and orchestration → QR URL parser: parses scanned URL
src/App.tsx - App state and orchestration → Song database lookup: looks up song
src/App.tsx - App state and orchestration → Welcome screen: renders welcome
src/App.tsx - Welcome screen → Error display: renders errors
src/components/Welcome.tsx - App state and orchestration → Scanner view: renders scanner
src/App.tsx - App state and orchestration → Song result view: renders result
src/App.tsx - Song result view → Music player: renders player
src/components/Result.tsx - Music player → YouTube URL parser: extracts video ID
src/components/MusicPlayer.tsx - Music player → YouTube player service: loads player API
src/components/MusicPlayer.tsx - Scan logic hook → Song database lookup: uses lookup
src/hooks/useScanLogic.ts - Scan logic hook → QR URL parser: parses URL
src/hooks/useScanLogic.ts