Skip to content

perf: Core Web Vitals, CDN caching, indexer & compression (#706 #707 #708 #709)#756

Merged
Hexstar-labs merged 2 commits into
BrainTease:mainfrom
webthreejunkie-sudo:feat/performance-706-707-708-709
Jun 29, 2026
Merged

perf: Core Web Vitals, CDN caching, indexer & compression (#706 #707 #708 #709)#756
Hexstar-labs merged 2 commits into
BrainTease:mainfrom
webthreejunkie-sudo:feat/performance-706-707-708-709

Conversation

@webthreejunkie-sudo

@webthreejunkie-sudo webthreejunkie-sudo commented Jun 29, 2026

Copy link
Copy Markdown

Summary

Implements four performance issues in a single PR.


#706 — Core Web Vitals Optimisation

  • CLS fix (courses page): wrapped CourseGrid in a min-h-[480px] container; fixed SVG icon with explicit width/height.
  • CLS fix (profile page): replaced bare "Loading…" text with a properly-sized skeleton; added explicit inline dimensions on the avatar fallback div.
  • LCP / INP: added <link rel="preconnect"> for the API origin and avatar CDNs in the root layout.
  • Lighthouse-CI gate: hardened all CWV assertions in lighthouserc.js from warnerror; added .github/workflows/lighthouse.yml.

#707 — HTTP Caching & CDN Strategy

  • CacheHeadersMiddlewareCache-Control (public+SWR for safe GETs, private for auth'd, no-store for mutations), ETag (SHA-1), 304 on matching If-None-Match.
  • Wired globally in AppModule.
  • docs/CDN_SETUP.md — header matrix, CloudFront/Cloudflare config, invalidation strategy, hit-ratio measurement.

#708 — Indexer & Event Query Performance

  • Batched processing: Promise.allSettled in chunks of 10 — one bad event never blocks the rest.
  • Back-pressure: skip tick when busy; exponential back-off (up to 4×) on consecutive busy ticks.
  • Lag metric: indexer:lag_ledgers + indexer:last_poll_ms written to Redis after every poll.
  • Cold-start fast-path: jumps to latest ledger on first run (INDEXER_CATCHUP=true for full historical replay).

#709 — API Response Compression & Payload Slimming

  • compression@1.7.4 added; app.use(compression({ threshold: 1024 })) in main.ts (gzip/brotli, ≥ 1 KB).
  • SparseFieldsInterceptor — global interceptor, trims responses to ?fields=id,title,level,price.
  • README updated with compression + sparse fieldsets docs and payload-reduction measurements.

Files changed

  • .github/workflows/lighthouse.yml (new)
  • apps/backend/package.json
  • apps/backend/src/app.module.ts
  • apps/backend/src/main.ts
  • apps/backend/src/common/middleware/cache-headers.middleware.ts (new)
  • apps/backend/src/common/interceptors/sparse-fields.interceptor.ts (new)
  • apps/backend/src/stellar/stellar-indexer.service.ts
  • apps/frontend/lighthouserc.js
  • apps/frontend/src/app/courses/page.tsx
  • apps/frontend/src/app/layout.tsx
  • apps/frontend/src/app/profile/page.tsx
  • docs/CDN_SETUP.md (new)
  • README.md

closes #706
closes #707
closes #708
closes #709

…rainTease#709

BrainTease#706 Core Web Vitals Optimisation
- Fix CLS on courses page (stable min-height container for grid)
- Fix CLS on profile page (skeleton loader, explicit avatar dimensions)
- Add preconnect hints for API origin and avatar CDNs in layout
- Harden lighthouserc.js CWV assertions from warn to error level
- Add .github/workflows/lighthouse.yml CI gate

BrainTease#707 HTTP Caching & CDN Strategy
- Add CacheHeadersMiddleware (Cache-Control + ETag + 304 support)
- Wire middleware globally in AppModule
- Add docs/CDN_SETUP.md with full CDN strategy and hit-ratio guide

BrainTease#708 Indexer & Event Query Performance
- Rewrite stellar-indexer: batched processing (Promise.allSettled)
- Add back-pressure (skip busy tick, exponential back-off)
- Write lag metrics to cache after every poll
- Cold-start fast-path (jump to latest ledger unless INDEXER_CATCHUP=true)

BrainTease#709 API Response Compression & Payload Slimming
- Add compression package, enable gzip/brotli in main.ts
- Add SparseFieldsInterceptor for ?fields= sparse responses
- Document payload reduction in README
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@webthreejunkie-sudo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Hexstar-labs
Hexstar-labs merged commit 2cd3291 into BrainTease:main Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants