- Service Name:
ihnyc-rc-gallery - Live Site: https://moments.ihnyc-rc.org
- Repository:
https://github.com/dghauri0/ihnyc-rc-gallery.git
π§ Overview
- Cloudflare Worker serving public gallery and admin UI from single entrypoint
- Stores media in R2 and metadata/indexes in Workers KV
- Uses Cloudflare Image Resizing for derived variants
- Scheduled repair jobs run every 30 minutes
- Admin routes protected via Cloudflare Access
Sources: ihnyc-rc-gallery/wrangler.toml, ihnyc-rc-gallery/src/index.ts, ihnyc-rc-gallery/README.md
π₯ Key User Flows
Public Gallery
- Browse published media at
/gallery - View permalinks at
/gallery/:id - List published items via
/api/gallery - Fetch media with on-the-fly resizing at
/media/*
Admin Media Management
- Upload originals and thumbs via
/api/admin/media - List all media (published and unpublished)
- Update KV indexes automatically
- Run orphan cleanup jobs
Media Delivery
- Serve originals or resized variants from R2
- Cloudflare Image Resizing generates variants on-demand
- Requires
PUBLIC_MEDIA_BASE_URLfor resizing fetches
Sources: ihnyc-rc-gallery/src/index.ts, ihnyc-rc-gallery/README.md
π Key Routes and Endpoints
| Route | Method | Auth | Purpose | Source |
|---|---|---|---|---|
/health | GET | Public | Health check | ihnyc-rc-gallery/src/index.ts |
/gallery | GET | Public | Gallery UI | ihnyc-rc-gallery/src/index.ts |
/gallery/:id | GET | Public | Permalink UI | ihnyc-rc-gallery/src/index.ts |
/api/gallery | GET | Public | List published media | ihnyc-rc-gallery/src/index.ts |
/api/gallery/:id | GET | Public | Get single media item | ihnyc-rc-gallery/src/index.ts |
/media/* | GET/HEAD | Public | Serve media (variants) | ihnyc-rc-gallery/src/index.ts |
/admin/gallery | GET | Edge Access | Admin UI | ihnyc-rc-gallery/src/index.ts |
/admin/repair | GET | Edge Access | Repair UI | ihnyc-rc-gallery/src/index.ts |
/api/admin/media | GET/POST | Edge Access | List or upload media | ihnyc-rc-gallery/src/index.ts |
/api/admin/media/:id | GET/PATCH/DELETE | Edge Access | Read/update/delete media item | ihnyc-rc-gallery/src/index.ts |
/api/admin/health | GET | Edge Access | Admin health | ihnyc-rc-gallery/src/index.ts |
/api/admin/repair/orphans | POST | Edge Access | Cleanup orphans | ihnyc-rc-gallery/src/index.ts |
πΌοΈ Media variants and parameters
variant=original(default): raw bytesvariant=thumb: resized, default width ~480variant=display: resized, default width ~1600- Optional query params:
w=<number>: custom max width (clamped 16β4096)format=webp|jpeg|png: output format override
π Admin upload constraints
- Max file size: 10MB
- Accepted types: JPEG, PNG, WebP
- Upload field name:
files(multipart)
ποΈ Data and Storage
| Storage | Binding | Purpose | Source |
|---|---|---|---|
| R2 | GALLERY_MEDIA | Originals and thumbs | ihnyc-rc-gallery/wrangler.toml |
| KV | GALLERY_META | Records and indexes | ihnyc-rc-gallery/wrangler.toml |
Sources: ihnyc-rc-gallery/wrangler.toml, ihnyc-rc-gallery/src/index.ts
Data Flow Diagram (Mermaid)
flowchart LR subgraph Users U_RES["USER: Visitor"] U_ADMIN["USER: Admin"] end subgraph Services S_GALLERY["SVC: ihnyc-rc-gallery"] end subgraph Storage STORE_R2["STORE: R2 (GALLERY_MEDIA)"] STORE_KV["STORE: KV (GALLERY_META)"] end subgraph External_Systems EXT_IMG["EXT: Cloudflare Image Resizing"] end U_RES -->|browse| S_GALLERY U_ADMIN -->|manage media| S_GALLERY S_GALLERY -->|store originals/thumbs| STORE_R2 S_GALLERY -->|index metadata| STORE_KV S_GALLERY -->|resize variants| EXT_IMG
Sources: ihnyc-rc-gallery/wrangler.toml, ihnyc-rc-gallery/src/index.ts
π Automations and Integrations
Image Resizing
- Cloudflare Image Resizing: On-demand variant generation via
cf.image - Requires
PUBLIC_MEDIA_BASE_URLconfigured
Scheduled Jobs
- Orphan Repair: Runs every 30 minutes
- Cleans up dangling KV entries with missing R2 objects
Access Protection
- Admin routes are not protected in code; enforce Cloudflare Access at the edge
- Configure Access for
/admin/*and/api/admin/*
Sources: ihnyc-rc-gallery/src/index.ts, ihnyc-rc-gallery/README.md, ihnyc-rc-gallery/wrangler.toml
π Detailed Guides
- architecture: Worker layout and routing
- data: KV + R2 data model and indexes
- api: Public and admin API reference
- media-pipeline: Uploads, thumbnails, variants
- ops: Runbooks and operational notes
πΊοΈ Service Flow Diagram
Gallery service architecture and integrations
flowchart LR subgraph Users U_RES["USER: Visitor"] U_ADMIN["USER: Admin"] end subgraph Services S_GALLERY["SVC: ihnyc-rc-gallery"] end subgraph External_Systems EXT_IMG["EXT: Cloudflare Image Resizing"] end subgraph Storage STORE_R2["STORE: R2"] STORE_KV["STORE: KV"] end U_RES -->|view| S_GALLERY U_ADMIN -->|admin| S_GALLERY S_GALLERY -->|media| STORE_R2 S_GALLERY -->|metadata| STORE_KV S_GALLERY -->|resize| EXT_IMG
Sources: ihnyc-rc-gallery/wrangler.toml, ihnyc-rc-gallery/src/index.ts
π οΈ Common Ops
Local Development
npm run devDeployment
npm run deployCreate R2 Bucket
wrangler r2 bucket create <bucket-name>Create KV Namespace
wrangler kv:namespace create GALLERY_METASources: ihnyc-rc-gallery/README.md
π Environment Variables
| Name | Purpose | Required |
|---|---|---|
PUBLIC_MEDIA_BASE_URL | Public media base URL for resizing fetches | Yes |
RC_LOGO_URL | Logo asset URL (falls back to built-in SVG if unset) | No |
Sources: ihnyc-rc-gallery/wrangler.toml, ihnyc-rc-gallery/src/index.ts
β Open Questions
Production Configuration
- Are
/admin*and/api/admin*protected by Cloudflare Access in production?
Sources: ihnyc-rc-gallery/README.md
π¨ UI/UX Features
Gallery Interface (2026-01-16 Update)
Skeleton Loading States
- Animated placeholder cards during initial load
- 8 skeleton cards with shimmer animation
- Respects
prefers-reduced-motionaccessibility setting - Improves perceived performance and user engagement
Enhanced Lightbox Experience
- Rich metadata overlay showing event date, tags, and dimensions
- Glass-morphism styled badge design for metadata tags
- Emoji-prefixed information for quick visual scanning
- Progressive image quality upgrade on zoom
Tag Filter UX
- Gradient fade indicators on scroll edges
- Visual cues for discoverability of overflow content
- Smooth scrollbar styling (webkit/firefox)
- Dynamic visibility based on scroll position
Custom Form Controls
- Replaced system-default dropdowns with custom-styled selects
- Inline SVG chevron icons matching design language
- Consistent styling across all interactive elements
- Smooth hover transitions with primary color accents
Mobile Responsiveness
- Responsive grid gaps (12pxβ16pxβ20pxβ24px across breakpoints)
- Touch target optimization (44px+ buttons/selects, 36px+ chips)
- Meets WCAG 2.1 Level AAA touch target requirements
- Enhanced mobile viewport handling (48px touch targets <480px)
Accessibility Enhancements
- Skip-to-content link for keyboard navigation
- Enhanced focus indicators (3px solid outline)
- Proper ARIA labels on all interactive controls
aria-pressedstates on filter buttons- Region landmarks for screen reader navigation
Sources: ihnyc-rc-gallery/src/templates/gallery.ts, ihnyc-rc-gallery/src/templates/layout.ts