How codebyvimal/stash works
Purpose and startup
Stash is a client-side personal productivity and self-gamification application: users manage tasks, earn a balance, and redeem configured rewards. The Vite/React application boots at src/main.tsx, renders the application root in src/App.tsx, and uses shared domain types from src/types.ts.
Application shell and navigation
src/App.tsx coordinates top-level application state and selects the active experience. src/components/layout/AppShell.tsx provides the authenticated desktop/mobile frame, with navigation implemented by src/components/layout/Sidebar.tsx and src/components/layout/MobileNav.tsx. src/components/layout/AppTourModal.tsx supports first-use onboarding.
Authentication and persistence boundary
Authentication is encapsulated in src/hooks/useAuth.ts and presented through src/components/auth/AuthScreen.tsx. Supabase integration is isolated behind src/lib/supabase.ts; it is optional, while local development persists data in browser local storage through the store layer. Database schema ownership is represented in supabase/schema.sql, separating frontend state from Supabase tables/auth services.
Central client state and domain model
src/hooks/useStore.ts is the Zustand state boundary for user data and mutations, including tasks, balances, rewards, and transaction/history effects. Components consume this store rather than own durable domain state. src/types.ts defines the shared task, reward, and activity/transaction shapes that connect dashboard, history, and redemption workflows.
Task-to-economy workflow
The dashboard is the primary operational surface: src/components/dashboard/TaskPlanner.tsx and src/components/dashboard/TaskList.tsx organize planned work; src/components/dashboard/QuickAddForm.tsx creates tasks; completing them feeds the balance and activity state exposed by src/components/dashboard/BalanceHeader.tsx and src/components/dashboard/ActivityList.tsx. src/components/dashboard/RewardPreview.tsx connects available balance to future redemption.
Reward lifecycle
Rewards are managed separately in src/components/rewards/RewardsTab.tsx and displayed through src/components/rewards/RewardCard.tsx. Creation and editing occur in src/components/rewards/AddRewardModal.tsx and src/components/rewards/EditRewardModal.tsx; src/components/rewards/ClaimModal.tsx is the spending boundary that claims a reward and should atomically affect balance/history via the store.
History, resilience, and delivery
src/components/history/HistoryTab.tsx presents transaction/task activity, grouped by src/components/history/TransactionGroup.tsx and rendered by src/components/history/TransactionCard.tsx. Cross-cutting UI failure and feedback boundaries are src/components/ui/ErrorBoundary.tsx, src/components/ui/ConfirmModal.tsx, and src/components/ui/Toast.tsx. The frontend is built with Vite, styled with Tailwind, and uses Framer Motion; production delivery supports static serving through Dockerfile/nginx.conf, Docker Compose via docker-compose.yml, and Vercel via vercel.json. Offline/PWA assets are in public/manifest.json and public/sw.js.
Main entry points: useStore.ts Zustand store · App.tsx App root · Sidebar.tsx Desktop & mobile navigation · AppShell.tsx Authenticated shell
Components 20
React client
- Vite entry
src/main.tsx - App root · Coordinates top-level state and active experience.
src/App.tsx - Authenticated shell
src/components/layout/AppShell.tsx - Desktop & mobile navigation
src/components/layout/Sidebar.tsx - First-use tour
src/components/layout/AppTourModal.tsx - Authentication
src/hooks/useAuth.ts - Auth screen
src/components/auth/AuthScreen.tsx - Task dashboard · Plans, creates, completes, and previews task/reward activity.
src/components/dashboard/TaskPlanner.tsx - Balance & activity · Shows earned balance and resulting activity.
src/components/dashboard/BalanceHeader.tsx - Reward management · Manages rewards and their cards.
src/components/rewards/RewardsTab.tsx - Reward claim · Claims a reward through an atomic store mutation.
src/components/rewards/ClaimModal.tsx - Activity history · Groups and renders task and transaction activity.
src/components/history/HistoryTab.tsx - UI feedback boundaries · Error boundary, confirmations, and toast feedback.
src/components/ui/ErrorBoundary.tsx
State & services
- Zustand store · Owns tasks, balances, rewards, transactions, and mutations.
src/hooks/useStore.ts - Domain types · Task, reward, activity, and transaction shapes.
src/types.ts - Supabase adapter · Optional remote auth and data integration.
src/lib/supabase.ts
Optional Supabase
- Supabase schema · Owns remote tables and auth-service boundary.
supabase/schema.sql
Delivery & offline
- Offline PWA assets
public/manifest.json - Static container delivery
Dockerfile - Vercel delivery
vercel.json
Connections 23
- Vite entry → App root: renders
- App root → Authentication: uses
- Authentication → Auth screen: drives
- App root → Authenticated shell: shows when authenticated
- Authenticated shell → Desktop & mobile navigation: contains
- Authenticated shell → First-use tour: hosts
- Desktop & mobile navigation → Task dashboard: selects
- Desktop & mobile navigation → Reward management: selects
- Desktop & mobile navigation → Activity history: selects
- Task dashboard → Zustand store: creates and completes tasks
- Zustand store → Balance & activity: provides balance and activity
- Reward management → Zustand store: manages rewards
- Reward management → Reward claim: opens
- Reward claim → Zustand store: spends balance and records history
- Zustand store → Activity history: provides activity
- Zustand store → Domain types: uses
- Authentication → Supabase adapter: optionally authenticates through
- Zustand store → Supabase adapter: optionally persists through
- Supabase adapter → Supabase schema: uses tables and auth
- App root → UI feedback boundaries: is protected by
- Static container delivery → App root: serves production build
- Vercel delivery → App root: deploys
- Offline PWA assets → App root: enables offline support