# binit-nayak/sneaky architecture

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

- Interactive diagram: https://gitdiagram.com/binit-nayak/sneaky
- Repository: https://github.com/binit-nayak/sneaky

## Overview

#### Purpose and runtime
Sneaky is a Vite-built React 18/TypeScript single-page product-discovery application. It presents a swipe-style recommended-product feed and supports authenticated cart, wishlist, notification, profile, and admin experiences. The browser app is deployed as a containerized static site, with Nginx serving build output; its API-backed state comes from an external backend.
Paths: `src/main.tsx`, `Dockerfile`, `nginx.conf`, `render.yaml`.

#### Bootstrap, routing, and page composition
`main.tsx` mounts the application; `App.tsx` is the application shell and route composition boundary. Route-level pages separate primary user journeys: landing/auth entry, product discovery, cart/wishlist, notifications, profile, and administrative views. Shared navigation adapts between regular and responsive layouts.
Paths: `src/main.tsx`, `src/App.tsx`, `src/pages/Home/Home.tsx`, `src/components/NavBar/NavBar.tsx`, `src/components/ResponsiveNav/ResponsiveNav.tsx`.

#### Authentication and authorization boundary
Authentication state is centralized in a React context, exposed through a dedicated hook, and backed by session/auth API modules. This layer determines authenticated UI behavior and provides the logical boundary for protected user state and role-oriented admin access.
Paths: `src/context/AuthContext.tsx`, `src/hooks/useAuth.ts`, `src/services/authAPI.ts`, `src/services/authSession.ts`, `src/pages/Admin/Admin.tsx`.

#### Product recommendation and swipe interaction
Home is the core discovery workflow: it retrieves backend-recommended products, renders card/content state, and routes user gestures/actions through home-specific action logic. Product-pass recording supports recommendation/analytics feedback, while categories and merchant links are represented in the UI flow.
Paths: `src/pages/Home/Home.tsx`, `src/pages/Home/HomeContent.tsx`, `src/pages/Home/useHomeActions.ts`, `src/services/productsAPI.ts`, `src/store/fetchAPI/recordProductPass.ts`.

#### Redux domain state and asynchronous mutations
Redux Toolkit is the client-side source of truth for product, cart, and wishlist data. `sneakyStore` wires the application store; `sneakySlice` and selectors represent state access. Operation-focused async modules encapsulate fetch and mutation flows—add/delete/move/clear/update—so pages dispatch domain actions rather than directly managing API state transitions.
Paths: `src/store/sneakyStore.ts`, `src/store/sneakyState/sneakySlice.ts`, `src/store/sneakyState/sneakySelectors.ts`, `src/store/fetchAPI/fetchProducts.ts`, `src/store/fetchAPI/updateCartQuantity.ts`.

#### Cart, wishlist, and merchant checkout flow
Cart and wishlist pages consume shared Redux state and invoke dedicated API-backed operations. The system supports bidirectional item movement, quantity updates, individual removal, and clear-all. Backend cart data includes merchant checkout grouping/links, making checkout delegation an external merchant boundary rather than an in-repo payment implementation.
Paths: `src/pages/Cart/Cart.tsx`, `src/pages/WishList/Wishlist.tsx`, `src/services/cartAPI.ts`, `src/services/wishlistAPI.ts`, `src/store/fetchAPI/moveWishlistItemToCart.ts`.

#### Notifications, API transport, and browser performance
A notification context and API service support in-app reminders, independently of Redux cart/wishlist handling. API modules are organized by backend domain on top of a common API layer. A public service worker caches images and empty-state assets for repeat visits; static assets are served by the browser-facing frontend deployment.
Paths: `src/context/NotificationsContext.tsx`, `src/services/notificationsAPI.ts`, `src/services/api.ts`, `public/service-worker.js`, `src/services/productAnalyticsAPI.ts`.

Main entry points: [`src/App.tsx`](https://github.com/binit-nayak/sneaky/blob/main/src/App.tsx) (App shell & routes), [`src/store/sneakyStore.ts`](https://github.com/binit-nayak/sneaky/blob/main/src/store/sneakyStore.ts) (Sneaky Redux store), [`src/services/api.ts`](https://github.com/binit-nayak/sneaky/blob/main/src/services/api.ts) (Common API transport), [`src/pages/Home/Home.tsx`](https://github.com/binit-nayak/sneaky/blob/main/src/pages/Home/Home.tsx) (Discovery home)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["React application"]
  node_entry["Application entry<br/>React bootstrap<br/>[main.tsx]"]
  node_app["App shell &amp; routes<br/>route composition<br/>[App.tsx]"]
  node_navigation["Adaptive navigation<br/>shared UI<br/>[NavBar.tsx]"]
  node_home["Discovery home<br/>product feed page<br/>[Home.tsx]"]
  node_home_content["Swipe card content<br/>discovery UI<br/>[HomeContent.tsx]"]
  node_home_actions["Home actions<br/>gesture logic<br/>[useHomeActions.ts]"]
  node_cart["Cart<br/>user journey page<br/>[Cart.tsx]"]
  node_wishlist["Wishlist<br/>user journey page<br/>[Wishlist.tsx]"]
  node_admin["Admin views<br/>role-protected page<br/>[Admin.tsx]"]
end

subgraph group_state["Client state"]
  node_auth_context["Authentication context<br/>React context<br/>[AuthContext.tsx]"]
  node_store[("Sneaky Redux store<br/>Redux Toolkit store<br/>[sneakyStore.ts]")]
  node_sneaky_slice["Sneaky domain slice<br/>Redux slice<br/>[sneakySlice.ts]"]
  node_notifications["Notifications context<br/>React context"]
  node_domain_operations["Async domain operations<br/>Redux async actions<br/>[fetchProducts.ts]"]
end

subgraph group_api["Backend integration"]
  node_api_transport["Common API transport<br/>HTTP client layer<br/>[api.ts]"]
  node_backend{{"External backend API<br/>remote API"}}
  node_merchant{{"Merchant checkout<br/>external checkout"}}
end

subgraph group_deploy["Static deployment"]
  node_service_worker["Asset service worker<br/>browser cache<br/>[service-worker.js]"]
  node_static_deployment["Nginx static site<br/>container deployment"]
end

node_entry -->|"mounts"| node_app
node_app -->|"renders"| node_navigation
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_cart
node_app -->|"routes to"| node_wishlist
node_app -->|"routes to"| node_admin
node_app -->|"provides"| node_auth_context
node_app -->|"connects"| node_store
node_home -->|"composes"| node_home_content
node_home -->|"uses"| node_home_actions
node_home_actions -->|"dispatches"| node_domain_operations
node_cart -->|"reads and dispatches"| node_store
node_wishlist -->|"reads and dispatches"| node_store
node_admin -->|"requires role state"| node_auth_context
node_store -->|"contains"| node_sneaky_slice
node_domain_operations -->|"updates"| node_store
node_domain_operations -->|"calls"| node_api_transport
node_auth_context -->|"uses auth/session"| node_api_transport
node_notifications -->|"uses notifications API"| node_api_transport
node_api_transport -->|"HTTP requests"| node_backend
node_cart -->|"delegates checkout"| node_merchant
node_entry -.->|"browser registers"| node_service_worker
node_static_deployment -->|"serves built app"| node_entry

click node_entry "https://github.com/binit-nayak/sneaky/blob/main/src/main.tsx"
click node_app "https://github.com/binit-nayak/sneaky/blob/main/src/App.tsx"
click node_navigation "https://github.com/binit-nayak/sneaky/blob/main/src/components/NavBar/NavBar.tsx"
click node_home "https://github.com/binit-nayak/sneaky/blob/main/src/pages/Home/Home.tsx"
click node_home_content "https://github.com/binit-nayak/sneaky/blob/main/src/pages/Home/HomeContent.tsx"
click node_home_actions "https://github.com/binit-nayak/sneaky/blob/main/src/pages/Home/useHomeActions.ts"
click node_cart "https://github.com/binit-nayak/sneaky/blob/main/src/pages/Cart/Cart.tsx"
click node_wishlist "https://github.com/binit-nayak/sneaky/blob/main/src/pages/WishList/Wishlist.tsx"
click node_admin "https://github.com/binit-nayak/sneaky/blob/main/src/pages/Admin/Admin.tsx"
click node_auth_context "https://github.com/binit-nayak/sneaky/blob/main/src/context/AuthContext.tsx"
click node_store "https://github.com/binit-nayak/sneaky/blob/main/src/store/sneakyStore.ts"
click node_sneaky_slice "https://github.com/binit-nayak/sneaky/blob/main/src/store/sneakyState/sneakySlice.ts"
click node_notifications "https://github.com/binit-nayak/sneaky/blob/main/src/context/NotificationsContext.tsx"
click node_domain_operations "https://github.com/binit-nayak/sneaky/blob/main/src/store/fetchAPI/fetchProducts.ts"
click node_api_transport "https://github.com/binit-nayak/sneaky/blob/main/src/services/api.ts"
click node_service_worker "https://github.com/binit-nayak/sneaky/blob/main/public/service-worker.js"
click node_static_deployment "https://github.com/binit-nayak/sneaky/blob/main/Dockerfile"

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_entry,node_app,node_navigation,node_home,node_home_content,node_home_actions,node_cart,node_wishlist,node_admin toneBlue
class node_auth_context,node_store,node_sneaky_slice,node_notifications,node_domain_operations toneAmber
class node_api_transport,node_backend,node_merchant toneMint
class node_service_worker,node_static_deployment toneRose
```

## Components

### React application

- [Application entry](https://github.com/binit-nayak/sneaky/blob/main/src/main.tsx): React bootstrap · `src/main.tsx`
- [App shell & routes](https://github.com/binit-nayak/sneaky/blob/main/src/App.tsx): route composition · `src/App.tsx`
- [Adaptive navigation](https://github.com/binit-nayak/sneaky/blob/main/src/components/NavBar/NavBar.tsx): shared UI · Regular and responsive navigation. · `src/components/NavBar/NavBar.tsx`
- [Discovery home](https://github.com/binit-nayak/sneaky/blob/main/src/pages/Home/Home.tsx): product feed page · `src/pages/Home/Home.tsx`
- [Swipe card content](https://github.com/binit-nayak/sneaky/blob/main/src/pages/Home/HomeContent.tsx): discovery UI · `src/pages/Home/HomeContent.tsx`
- [Home actions](https://github.com/binit-nayak/sneaky/blob/main/src/pages/Home/useHomeActions.ts): gesture logic · `src/pages/Home/useHomeActions.ts`
- [Cart](https://github.com/binit-nayak/sneaky/blob/main/src/pages/Cart/Cart.tsx): user journey page · `src/pages/Cart/Cart.tsx`
- [Wishlist](https://github.com/binit-nayak/sneaky/blob/main/src/pages/WishList/Wishlist.tsx): user journey page · `src/pages/WishList/Wishlist.tsx`
- [Admin views](https://github.com/binit-nayak/sneaky/blob/main/src/pages/Admin/Admin.tsx): role-protected page · `src/pages/Admin/Admin.tsx`

### Client state

- [Authentication context](https://github.com/binit-nayak/sneaky/blob/main/src/context/AuthContext.tsx): React context · Centralizes session and authenticated UI state. · `src/context/AuthContext.tsx`
- [Sneaky Redux store](https://github.com/binit-nayak/sneaky/blob/main/src/store/sneakyStore.ts): Redux Toolkit store · Source of truth for products, cart, and wishlist. · `src/store/sneakyStore.ts`
- [Sneaky domain slice](https://github.com/binit-nayak/sneaky/blob/main/src/store/sneakyState/sneakySlice.ts): Redux slice · `src/store/sneakyState/sneakySlice.ts`
- [Notifications context](https://github.com/binit-nayak/sneaky/blob/main/src/context/NotificationsContext.tsx): React context · Independent in-app reminder state. · `src/context/NotificationsContext.tsx`
- [Async domain operations](https://github.com/binit-nayak/sneaky/blob/main/src/store/fetchAPI/fetchProducts.ts): Redux async actions · Fetches and mutations such as product loading and cart quantity updates. · `src/store/fetchAPI/fetchProducts.ts`

### Backend integration

- [Common API transport](https://github.com/binit-nayak/sneaky/blob/main/src/services/api.ts): HTTP client layer · `src/services/api.ts`
- **External backend API**: remote API · Provides auth, products, cart, wishlist, and notifications.
- **Merchant checkout**: external checkout · Cart groups expose delegated merchant checkout links.

### Static deployment

- [Asset service worker](https://github.com/binit-nayak/sneaky/blob/main/public/service-worker.js): browser cache · Caches images and empty-state assets for repeat visits. · `public/service-worker.js`
- [Nginx static site](https://github.com/binit-nayak/sneaky/blob/main/Dockerfile): container deployment · Nginx serves the Vite build output. · `Dockerfile`

## Connections

- Application entry → App shell & routes: mounts
- App shell & routes → Adaptive navigation: renders
- App shell & routes → Discovery home: routes to
- App shell & routes → Cart: routes to
- App shell & routes → Wishlist: routes to
- App shell & routes → Admin views: routes to
- App shell & routes → Authentication context: provides
- App shell & routes → Sneaky Redux store: connects
- Discovery home → Swipe card content: composes
- Discovery home → Home actions: uses
- Home actions → Async domain operations: dispatches
- Cart → Sneaky Redux store: reads and dispatches
- Wishlist → Sneaky Redux store: reads and dispatches
- Admin views → Authentication context: requires role state
- Sneaky Redux store → Sneaky domain slice: contains
- Async domain operations → Sneaky Redux store: updates
- Async domain operations → Common API transport: calls
- Authentication context → Common API transport: uses auth/session
- Notifications context → Common API transport: uses notifications API
- Common API transport → External backend API: HTTP requests
- Cart → Merchant checkout: delegates checkout
- Application entry → Asset service worker: browser registers
- Nginx static site → Application entry: serves built app
