These rules apply to all coding sessions in the GitPulse project.
GitPulse is a GitHub Activity Dashboard built with React + TanStack DB. It showcases TanStack DB's realtime features: collections, live queries (filters, joins, sorts, aggregates), and reactive UI updates.
- Data layer: TanStack DB collections are the single source of truth
- Fetching: TanStack Query + @tanstack/query-db-collection bridges API data into collections
- Queries: All UI reads go through
useLiveQuery/useLiveSuspenseQuery— never read from Query cache directly - Routing: Simple state-based SPA page switching (no URL router)
- Define all collections in
src/collections/— one file per entity - Every collection must have a Zod schema in
src/schemas/ - Use
queryCollectionOptions()to bridge TanStack Query into TanStack DB - Always provide
getKey,schema, andsyncconfig - Prefer
syncMode: 'eager'for small datasets (<10k),'on-demand'for large
- Place reusable query definitions in
src/queries/ - Import operators (
eq,gt,and,or,count, etc.) from@tanstack/react-db - Always pass reactive dependencies as the second argument to
useLiveQuery - Use
useLiveSuspenseQueryinside Suspense boundaries for initial loads only
- All GitHub API functions go in
src/api/ - Use native
fetchwith the stored PAT as Bearer token - Handle rate limiting (check
X-RateLimit-Remainingheader) - Never store tokens in code — only in localStorage
- Page components go in
src/pages/ - Reusable UI primitives go in
src/components/ui/ - Feature-specific components go in
src/components/<feature>/ - Use Tailwind CSS v4 utility classes — avoid inline styles
- Prefer composition over prop-heavy components
- Use Tailwind CSS v4 with
@import "tailwindcss"in globals.css - Support dark mode via Tailwind
dark:variant with class strategy - Use CSS custom properties for theme colors defined in globals.css
- Label colors from GitHub should be rendered with inline background-color
- Strict mode enabled
- Infer collection types from Zod schemas — don't duplicate type definitions
- Use
z.infer<typeof schema>for derived types - Prefer
constassertions for static config objects
src/collections/— TanStack DB collection definitionssrc/schemas/— Zod schemas for all entitiessrc/queries/— Reusable live query definitionssrc/api/— GitHub REST API client and endpoint functionssrc/pages/— Top-level page componentssrc/components/— UI components organized by featuresrc/hooks/— Custom React hookssrc/lib/— Utility functions (dates, colors, token management)
Key packages (do not add alternatives without reason):
@tanstack/react-db— Client-side reactive data store@tanstack/react-query+@tanstack/query-db-collection— Data fetching bridgezod— Schema validationrecharts— Chartslucide-react— Iconsdate-fns— Date formatting
- Run
npm run buildto verify TypeScript compilation - Run
npm run devto test locally - Test with invalid/expired token to verify error handling