- Complex nested queries in
queries.tsthat load everything at once - Large payloads with deeply nested data structures
- Difficult to cache individual entities efficiently
- Components can't independently manage loading states
- Hard to debug and maintain complex joins
Replace the current nested approach with a flatter, more modular data loading strategy:
fetchSets() -> includes artists -> includes genres -> includes votes
fetchArtists() -> includes genres -> includes votes
fetchSets() -> just set data + artist_ids + genre_ids
fetchArtists(ids) -> just artist data + genre_ids
fetchGenres() -> cached genre list (loaded once)
fetchVotes(entityIds) -> vote data for specific entities
- Better caching: Each entity type cached separately with TanStack Query
- Parallel loading: Components can load data independently
- Smaller payloads: Only fetch what's needed when needed
- Better UX: Show sets immediately while other data loads progressively
- Easier testing: Each query has single responsibility
- More maintainable: Simpler queries, easier to debug
- Create separate query functions for each entity type
- Update components to use dependent queries
- Implement proper loading states for progressive data loading
- Add proper error boundaries for individual data loading failures
- Update TypeScript types to reflect flatter structure
- Migrate existing nested queries one by one
This is a significant architectural change that will improve performance and maintainability but requires careful migration planning.
Add other future improvements here...