How winsharp/music-api works
Purpose and runtime
This is a Vite-powered React/TypeScript single-page application for building and showcasing personal music collections: users browse releases and artists, search catalog data, rate/collect releases, and present profile-based music taste. Browser startup flows from src/main.tsx into src/App.tsx; global presentation begins in src/index.css.
Application shell and navigation
src/App.tsx is the top-level composition point for route-level pages and shared application structure. src/components/NavBar.tsx provides primary navigation, while src/components/ProtectedRoute.tsx enforces authenticated access around private profile/settings flows. Pages are independently responsible for their screen-level fetches, state, loading, and errors.
Authentication and identity boundary
Authentication state is centralized through src/contexts/AuthContext.tsx, with consumers using src/hooks/useAuth.ts and the typed contract in src/types/AuthContextValue.ts. Backend-facing sign-in, registration, and session operations are isolated in src/services/authService.ts. src/pages/LoginPage.tsx and src/pages/RegisterPage.tsx initiate anonymous-user flows; profile routing includes src/pages/MyProfileRedirect.tsx.
Discogs integration
Discogs is the material external catalog/identity provider. OAuth configuration and authorization exchange logic live in src/services/discogsConfig.ts and src/services/discogsOAuthService.ts; callback completion is handled by src/pages/DiscogsCallbackPage.tsx. Connection credentials/state are persisted separately in src/services/discogsAuthStorage.ts, and Discogs user data is accessed/cached via src/services/discogsUserService.ts and src/services/discogsUserCache.ts. UI connection state is exposed through src/hooks/useDiscogsConnection.ts and src/components/ConnectDiscogsButton.tsx.
Catalog discovery and release detail
Catalog browsing, search, release detail, artist pages, and home features are separate page/service verticals:
• Browse: src/pages/BrowseCatalogPage.tsx, src/services/browseService.ts
• Search: src/pages/SearchPage.tsx, src/services/searchService.ts
• Release detail: src/pages/ReleasePage.tsx, src/services/releaseService.ts
• Artist detail: src/pages/ArtistPage.tsx, src/services/artistService.ts
• Featured/home data: src/pages/HomePage.tsx, src/services/homeService.ts
Services form the remote-data boundary and map responses into domain types under src/types/, including src/types/discogsRelease.ts, src/types/search.ts, and src/types/artist.ts. Reusable filtering/pagination UI uses genre/style constants from src/constants/genres.ts and src/constants/styles.ts.
Collection and profile domain
User-owned collection actions are separated from catalog retrieval. src/services/releaseCollectionService.ts manages rating/collection-related release operations, and src/services/wantlistService.ts manages wanted releases. src/components/RateAndCollect.tsx is the primary release-action UI. Profile rendering is organized through src/pages/ProfilePage.tsx and src/pages/ProfileSectionPage.tsx, with src/pages/SettingsPage.tsx covering account/integration settings.
UI state and resilience
Shared presentation components render catalog cards, lists, search results, filters, and pagination, notably src/components/ReleaseGrid.tsx, src/components/SearchResultView.tsx, and src/components/Pagination.tsx. Asynchronous request state is normalized by src/hooks/useAsyncStatus.ts; page query pagination is managed by src/hooks/usePageParam.ts. Loading boundaries use dedicated skeletons such as src/components/skeletons/ReleaseDetailSkeleton.tsx and src/components/skeletons/ProfilePageSkeleton.tsx. API errors are converted for display through src/utils/getApiErrorMessage.ts.
Main entry points: App.tsx App routes & shell · BrowseCatalogPage.tsx Discovery pages · ProfilePage.tsx Profiles & settings · AuthContext.tsx Auth state
Components 19
Application shell
- Browser entry
src/main.tsx - App routes & shell · Composes route pages and shared structure.
src/App.tsx - Primary navigation
src/components/NavBar.tsx - Async state & loading UI · Normalizes request states and loading boundaries.
src/hooks/useAsyncStatus.ts
Identity & access
- Auth state · Central authenticated identity state.
src/contexts/AuthContext.tsx - Auth consumer API
src/hooks/useAuth.ts - Authentication API · Handles sign-in, registration, and sessions.
src/services/authService.ts - Login & registration
src/pages/LoginPage.tsx - Private-route guard
src/components/ProtectedRoute.tsx
Discogs integration
- Discogs OAuth & credentials · Authorizes Discogs and persists connection state.
src/services/discogsOAuthService.ts - Discogs callback
src/pages/DiscogsCallbackPage.tsx - Discogs user data
src/services/discogsUserService.ts
Catalog & discovery
- Catalog data services · Browse, search, release, artist, and home data.
src/services/browseService.ts - Discovery pages · Browse, search, home, release, and artist screens fetch their own data.
src/pages/BrowseCatalogPage.tsx - Catalog domain types
src/types/discogsRelease.ts - Catalog result UI · Release grids, search results, filters, and pagination.
src/components/ReleaseGrid.tsx
Collection & profiles
- Collection & wantlist API · Separates owned-release actions from catalog retrieval.
src/services/releaseCollectionService.ts - Rate & collect UI
src/components/RateAndCollect.tsx - Profiles & settings · Renders profile sections and account/integration settings.
src/pages/ProfilePage.tsx
Connections 19
- Browser entry → App routes & shell: mounts
- App routes & shell → Primary navigation: renders
- App routes & shell → Login & registration: routes to
- App routes & shell → Discovery pages: routes to
- App routes & shell → Private-route guard: wraps private routes
- Private-route guard → Profiles & settings: permits
- Auth state → Authentication API: session operations
- Auth consumer API → Auth state: consumes
- Login & registration → Auth state: starts auth flows
- Discogs callback → Discogs OAuth & credentials: completes OAuth
- Discogs OAuth & credentials → Discogs user data: authorizes access
- Profiles & settings → Discogs OAuth & credentials: manages connection
- Discovery pages → Catalog data services: fetches catalog data
- Catalog data services → Catalog domain types: maps responses to
- Discovery pages → Catalog result UI: renders results with
- Discovery pages → Async state & loading UI: uses request state
- Rate & collect UI → Collection & wantlist API: updates collection
- Profiles & settings → Collection & wantlist API: loads user music data
- Profiles & settings → Discogs user data: loads Discogs identity