aws-samples / aws-samples/sample-collaborative-ai-dlc
Replace useProjectsCache with Tanstack Query (or SWR)
- Dominant language
- JavaScript
- Stars
- 75
- Forks
- 23
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 24
Description
## Context
Per review comment on #184 by @svozza: the hand-rolled `useProjectsCache` hook (~200 lines) manually implements stale-while-revalidate, dedup, TTL, and error states. A library like [Tanstack Query](https://tanstack.com/query) or [SWR](https://swr.vercel.app/) provides all of this out of the box with devtools, retry, prefetch, and garbage collection.
## Expected outcome
- Replace `useProjectsCache.ts` with Tanstack Query hooks
- Reduce cache boilerplate by ~50%
- All consumers (`AppSidebar`, `Dashboard`, `Project`, `ObservabilityLayout`) updated
- Behavior unchanged: stale-while-revalidate, 120s TTL projects, 60s sprints
## Notes
- Tanstack Query is tree-shakeable and ~12kB gzipped
- This is a refactor, no user-facing behavior change
Contributor guide
Research direction
Start by reading useProjectsCache.ts and tracing its consumers: AppSidebar, Dashboard, Project, and ObservabilityLayout. Compare Tanstack Query and SWR against the existing stale-while-revalidate, deduplication, error, and TTL behavior. Done means the consumers use the selected library, the cache hook is replaced, boilerplate is reduced, and projects and sprints retain their 120-second and 60-second TTLs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100