Webapp Architecture β
The TuneCamp webapp is a modern Single Page Application (SPA) built with React and Vite, optimized for the music user experience and decentralized interaction.
Tech Stack β
- UI Framework: React (TypeScript)
- Build Tool: Vite
- State Management: Zustand
- Routing: React Router
- Instance Discovery: HTTP Gossip REST API
- Wallet: Ethers.js v6 (EIP-1193 injected provider, e.g., MetaMask)
Code Organization β
1. Components (components/) β
Organized by functional domain:
player/: The global music player, handles playback state, queue, and waveform display.artist/,auth/,admin/: Specific components for different areas of the application.ui/: Atomic and reusable components (buttons, inputs, loaders).
2. Pages (pages/) β
Each file represents a main route:
Home.tsx: Main dashboard.Albums.tsx/Artists.tsx: Library browsing.Admin.tsx: Management panel for the server administrator.Network.tsx: View of the federated network.
3. State Stores (stores/) β
We use Zustand for lightweight and high-performance state:
usePlayerStore: Current playback state (queue, active track).useAuthStore: Logged-in user state and JWT token.useWalletStore: Connected wallet state (account, network).useConfigStore: Instance configuration (branding, feature flags).useUIStore: Interface state (modals, panels).useDigStore: State of "Dig" mode (crate digging / music discovery).
4. Services (services/) β
api.ts: Wrapper for REST calls to the TuneCamp backend.wallet.ts: Browser wallet management (connection, signing, on-chain transactions via ethers).
Navigation & Playback Flow β
- Navigation: User clicks on an album ->
AlbumDetails.tsxrequests data fromapi.ts-> Data displayed usingartist/components. - Playback: Click on "Play" -> Track added to
usePlayerStore->player/component starts streaming from backend (/api/tracks/:id/stream), with fallback to external providers if local file is missing. - Web3 Interaction: Connect wallet ->
wallet.tsmanages the account -> Ability to purchase releases or unlock content.