Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0ead36c
Add persistent cache layer for read-heavy views
Mosas2000 Mar 18, 2026
c0b4dce
Add tests for persistent cache layer
Mosas2000 Mar 18, 2026
46e489b
Add hook for data fetching with cache fallback
Mosas2000 Mar 18, 2026
8e009d5
Add tests for cached data hook
Mosas2000 Mar 18, 2026
1a9296d
Add FreshnessIndicator component for cache status display
Mosas2000 Mar 18, 2026
1f50c1b
Add hook for controlling transaction availability during outages
Mosas2000 Mar 18, 2026
c2c9659
Add tests for transaction lockout hook
Mosas2000 Mar 18, 2026
d6d8903
Add cache invalidation manager for strategic cache expiry
Mosas2000 Mar 18, 2026
be9ed56
Add tests for cache invalidation manager
Mosas2000 Mar 18, 2026
c67d593
Add hook for cached platform statistics
Mosas2000 Mar 18, 2026
a905665
Add comprehensive guide for last-known-good caching system
Mosas2000 Mar 18, 2026
b6937c6
Add hook for cached leaderboard data
Mosas2000 Mar 18, 2026
8cc6e25
Add transparent API client wrapper with automatic caching
Mosas2000 Mar 18, 2026
8d9b5a4
Add tests for cached API client
Mosas2000 Mar 18, 2026
2a2f56c
Add resilience context for application-wide cache coordination
Mosas2000 Mar 18, 2026
17b476d
Add migration guide for last-known-good caching
Mosas2000 Mar 18, 2026
72f1bed
Update CHANGELOG for last-known-good caching (Issue 290)
Mosas2000 Mar 18, 2026
e5a85f4
Add API resilience and caching architecture to ARCHITECTURE.md
Mosas2000 Mar 18, 2026
9189550
Add resilience monitoring and diagnostics utilities
Mosas2000 Mar 18, 2026
582e8c8
Add tests for resilience monitoring utilities
Mosas2000 Mar 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,48 @@ enrichedTips (displayed to user)

See `docs/PERFORMANCE_PROFILING.md` for measurement techniques.

## Data Flow
### API Resilience & Caching (Issue #290)

Read-heavy views implement last-known-good caching to survive API outages:

## Security Boundaries
```
Live API Request
|
v
Fetch with timeout (10s)
├─ Success?
│ ├─ Yes: Store in persistent cache → Return live data
│ │
│ └─ No: Timeout/error occurred
│ Check persistent cache
│ ├─ Cache found → Return cached data
│ └─ No cache → Return error
|
v
User sees: live data OR cached data OR error
UI shows: freshness metadata + retry button (if cached)
```

**Features:**

- **Persistent cache**: localStorage-backed, survives browser reload
- **TTL management**: 2-5 minute caches per endpoint type
- **Automatic fallback**: No code changes needed, transparent
- **Freshness indicators**: Users shown data source and age
- **Transaction lockout**: Risky actions disabled on stale data
- **Pattern invalidation**: Related caches cleared on state change

**Layers:**

1. `persistentCache.js` - Low-level storage with TTL
2. `useCachedData` - Generic hook for any fetch
3. `cachedApiClient.js` - Transparent HTTP wrapper
4. `FreshnessIndicator.jsx` - Visual feedback component
5. `ResilienceContext.jsx` - Global coordination

See `docs/LAST_KNOWN_GOOD_CACHING.md` for architecture and patterns.

## Data Flow

| Boundary | Trust Model |
|---|---|
Expand Down
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

### Changed

- Added last-known-good caching for read-heavy surfaces (Issue #290):
- Persistent cache stores successful API responses with configurable TTL
- Automatic fallback to cached data when live APIs are unavailable or slow
- Visual freshness indicators show users whether they are viewing live or cached data
- Transaction operations locked when live data unavailable to prevent incorrect actions
- Strategic cache invalidation on state changes (tip-sent, profile-update)

- Event feed pipeline refactored for scale and performance (Issue #291):
- Implemented selective message enrichment: messages are now fetched only
for visible/paginated tips instead of all tips, reducing API calls by ~90%
Expand All @@ -19,6 +26,33 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- RecentTips component refactored to use new `useFilteredAndPaginatedEvents`
hook, centralizing filter/sort/paginate logic and improving composability.

### Added (Issue #290)

- `frontend/src/lib/persistentCache.js`: localStorage-backed cache with TTL support,
metadata tracking, and statistics collection.
- `frontend/src/hooks/useCachedData.js`: Generic hook for fetch with automatic
fallback to persistent cache on error or timeout.
- `frontend/src/hooks/useCachedStats.js`: Platform stats-specific hook with
appropriate TTL and timeout settings.
- `frontend/src/hooks/useCachedLeaderboard.js`: Leaderboard-specific hook with
extended cache TTL for aggregated data.
- `frontend/src/lib/cachedApiClient.js`: Transparent fetch wrapper with automatic
response caching, timeout handling, and per-endpoint TTL configuration.
- `frontend/src/lib/cacheInvalidationManager.js`: Utilities for pattern-based and
event-based cache invalidation to prevent stale data cascades.
- `frontend/src/hooks/useTransactionLockout.js`: Hook for controlling transaction
availability based on data source (live/cache/none).
- `frontend/src/context/ResilienceContext.jsx`: Global context for coordinating
cache invalidation and connection status monitoring across the app.
- `frontend/src/components/FreshnessIndicator.jsx`: Visual component showing cache
status, data age, and retry button for manual refresh.
- `docs/LAST_KNOWN_GOOD_CACHING.md`: Comprehensive guide covering architecture,
components, usage patterns, TTL guidelines, and troubleshooting.
- `docs/MIGRATION_GUIDE_290.md`: Step-by-step integration guide for adding caching
to existing components with before/after examples.
- Unit tests for persistent cache, cached data hook, cache invalidation, and
transaction lockout with edge case and integration coverage.

### Added (Issue #291)

- `frontend/src/lib/eventCursorManager.js`: Opaque cursor-based pagination
Expand Down
Loading
Loading