# codebyvimal/stash architecture

> Architecture diagram of the GitHub repository codebyvimal/stash, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codebyvimal/stash
- Repository: https://github.com/codebyvimal/stash

## Overview

#### 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: [`src/hooks/useStore.ts`](https://github.com/codebyvimal/stash/blob/main/src/hooks/useStore.ts) (Zustand store), [`src/App.tsx`](https://github.com/codebyvimal/stash/blob/main/src/App.tsx) (App root), [`src/components/layout/Sidebar.tsx`](https://github.com/codebyvimal/stash/blob/main/src/components/layout/Sidebar.tsx) (Desktop & mobile navigation), [`src/components/layout/AppShell.tsx`](https://github.com/codebyvimal/stash/blob/main/src/components/layout/AppShell.tsx) (Authenticated shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_main(("Vite entry<br/>bootstrap<br/>[main.tsx]"))
  node_app["App root<br/>application shell<br/>[App.tsx]"]
  node_shell["Authenticated shell<br/>layout<br/>[AppShell.tsx]"]
  node_navigation["Desktop &amp; mobile navigation<br/>[Sidebar.tsx]"]
  node_tour["First-use tour<br/>onboarding modal<br/>[AppTourModal.tsx]"]
  node_auth["Authentication<br/>auth hook &amp; screen<br/>[useAuth.ts]"]
  node_authscreen["Auth screen<br/>auth UI<br/>[AuthScreen.tsx]"]
  node_dashboard["Task dashboard<br/>operational UI<br/>[TaskPlanner.tsx]"]
  node_economy["Balance &amp; activity<br/>dashboard UI<br/>[BalanceHeader.tsx]"]
  node_rewards["Reward management<br/>rewards UI<br/>[RewardsTab.tsx]"]
  node_claim["Reward claim<br/>spending modal<br/>[ClaimModal.tsx]"]
  node_history["Activity history<br/>history UI<br/>[HistoryTab.tsx]"]
  node_resilience["UI feedback boundaries<br/>error &amp; feedback UI<br/>[ErrorBoundary.tsx]"]
end

subgraph group_state["State &amp; services"]
  node_store[("Zustand store<br/>durable client state<br/>[useStore.ts]")]
  node_types["Domain types<br/>shared model<br/>[types.ts]"]
  node_supabaseclient{{"Supabase adapter<br/>integration boundary<br/>[supabase.ts]"}}
end

subgraph group_supabase["Optional Supabase"]
  node_schema[("Supabase schema<br/>database schema<br/>[schema.sql]")]
end

subgraph group_delivery["Delivery &amp; offline"]
  node_pwa["Offline PWA assets<br/>manifest &amp; service worker<br/>[manifest.json]"]
  node_container["Static container delivery<br/>Docker &amp; nginx"]
  node_vercel["Vercel delivery<br/>deployment config<br/>[vercel.json]"]
end

node_main -->|"renders"| node_app
node_app -->|"uses"| node_auth
node_auth -->|"drives"| node_authscreen
node_app -->|"shows when authenticated"| node_shell
node_shell -->|"contains"| node_navigation
node_shell -->|"hosts"| node_tour
node_navigation -->|"selects"| node_dashboard
node_navigation -->|"selects"| node_rewards
node_navigation -->|"selects"| node_history
node_dashboard -->|"creates and completes tasks"| node_store
node_store -->|"provides balance and activity"| node_economy
node_rewards -->|"manages rewards"| node_store
node_rewards -->|"opens"| node_claim
node_claim -->|"spends balance and records history"| node_store
node_store -->|"provides activity"| node_history
node_store -->|"uses"| node_types
node_auth -.->|"optionally authenticates through"| node_supabaseclient
node_store -.->|"optionally persists through"| node_supabaseclient
node_supabaseclient -.->|"uses tables and auth"| node_schema
node_app -->|"is protected by"| node_resilience
node_container -->|"serves production build"| node_app
node_vercel -->|"deploys"| node_app
node_pwa -->|"enables offline support"| node_app

click node_main "https://github.com/codebyvimal/stash/blob/main/src/main.tsx"
click node_app "https://github.com/codebyvimal/stash/blob/main/src/App.tsx"
click node_shell "https://github.com/codebyvimal/stash/blob/main/src/components/layout/AppShell.tsx"
click node_navigation "https://github.com/codebyvimal/stash/blob/main/src/components/layout/Sidebar.tsx"
click node_tour "https://github.com/codebyvimal/stash/blob/main/src/components/layout/AppTourModal.tsx"
click node_auth "https://github.com/codebyvimal/stash/blob/main/src/hooks/useAuth.ts"
click node_authscreen "https://github.com/codebyvimal/stash/blob/main/src/components/auth/AuthScreen.tsx"
click node_dashboard "https://github.com/codebyvimal/stash/blob/main/src/components/dashboard/TaskPlanner.tsx"
click node_economy "https://github.com/codebyvimal/stash/blob/main/src/components/dashboard/BalanceHeader.tsx"
click node_rewards "https://github.com/codebyvimal/stash/blob/main/src/components/rewards/RewardsTab.tsx"
click node_claim "https://github.com/codebyvimal/stash/blob/main/src/components/rewards/ClaimModal.tsx"
click node_history "https://github.com/codebyvimal/stash/blob/main/src/components/history/HistoryTab.tsx"
click node_resilience "https://github.com/codebyvimal/stash/blob/main/src/components/ui/ErrorBoundary.tsx"
click node_store "https://github.com/codebyvimal/stash/blob/main/src/hooks/useStore.ts"
click node_types "https://github.com/codebyvimal/stash/blob/main/src/types.ts"
click node_supabaseclient "https://github.com/codebyvimal/stash/blob/main/src/lib/supabase.ts"
click node_schema "https://github.com/codebyvimal/stash/blob/main/supabase/schema.sql"
click node_pwa "https://github.com/codebyvimal/stash/blob/main/public/manifest.json"
click node_container "https://github.com/codebyvimal/stash/blob/main/Dockerfile"
click node_vercel "https://github.com/codebyvimal/stash/blob/main/vercel.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_app,node_shell,node_navigation,node_tour,node_auth,node_authscreen,node_dashboard,node_economy,node_rewards,node_claim,node_history,node_resilience toneBlue
class node_store,node_types,node_supabaseclient toneAmber
class node_schema toneMint
class node_pwa,node_container,node_vercel toneRose
```

## Components

### React client

- [Vite entry](https://github.com/codebyvimal/stash/blob/main/src/main.tsx): bootstrap · `src/main.tsx`
- [App root](https://github.com/codebyvimal/stash/blob/main/src/App.tsx): application shell · Coordinates top-level state and active experience. · `src/App.tsx`
- [Authenticated shell](https://github.com/codebyvimal/stash/blob/main/src/components/layout/AppShell.tsx): layout · `src/components/layout/AppShell.tsx`
- [Desktop & mobile navigation](https://github.com/codebyvimal/stash/blob/main/src/components/layout/Sidebar.tsx): navigation · `src/components/layout/Sidebar.tsx`
- [First-use tour](https://github.com/codebyvimal/stash/blob/main/src/components/layout/AppTourModal.tsx): onboarding modal · `src/components/layout/AppTourModal.tsx`
- [Authentication](https://github.com/codebyvimal/stash/blob/main/src/hooks/useAuth.ts): auth hook & screen · `src/hooks/useAuth.ts`
- [Auth screen](https://github.com/codebyvimal/stash/blob/main/src/components/auth/AuthScreen.tsx): auth UI · `src/components/auth/AuthScreen.tsx`
- [Task dashboard](https://github.com/codebyvimal/stash/blob/main/src/components/dashboard/TaskPlanner.tsx): operational UI · Plans, creates, completes, and previews task/reward activity. · `src/components/dashboard/TaskPlanner.tsx`
- [Balance & activity](https://github.com/codebyvimal/stash/blob/main/src/components/dashboard/BalanceHeader.tsx): dashboard UI · Shows earned balance and resulting activity. · `src/components/dashboard/BalanceHeader.tsx`
- [Reward management](https://github.com/codebyvimal/stash/blob/main/src/components/rewards/RewardsTab.tsx): rewards UI · Manages rewards and their cards. · `src/components/rewards/RewardsTab.tsx`
- [Reward claim](https://github.com/codebyvimal/stash/blob/main/src/components/rewards/ClaimModal.tsx): spending modal · Claims a reward through an atomic store mutation. · `src/components/rewards/ClaimModal.tsx`
- [Activity history](https://github.com/codebyvimal/stash/blob/main/src/components/history/HistoryTab.tsx): history UI · Groups and renders task and transaction activity. · `src/components/history/HistoryTab.tsx`
- [UI feedback boundaries](https://github.com/codebyvimal/stash/blob/main/src/components/ui/ErrorBoundary.tsx): error & feedback UI · Error boundary, confirmations, and toast feedback. · `src/components/ui/ErrorBoundary.tsx`

### State & services

- [Zustand store](https://github.com/codebyvimal/stash/blob/main/src/hooks/useStore.ts): durable client state · Owns tasks, balances, rewards, transactions, and mutations. · `src/hooks/useStore.ts`
- [Domain types](https://github.com/codebyvimal/stash/blob/main/src/types.ts): shared model · Task, reward, activity, and transaction shapes. · `src/types.ts`
- [Supabase adapter](https://github.com/codebyvimal/stash/blob/main/src/lib/supabase.ts): integration boundary · Optional remote auth and data integration. · `src/lib/supabase.ts`

### Optional Supabase

- [Supabase schema](https://github.com/codebyvimal/stash/blob/main/supabase/schema.sql): database schema · Owns remote tables and auth-service boundary. · `supabase/schema.sql`

### Delivery & offline

- [Offline PWA assets](https://github.com/codebyvimal/stash/blob/main/public/manifest.json): manifest & service worker · `public/manifest.json`
- [Static container delivery](https://github.com/codebyvimal/stash/blob/main/Dockerfile): Docker & nginx · `Dockerfile`
- [Vercel delivery](https://github.com/codebyvimal/stash/blob/main/vercel.json): deployment config · `vercel.json`

## Connections

- 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
