How binit-nayak/sneaky works
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: App.tsx App shell & routes · sneakyStore.ts Sneaky Redux store · api.ts Common API transport · Home.tsx Discovery home
Components 19
React application
- Application entry
src/main.tsx - App shell & routes
src/App.tsx - Adaptive navigation · Regular and responsive navigation.
src/components/NavBar/NavBar.tsx - Discovery home
src/pages/Home/Home.tsx - Swipe card content
src/pages/Home/HomeContent.tsx - Home actions
src/pages/Home/useHomeActions.ts - Cart
src/pages/Cart/Cart.tsx - Wishlist
src/pages/WishList/Wishlist.tsx - Admin views
src/pages/Admin/Admin.tsx
Client state
- Authentication context · Centralizes session and authenticated UI state.
src/context/AuthContext.tsx - Sneaky Redux store · Source of truth for products, cart, and wishlist.
src/store/sneakyStore.ts - Sneaky domain slice
src/store/sneakyState/sneakySlice.ts - Notifications context · Independent in-app reminder state.
src/context/NotificationsContext.tsx - Async domain operations · Fetches and mutations such as product loading and cart quantity updates.
src/store/fetchAPI/fetchProducts.ts
Backend integration
- Common API transport
src/services/api.ts - External backend API · Provides auth, products, cart, wishlist, and notifications.
- Merchant checkout · Cart groups expose delegated merchant checkout links.
Static deployment
- Asset service worker · Caches images and empty-state assets for repeat visits.
public/service-worker.js - Nginx static site · Nginx serves the Vite build output.
Dockerfile
Connections 23
- 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