Documentation Index
Fetch the complete documentation index at: https://mintlify.com/pieroenrico/tune-me-in/llms.txt
Use this file to discover all available pages before exploring further.
Architecture Overview
Tune Me In is built on a modern headless commerce architecture that combines three powerful platforms:- Shopify Storefront API - Product catalog, inventory, and checkout
- Sanity CMS - Content management and editorial features
- Hydrogen - React-based framework for building custom storefronts
High-Level Architecture
Core Components
1. Hydrogen Framework
Hydrogen is Shopify’s React-based framework for building custom storefronts. It provides:- Server Components - React Server Components for optimal performance
- Streaming SSR - Fast initial page loads with progressive enhancement
- Built-in Components - Pre-built components for common e-commerce patterns
- Developer Experience - Hot module replacement and fast refresh with Vite
Tune Me In uses Hydrogen v0.7.0, which is based on React 18 alpha with experimental Server Components support.
2. Sanity CMS Integration
Sanity provides the content layer, storing:- Product References - References to Shopify products with custom metadata
- Editorial Content - Rich content using Portable Text
- Page Structures - Homepage, collections, articles, and custom pages
- Media Assets - Images with transformations and optimization
sanity.config.js:1-7):
3. Shopify Storefront API
The Shopify Storefront API provides real-time commerce data:- Product Data - Titles, descriptions, pricing, availability
- Variants - Product options, SKUs, inventory levels
- Media - Product images and videos
- Metafields - Custom product metadata (e.g.,
tunemeinnamespace)
shopify.config.js:3-9):
Application Structure
Entry Point
The application starts inApp.server.jsx:11-24, which sets up the core providers:
The
ShopifyServerProvider wraps the entire application, making Shopify configuration available throughout the component tree.Page Structure
Pages follow the file-based routing convention:pages/Index.server.jsx- Homepagepages/[handle].server.jsx- Dynamic article pagespages/products/[handle].server.jsx- Product detail pagespages/collections/[handle].server.jsx- Collection listing pages
.server.jsx extension, while client components use .client.jsx.
Data Flow
Unified Data Fetching
- Server Component renders and calls
useSanityQuery - Sanity Query fetches content with product references
- Product Detection identifies Shopify product IDs in the response
- Storefront Query automatically fetches product data from Shopify
- Merged Response returns both Sanity content and Shopify products
Example Flow
Frompages/Index.server.jsx:25-48:
sanityDatacontains the full Sanity response with product referencesshopifyProductscontains a normalized map of products keyed by Sanity ID
Key Design Patterns
Server vs Client Components
- Server Components (
.server.jsx) - Data fetching, layout, non-interactive elements - Client Components (
.client.jsx) - Interactive UI, state management, browser APIs
Product Context Pattern
Products fetched viauseSanityQuery are passed through React Context (ProductsProvider.client.jsx:3-11) to deeply nested components:
useProductsContext(productId) without prop drilling.
Fragment Composition
GROQ queries use reusable fragments (src/fragments/) to maintain consistency:
IMAGE- Standard image fields with transformationsPRODUCT_WITH_VARIANT- Product references with variant selectionPORTABLE_TEXT- Rich content with nested product referencesSEO- Metadata for search optimization
Performance Considerations
Caching Strategy
- Sanity CDN - Content is served from a global CDN when
useCdn: true - Shopify Storefront - Product data is always fresh from Shopify’s API
- Hydrogen Caching - Currently disabled in the demo (see README caveats)
Image Optimization
- Sanity images include low-quality image placeholders (LQIP) for progressive loading
- Images are transformed on-demand via Sanity’s image CDN
- Shopify product images are served from Shopify’s CDN
Next Steps
Sanity Integration
Learn how Sanity CMS powers the content layer
Shopify Integration
Understand how Shopify provides commerce functionality
Data Fetching
Deep dive into the useSanityQuery hook
Getting Started
Set up your own Tune Me In storefront