pnpm install / npm install
pnpm run dev / npm run dev
A modern, scalable e-commerce dashboard built with SvelteKit and TailwindCSS v4, featuring product listing, search, filtering, and dark mode with comprehensive unit testing.
# Install dependencies
pnpm install
# or
npm install
# Start dev server
pnpm dev
# or
npm run dev
Visit http://localhost:5173
# Build for production
pnpm build
# or
npm run build
pnpm preview
# or
npm run preview
# Run tests
pnpm test
# Run tests in UI mode
pnpm test:ui
# Run tests with coverage
pnpm test:coverage
src/
โโโ lib/
โ โโโ components/ # Reusable Svelte components
โ โ โโโ Pagination.svelte
โ โ โโโ ProductCard.svelte
โ โโโ composables/ # Reusable logic (hooks)
โ โ โโโ useIntersectionObserver.ts
โ โ โโโ useProducts.ts
โ โโโ store/ # Svelte stores (state management)
โ โ โโโ products.ts # Products & dark mode store
โ โโโ types/ # TypeScript type definitions
โ โ โโโ index.ts
โ โโโ utils/ # Utility functions
โ โ โโโ api.ts # API client
โ โ โโโ debounce.ts # Debounce utility
โ โ โโโ filters.ts # Product filter utilities
โ โโโ assets/ # Static assets
โโโ routes/ # SvelteKit routes
โ โโโ +layout.svelte # Root layout
โ โโโ +page.svelte # Home (product list)
โ โโโ product/
โ โ โโโ [id]/ # Product detail page
โ โโโ category/
โ โโโ [name]/ # Category page
โโโ tests/ # Test setup
โ โโโ setup.ts
โโโ app.css # Global styles
Located in src/lib/composables/, these provide reusable logic:
useIntersectionObserver: Lazy loading images with IntersectionObserveruseProducts: Product data fetching and state managementAll global state is managed through Svelte stores:
productsStore: Cached product datacategoriesStore: Available categoriesdarkModeStore: Dark mode state with localStorage persistenceFull TypeScript support with interfaces in src/lib/types/:
Product: Product data structurePaginatedResponse: API pagination responseCategory: Category typeClean, testable utility functions:
api.ts: API client with error handlingdebounce.ts: Generic debounce functionfilters.ts: Product filtering and sortingDark mode is implemented with:
api.test.ts)debounce.test.ts)filters.test.ts)Run pnpm test:coverage to see detailed coverage report.
Using FakeStore API for demo data:
GET /products - All productsGET /products/:id - Single productGET /products/categories - All categoriesGET /products/category/:name - Products by categoryMIT
Contributions, issues and feature requests are welcome!
Built with โค๏ธ using SvelteKit and TailwindCSS