ChronoStory Drop Item Search System

Featured Project
A solo-built full-stack game data platform serving 4,143+ entries across 250 source files (124 components + 49 custom hooks) with zero CDN egress cost. Key innovations include distributed Tab Leader election (N→1 WebSocket), browser-side OCR with 6 preprocessing modes, 4-layer caching architecture (localStorage → SWR → ISR → Cloudflare R2), and cross-device preference sync with real-time cycle prevention. Full bilingual support (zh-TW/en) with responsive design down to 320px.
10 months (actively maintained)
Launched: 2025-11-05
~0K
Users
GA4, Nov 2025–Aug 2026, no ad spend
0
Registered Users
Discord OAuth registered accounts
~0 min
Avg. Session
Average engagement per active user, same period
0.0M+
Total Events
Cumulative GA4 events, same period
$0+
Ad Revenue
Cumulative estimated AdSense earnings, Dec 2025–Oct 2026

Tech Stack Versions

Precise technology versions used in this project

Next.js15.x
React19.x
TypeScript5.9
Supabase2.x
Cloudflare R2
Tailwind CSS4.x
SWR2.x
Zod3.x
Tesseract.js5.x
Playwright1.x

Screenshots

Main feature screens of the project

Hit Rate Calculator — Precise numerical tool

Homepage (Light Mode) — Drop item search & filter

English Interface — Full i18n localization support

User Menu — Discord OAuth login integration

Trade Market — Player-to-player trading platform

Create Listing — Item listing & pricing interface

OCR EXP Tracker — Tesseract.js game screenshot recognition

System Architecture

3-tier caching strategy and data flow architecture

ChronoStory ArchitectureBrowser ClientBrowser StorageL1User Prefs (Perm)missVercel Edge FunctionsUpstash RedisL2Hot Data (30min)missSupabase PostgreSQLL3Live Data (5min)Cache Strategy: L1 (Browser) → L2 (Redis) → L3 (Supabase)TTL Tiers: User Prefs Perm | Hot Data 30min | Live Data 5min

Performance Metrics

Lighthouse scores and Core Web Vitals measurements

Lighthouse Scores

0
Performance
0
Accessibility
0
SEO

Core Web Vitals

LCP
1.1s
Largest Contentful Paint
INP
156ms
Interaction to Next Paint
CLS
0.09
Cumulative Layout Shift

Project Results

Specific achievements and technical highlights of the project

Google Analytics

↑ Real Google Analytics traffic data proof

0%65-75%
Cache Hit Rate
Effective hit rate of 3-tier caching
100%-60%
API Calls Reduced
Edge caching significantly reduces backend load
$65$0
Monthly Cost
Optimized from $65/mo to completely free
Serverless
Operations
No servers to maintain; runs on managed services

Capabilities Demonstrated

Technical and business capabilities demonstrated through this project

  • Real Traffic - 1,000+ daily users at peak, Dec 2025–Mar 2026
  • Rapid Iteration - 80+ automation scripts with daily ETL pipeline
    • 20+ data scraping & sync scripts
    • 40+ data transformation & batch processing scripts
    • 15+ image download & CDN management scripts
  • Security - CSP security headers + Zod input validation + quota system atomic operations

Challenges Faced

Main technical challenges encountered during development

  • Multi-tab WebSocket coordination — Supabase Realtime opens a connection per tab, N tabs = N connections consuming server resources
  • Browser OCR with variable game screenshots — inconsistent lighting, fonts, and backgrounds cause unreliable text recognition
  • Zero-cost global serving of 4,143+ data entries — traditional CDN egress fees scale linearly with traffic
  • Cross-device preference sync with cycle prevention — 30+ preference keys must sync in real-time without creating infinite update loops
  • Managing 49 custom hooks in single-page architecture — preventing re-render cascades and maintaining clean separation of concerns

Solutions

Technical solutions and implementation strategies adopted

  • Distributed Tab Leader election via BroadcastChannel + Zod-validated heartbeat, reducing WebSocket connections from N to 1 with 5-second failover
  • 6-mode preprocessing pipeline (5 binary thresholds + raw) with confidence-based result selection for automated EXP tracking
  • Cloudflare R2 zero-egress CDN + immutable cache headers + GitHub Actions auto-sync with version-based cache busting
  • Debounced batch writes with Supabase Realtime cycle prevention + guest variant keys + Tab Leader single-connection broadcast
  • Hooks-as-service-layer pattern + 6 React Context boundaries + SWR implicit data sharing with 60s dedup window

Code Snippets

Key implementation code from the project

// lib/cache/localStorage.ts - 4-Layer Cache Architecture
const CACHE_PREFIX = 'cs_cache_'
const DEFAULT_TTL = 5 * 60 * 1000 // 5 minutes

export function getFromCache<T>(key: string): T | null {
  const raw = localStorage.getItem(`${CACHE_PREFIX}${key}`)
  if (!raw) return null

  const { value, timestamp, ttl } = JSON.parse(raw)
  if (Date.now() - timestamp > (ttl || DEFAULT_TTL)) {
    localStorage.removeItem(`${CACHE_PREFIX}${key}`)
    return null
  }
  return value as T
}

export function setToCache<T>(key: string, value: T, ttl?: number) {
  localStorage.setItem(`${CACHE_PREFIX}${key}`, JSON.stringify({
    value, timestamp: Date.now(), ttl: ttl || DEFAULT_TTL
  }))
}

// Layer progression:
// L1: localStorage (permanent, 0ms) -> user preferences
// L2: SWR (60s dedup window) -> UI state revalidation
// L3: ISR (24h revalidation) -> server-side static pages
// L4: Cloudflare R2 (immutable headers) -> zero egress CDN

Architecture Decisions

Key architectural and technical decisions made during development

Context

Game data queries need ultra-low latency and different data types have different update frequencies. A single CDN layer can't differentiate caching strategies for preferences vs static data.

Options Compared
CDN Only (Cloudflare R2)
Pros
  • Simple implementation
  • Zero egress fees
Cons
  • User preferences can't update in real-time
  • No client-side request dedup
localStorage + SWR + ISR + R2
Pros
  • Each layer serves different access patterns
  • SWR 60s dedup reduces API calls
  • User preferences permanently saved on client
Cons
  • Cache invalidation needs careful design
  • More complex implementation
Decision

Chose 4-layer cache: localStorage for preferences (permanent), SWR for dedup (60s), ISR for DB offload (24h), R2 for zero egress (immutable headers)

Outcome

Zero CDN egress cost serving 4,143+ entries, 4-layer progression maximizing cache hit rate

Technical Highlights

In-depth technical implementation details and architecture design

Discord OAuth Integration

Authentication
  • Discord one-click login - Passwordless authentication
  • Supabase Auth integration - Automatic session management
  • JWT token verification - Secure API access control

Full-Stack Supabase Integration

Database Architecture
  • PostgreSQL database - Full CRUD operations
  • Row Level Security (RLS) - Row-level access control
  • Realtime subscriptions - Live data synchronization
  • Supabase Realtime - Real-time cross-device preference sync

4-Layer Caching Architecture

Caching Architecture
  • localStorage preferences - Permanent storage, zero-latency access
  • SWR client cache - 60s dedup window + automatic revalidation
  • ISR server cache - 24h Incremental Static Regeneration
  • Cloudflare R2 CDN - Immutable cache headers + zero egress cost

Unified Error Handling & Middleware

System Architecture
  • 7 standard error types + Automatic trace ID
  • 5 middleware composition patterns (auth, admin, bot protection)
  • Unified API response format & logging system

Key Takeaways

Important lessons and reflections from this project

Architecture

4-layer caching works because each layer serves a different access pattern — localStorage for preferences, SWR for dedup, ISR for DB offload, R2 for zero egress

Real Impact: Zero CDN egress cost serving 4,143+ entries with progressive 4-layer cache maximizing hit rate

Cost Engineering

Zero-cost architecture requires one-time custom tooling investment — R2 saves hosting but needs GitHub Actions + version-based cache busting

Real Impact: Custom tooling is one-time investment while cost savings compound; 4,143+ entries served at zero egress cost

Product Thinking

Gaming communities demand far more data freshness than expected — 5-min cache TTL was still too long on patch days

Real Impact: Added manual cache purge and auto-shortened TTL on game update days

Technical

Browser APIs can replace server infrastructure — BroadcastChannel + heartbeat protocol enables distributed Tab Leader election

Real Impact: WebSocket connections reduced from N to 1 with 5-second failover at zero server cost

Architecture

Browser OCR success depends on preprocessing, not the recognition engine — 6 modes + confidence ranking makes Tesseract.js viable for game screenshots

Real Impact: Zero cloud API costs, zero privacy concerns, user data stays entirely in the browser

Process

Hooks-as-Services enables single-page complexity without framework overhead — 49 hooks + 6 Contexts replace Redux/Zustand

Real Impact: No external state management dependency, and Context boundaries provide clean separation of concerns

Interested in this project?

Feel free to reach out to discuss similar technical solutions or how I can help with your project.

Contact Me
Contact Me
ChronoStory Drop Item Search System | Chih-Cheng Tien - Full Stack Developer