Overview
The gallery page is implemented inapp/gallery/page.tsx and orchestrates three main components:
- AlbumSidebar - Navigate between albums and search photos
- PhotoGrid - Display photos in a responsive grid layout
- PhotoDetails - View detailed information about selected photos
Core Component Structure
app/gallery/page.tsx:16-203
Real-Time Data with SWR
The gallery uses SWR for efficient data fetching and automatic revalidation:app/gallery/page.tsx:14-30
SWR automatically revalidates data when the user refocuses the tab or reconnects to the network, ensuring the gallery always displays fresh data.
Photo Filtering
Photos are filtered in real-time based on album selection and search query:app/gallery/page.tsx:32-42
Photo Selection
Users can select photos from the grid to view detailed information:Photo details panel opens
The
PhotoDetails component displays on the right side with metadata, dimensions, and dominant colorsLayout Structure
The gallery uses a three-column flexbox layout:Album Sidebar
Fixed width (256px) on the left for album navigation and search
Photo Grid
Flexible main area that displays photos in a responsive grid
Photo Details
Fixed width (320px) panel on the right for selected photo details
State Management
The gallery manages several pieces of state:| State | Type | Purpose |
|---|---|---|
selectedAlbumId | string | null | Currently selected album filter |
selectedPhoto | Photo | null | Currently selected photo for details view |
searchQuery | string | Search filter for photo filenames |
isUploading | boolean | Upload operation in progress |
Cache Mutations
When photos or albums are modified, the gallery uses SWR’smutate function to update the cache:
app/gallery/page.tsx:70, app/gallery/page.tsx:136-137
Protected Route
The gallery page is protected by authentication middleware that redirects unauthenticated users to the login page. See the Authentication documentation for details.Related Components
Albums
Learn about album management in the sidebar
Photos
Explore photo upload, viewing, and management features