How aaron-howard/e-commerce works
1. Overall shape
- This is a SvelteKit storefront MVP. The app is entirely client-side mocked: products, users, cart, checkout, and orders are all simulated in-memory or via localStorage, with no backend API, payment gateway, or database.
2. Primary UI shell
- src/routes/+layout.svelte provides the shared application frame.
- src/lib/components/Nav.svelte and Footer.svelte are the main cross-page UI boundaries, reused by marketing and commerce pages.
3. Route structure
- The app is organized by user journey:
- Marketing/content: /, /about, /collections, /journal
- Commerce browsing: /shop, /product/[slug]
- Transaction flow: /cart, /checkout/shipping, /checkout/payment
- Identity/account: /login, /signup, /account
- Orders: /orders/[id]
- Dynamic routes for product and order details are driven by URL params and route-specific load logic.
4. Data layer
- Canonical mock content lives in src/lib/data/:
- products.ts for the catalog
- collections.ts for collection metadata / deep-linking
- mockUser.ts for simulated user identity
- These files act as the app’s source of truth for displayed commerce content.
5. State management boundary
- Persistent client state is centralized in src/lib/stores/ using Svelte stores.
- The main stores are:
- cart.ts for cart contents
- checkout.ts for checkout progression and form state
- auth.ts for mock sign-in/sign-up state
- orders.ts for persisted mock orders
- readJsonArray.ts suggests a small persistence helper around localStorage or JSON-serialized arrays.
6. Checkout and order flow
- The transaction path is a two-step wizard:
- shipping information
- payment review
- src/lib/order/placeOrder.ts likely converts the current cart + checkout state into a persisted order record.
- totalsFromSubtotal.ts encapsulates business logic for shipping/tax/total calculations, keeping pricing rules separate from UI.
7. Catalog and product browsing flow
- /shop is the main browsing entry point and supports search and category/collection filters.
- /collections provides deep links into the catalog via ?collection=....
- /product/[slug] resolves a single product from the mock catalog and supports quantity selection plus add-to-cart.
8. Order detail and persistence
- /orders/[id] is a client-only order confirmation/detail view, meaning the order record must already exist in local persisted state.
- This creates a clear dependency chain: cart → checkout → place order → orders store → order detail route.
9. Account flow
- /login, /signup, and /account are mock identity screens tied to the auth store and mock user data.
- There is no real authentication boundary; the “account” experience is a UI/state simulation for the storefront demo.
10. Styling and design system
- src/routes/layout.css contains the global visual tokens, aligned to the Stitch/Digital Atelier palette.
- The repository includes stitch_e-commerce/stitch/ as a reference artifact set: exported HTML and design docs used to port the visual system, but not executed by the app.
11. Execution/runtime boundaries
- Since the app has no server-side data sources, the main runtime boundary is the browser itself.
- Persistence, navigation state, and mock business logic all live in the client, which makes the architecture simple but also means reloads depend on local storage for continuity.
12. What to draw in an architecture diagram
- A good diagram would show:
- SvelteKit route layer on top
- shared components and layout beneath it
- mock data modules as static inputs
- Svelte stores as the central state hub
- order/pricing helpers as business-logic services
- browser localStorage as the only persistence layer
- the Stitch folder as an external design reference, not a runtime dependency
Main entry points: +layout.svelte App shell · stores Stores · placeOrder.ts Place order · +page.svelte Product detail
Components 24
SvelteKit routes
Client-side pages and route-specific load logic.
- App shell · Shared application frame for all routes.
src/routes/+layout.svelte - Home · Marketing entry page.
src/routes/+page.svelte - About · Brand/about information page.
src/routes/about/+page.svelte - Collections · Collection deep links into the product catalog.
src/routes/collections/+page.svelte - Journal · Content/editorial browsing page.
src/routes/journal/+page.svelte - Shop · Primary product listing with search and filters.
src/routes/shop/+page.svelte - Product detail · Single product view driven by slug params.
src/routes/product/[slug]/+page.svelte - Cart · Cart review and quantity management.
src/routes/cart/+page.svelte - Shipping · Shipping information step in the checkout wizard.
src/routes/checkout/shipping/+page.svelte - Payment · Payment review step in the checkout wizard.
src/routes/checkout/payment/+page.svelte - Login · Mock sign-in screen.
src/routes/login/+page.svelte - Signup · Mock sign-up screen.
src/routes/signup/+page.svelte - Account · Client-side account view bound to mock auth state.
src/routes/account/+page.svelte - Order detail · Persisted order confirmation/detail view driven by id params.
src/routes/orders/[id]/+page.svelte
Shared UI
Layout shell and reusable components across pages.
Client state
Svelte stores plus persistence helpers for mock app state.
- Stores · Central client state boundary for cart, checkout, auth, and orders.
src/lib/stores - Local storage · Only persistence layer for mock state continuity.
Mock content
Canonical in-memory catalog and identity data.
- Products · Canonical mock product catalog.
src/lib/data/products.ts - Collections data · Collection metadata and deep-link targets.
src/lib/data/collections.ts - Mock user · Simulated user identity used by auth/account flows.
src/lib/data/mockUser.ts
Commerce logic
Order placement and pricing calculations.
- Place order · Converts cart and checkout state into a persisted order record.
src/lib/order/placeOrder.ts - Totals · Shipping, tax, and total calculations.
src/lib/order/totalsFromSubtotal.ts
Design reference
Stitch export artifacts used as visual/source reference, not runtime dependencies.
- Stitch refs · Reference HTML and design docs for visual implementation; not executed by the app.
stitch_e-commerce/stitch
Connections 36
- App shell → Nav: renders · The app shell composes shared navigation.
- App shell → Footer: renders · The app shell composes shared footer.
- App shell → Home: wraps · Shared frame applies to all top-level routes.
- App shell → About: wraps · Shared frame applies to all top-level routes.
- App shell → Collections: wraps · Shared frame applies to all top-level routes.
- App shell → Journal: wraps · Shared frame applies to all top-level routes.
- App shell → Shop: wraps · Shared frame applies to all top-level routes.
- App shell → Product detail: wraps · Shared frame applies to all top-level routes.
- App shell → Cart: wraps · Shared frame applies to all top-level routes.
- App shell → Shipping: wraps · Shared frame applies to all top-level routes.
- App shell → Payment: wraps · Shared frame applies to all top-level routes.
- App shell → Login: wraps · Shared frame applies to all top-level routes.
- App shell → Signup: wraps · Shared frame applies to all top-level routes.
- App shell → Account: wraps · Shared frame applies to all top-level routes.
- App shell → Order detail: wraps · Shared frame applies to all top-level routes.
- Home → Products: reads · Marketing and storefront pages draw from mock catalog content.
- Collections → Collections data: reads · Collection page uses catalog grouping metadata.
- Shop → Products: reads · Shop listing is driven by canonical catalog data.
- Product detail → Products: loads · Slug-based detail route resolves one product from the catalog.
- Cart → Stores: uses · Cart state is sourced from the central stores boundary.
- Shipping → Stores: uses · Checkout step reads and updates shared checkout state.
- Payment → Stores: uses · Checkout step reads and updates shared checkout state.
- Login → Stores: uses · Mock sign-in state flows through auth store.
- Signup → Stores: uses · Mock sign-up state flows through auth store.
- Account → Stores: uses · Account screen reflects simulated auth/account state.
- Order detail → Stores: reads · Order detail route looks up persisted orders.
- Stores → Local storage: persists to · Persistent client state survives reloads through browser storage.
- Place order → Stores: reads/writes · Order placement consumes cart and checkout state and updates orders.
- Place order → Totals: uses · Order placement relies on pricing calculations.
- Place order → Local storage: persists to · Placed orders are stored in browser persistence.
- Shipping → Place order: advances · Shipping step feeds into order placement flow.
- Payment → Place order: confirms · Payment review triggers final order creation.
- Product detail → Stores: adds to cart · Product detail page drives cart mutations through stores.
- Stitch refs → App shell: references · Visual system reference informs the app shell and styling.
- Stitch refs → Collections: references · Design artifacts mirror the storefront's collection page.
- Stitch refs → Product detail: references · Design artifacts mirror the product detail experience.