The public website, on your device.
Discover routines and social stories, customize personal versions, use them interactively, and export PDFs. This app consumes the public Node.js API we documented earlier.
Shared catalog
React Query and Axios load activities, templates, stories, visuals, and categories from the backend.
Personal workspace
Redux holds saved content and progress. Browser storage persists personal records and preferences.
Browser exports
React PDF generates downloads and print previews from local state and fetched images.
Logical architecture based on source. Cloudflare hosting is configured, not live-verified. R2 storage is confirmed by the previously supplied backend code.
Follow a user action.
Choose a scenario. Diagrams read top to bottom; text steps appear below.
Different state, different responsibilities.
| Layer | What it holds | Lifetime / source |
|---|---|---|
| Component state | Unsaved editor fields, dialogs, current choices, status | useState / useRef; scoped to components |
| React Query | API results, errors, loading, saved-content resolution | Memory cache; global staleTime 5 minutes; scoped catalog gcTime 30 minutes |
| Redux Toolkit | socialStories.stories, schedules.schedules, schedules.scheduleProgress | Shared application state initialized from browser storage |
| localStorage | schedules, scheduleProgress, visualStepsStories, favorites, history, display/privacy settings | Same browser origin, until cleared or unavailable |
| PostgreSQL | Shared catalog and public submissions | Backend-owned records accessed through API |
| R2 / asset URLs | Pictures for display and PDF preparation | Image bytes separate from saved personal records |
Local saves are not account synchronization
The inspected flow does not upload personal routines or stories to a user account. Clearing site storage or changing browser/origin can make saves unavailable. Routine backup UI exists. localStorage is not a server backup.
Compact records still depend on catalog data
Routine saves use activity references and customization. Story storage version 2 stores page IDs and overrides, avoiding repeated library image metadata when a visual ID exists. useSavedStory resolves references through API/cache. A saved record does not guarantee full offline functionality.
Provider composition
main.jsx mounts StrictMode → HelmetProvider → Redux Provider → QueryClientProvider → BrowserRouter → AppErrorBoundary → App. ScrollToTop is also inside BrowserRouter. The store subscribes to relevant changes and persists schedules, progress, and compact stories.
From discovery to daily use.
| URL family | Purpose |
|---|---|
| / · /search | Homepage and global search |
| /routines · /routines/:slug | Browse and view ready-made routines |
| /routines/create · /routines/:slug/customize | Build from scratch or adapt a shared template |
| /my-routines · /routines/:scheduleId/view, /use, /edit | Manage, view, run, and edit local routines; suffixes summarize separate routes |
| /social-stories · /social-stories/:slug | Browse and view shared stories |
| /social-stories/create · /social-stories/:slug/customize · /social-stories/:storyId/edit | Story builder |
| /my-stories · /social-stories/:storyId/view | Saved stories and reader |
| /social-stories/saved-templates/:storyId/view | Personal saved-template view |
| /request-resource · /feedback | Forms that POST to the backend |
| /resources/* · feature how-it-works and guides | Learning and support content |
| /about · /contact · /faq · legal pages | Information and policy pages |
| * | In-app not-found screen |
App.jsx mounts pages inside Layout. BrowserRouter handles navigation. Cloudflare’s configured SPA fallback supports client-side paths.
Every package, tied to its actual role.
17 runtime and 11 development dependencies. Version ranges are declarations from package.json, not installed-version verification.
| Runtime package / range | Role | Source |
|---|---|---|
@dnd-kit/core^6.3.1 | Drag-and-drop contexts, sensors, and collision handling for activity and story-page lists. | RoutineSelectedActivities.jsx; StoryPageList.jsx |
@dnd-kit/sortable^10.0.0 | Sortable items and arrayMove let users reorder activities and pages. | RoutineSelectedActivities.jsx; useStoryPages.js |
@dnd-kit/utilities^3.2.2 | Converts drag transforms to CSS values so items move visibly. | RoutineSelectedActivities.jsx; StoryPageList.jsx |
@react-pdf/renderer^4.9.0 | Builds PDF documents from React PDF components in the browser. Active export paths dynamically load it; these are document layouts rather than web-page screenshots. | useSchedulePdf.jsx; social-stories/utils/storyExport.js |
@reduxjs/toolkit^2.12.0 | Creates the central Redux store and schedule/story slices. Tracks saved content and progress; persistence is implemented separately. | store/store.js; store/slices/ |
@tanstack/react-query^5.103.1 | Loads and caches API data and tracks loading/error states. Defaults: 5-minute stale time, one retry, no window-focus refetch. Hooks can override these defaults. | main.jsx; hooks/ |
axios^1.20.0 | Sends API requests through axiosClient: VITE_API_BASE_URL, JSON headers, 45-second timeout. No Clerk token interceptor is present here. | api/axiosClient.js |
buffer^6.0.3 | Supplies Node-style Buffer support for browser PDF dependencies, assigning globalThis.Buffer only if missing. | utils/pdfBuffer.js |
driver.js^1.8.0 | Provides interactive guided tours in the routine and story builders. | RoutineBuilderEditor.jsx; SocialStoryBuilderPage.jsx |
html2canvas^1.4.1 | Can render HTML to canvas. No import/use found in supplied src or scripts; listed dependency only. Current PDF paths use React PDF. | package.json; source usage search |
jspdf^4.2.1 | Can create PDFs in JavaScript. No import/use found in supplied src or scripts; do not infer it powers current exports. | package.json; source usage search |
lucide-react^1.48.0 | React icons for navigation, actions, sharing, feedback, and other UI. | TemplateActions.jsx and UI components |
react^19.2.8 | Components, state, effects, refs, and interactive rendering. Unsaved editor values stay in component state before Save. | src/ |
react-dom^19.2.8 | Mounts the app with createRoot; flushSync also appears in the story builder. hydrateRoot is not used at the entry point. | main.jsx; SocialStoryBuilderPage.jsx |
react-helmet-async^3.0.0 | Manages document titles, SEO/social metadata, canonical tags, and structured data via HelmetProvider and Helmet. It is different from backend helmet. | components/SEO.jsx; StructuredData.jsx; main.jsx |
react-redux^9.3.0 | Connects React to Redux through Provider, useSelector, and useDispatch. Toolkit defines the store; this package connects components to it. | main.jsx; feature pages and hooks |
react-router-dom^7.18.4 | Maps URLs to pages and provides navigation, route parameters, and location state. Layout wraps the public routes. | App.jsx; main.jsx |
Development tools
| Development package / range | Role | Source |
|---|---|---|
@eslint/js^10.0.1 | Standard JavaScript lint configurations; exact enabled rules cannot be verified without the omitted ESLint config. | package.json |
@types/react^19.2.18 | React type definitions for editor tooling and TypeScript consumers; this does not mean the JSX app uses TypeScript. | package.json |
@types/react-dom^19.2.7 | React DOM type definitions for tooling. | package.json |
@vitejs/plugin-react^6.1.1 | React integration and development refresh support for Vite; plugin wiring cannot be verified without the Vite config. | package.json |
eslint^10.10.0 | Static JavaScript checks through npm run lint; config not included. | package.json |
eslint-plugin-react-hooks^7.1.1 | Lint rules for hook usage and related React checks; enabled rules depend on omitted config. | package.json |
eslint-plugin-react-refresh^0.5.6 | Lint rules supporting Fast Refresh compatibility; config not supplied. | package.json |
globals^17.12.0 | Environment global-name lists for lint configuration. | package.json |
vite^8.3.0 | Development server, production asset build, and local build preview. | package.json; scripts/build-prerender.mjs |
wait-on^9.5.1 | Waits for the temporary preview server before SEO prerendering. | scripts/build-prerender.mjs |
wrangler^4.151.0 | Cloudflare tooling. wrangler.jsonc configures Worker/static assets; no deploy script is declared in package.json. | wrangler.jsonc; package.json |
Vite builds it. Cloudflare serves it.
Optional SEO build
build:seo runs Vite, then starts a preview server on port 4173. wait-on waits for it. prerender.mjs uses Playwright to render selected static pages and routine/story slugs obtained from the API into dist. Normal build does not run this extra step.
Worker behavior
worker/index.js forwards only /sitemap.xml to API_ORIGIN and returns XML with a one-hour cache header. Other requests use env.ASSETS.fetch. It is not a general API proxy. Browser API requests use VITE_API_BASE_URL independently.
Configuration inputs
VITE_API_BASE_URL configures Axios; VITE_PUBLIC_SITE_URL supports public sharing links. PRERENDER_API_URL and PRERENDER_PREVIEW_URL control prerender sources. Worker API_ORIGIN is for the sitemap. Frontend VITE variables are client-visible settings, not backend secrets.
Archive completeness
Supplied folders: src, scripts, worker, plus package.json and wrangler.jsonc. Missing: index.html, public assets, Vite/ESLint config, lockfile, and environment files. The prerender script imports Playwright, which is not declared in this package.json; it may be supplied by a wider workspace. This archive alone is not a verified runnable build.
Rendering and validation scope
The entry uses createRoot rather than hydrateRoot despite the optional captured HTML. Tests are present, but no test script is declared. This guide uses static source inspection; app tests, build, and live deployment were not run. No application source was changed.
React and Node.js, connected.
| Frontend action | Destination | Meaning |
|---|---|---|
| Browse catalog | Public API GET → PostgreSQL | Shared server content |
| Save personal routine/story | localStorage + Redux | Browser save, not cloud save |
| Resource request / general feedback | POST /resource-requests or /feedback | Backend stores a community submission |
| Helpfulness choice | POST /template-feedback | 30/min route limit plus global backend limit |
| Load image | Public URL, commonly R2 | Separate from JSON delivery |
| Export PDF | Browser image processing + React PDF | Does not call sharp or a server PDF endpoint |
| Manage shared catalog / upload image | Backend /api/admin endpoints | Admin frontend not supplied here |
| Sitemap | Cloudflare Worker → Node /sitemap.xml | Backend-generated sitemap exposed by website host |
Open the companion Node.js guide (keep both HTML files together).
Where to look in the code.
| Area | Files |
|---|---|
| Composition / navigation | src/main.jsx; src/App.jsx |
| API / caching | src/api/axiosClient.js; scopedCatalogApi.js; src/hooks/useScopedCatalog.js |
| Storage | src/store/store.js; store/slices/; RoutineBuilderEditor.jsx; social-stories/utils/storyStorage.js; useSavedStory.js |
| Active PDF export | schedule/hooks/useSchedulePdf.jsx; social-stories/hooks/useStoryPdf.js; social-stories/utils/storyExport.js; utils/pdfBuffer.js |
| Sharing / submissions | TemplateActions.jsx; templateSharing.js; FeedbackPage.jsx; RequestResourcePage.jsx |
| Build / hosting | package.json; scripts/build-prerender.mjs; scripts/prerender.mjs; wrangler.jsonc; worker/index.js |