mini-product-dashboard-svelte Svelte Themes

Mini Product Dashboard Svelte

Mini product dashboard with svelte

FakeStore Dashboard (SvelteKit + Tailwind 4)

Features

  • Product List + Search + Filter + Pagination
  • Product Detail + Breadcrumb
  • Category Page
  • Responsive Layout
  • Caching Store (Svelte writable)
  • Dark Mode Toggle

Tech Stack

  • SvelteKit
  • TailwindCSS v4
  • TypeScript

Run

pnpm install / npm install
pnpm run dev / npm run dev

FakeStore Dashboard (SvelteKit + Tailwind 4)

A modern, scalable e-commerce dashboard built with SvelteKit and TailwindCSS v4, featuring product listing, search, filtering, and dark mode with comprehensive unit testing.

โœจ Features

  • ๐Ÿ“ฆ Product Management: Product list with search, filter, and pagination
  • ๐Ÿ” Product Detail: Detailed product view with breadcrumb navigation
  • ๐Ÿ“‚ Category Pages: Browse products by category
  • ๐Ÿ“ฑ Responsive Layout: Mobile-first responsive design
  • ๐ŸŒ“ Dark Mode: Persistent dark mode toggle with localStorage
  • ๐Ÿ’พ Caching: Client-side caching using Svelte stores
  • โšก Lazy Loading: Image lazy loading with IntersectionObserver
  • ๐Ÿงช Unit Testing: Comprehensive tests with Vitest
  • ๐ŸŽฏ Type Safety: Full TypeScript support with proper typing
  • ๐Ÿ—๏ธ Scalable Architecture: Clean code structure with composables and utilities

๐Ÿ› ๏ธ Tech Stack

  • Framework: SvelteKit 2.x (Svelte 5)
  • Styling: TailwindCSS v4
  • Language: TypeScript
  • Testing: Vitest + @testing-library/svelte
  • API: FakeStore API

๐Ÿš€ Getting Started

Installation

# Install dependencies
pnpm install
# or
npm install

Development

# Start dev server
pnpm dev
# or
npm run dev

Visit http://localhost:5173

Build

# Build for production
pnpm build
# or
npm run build

Preview Production Build

pnpm preview
# or
npm run preview

๐Ÿงช Testing

# Run tests
pnpm test

# Run tests in UI mode
pnpm test:ui

# Run tests with coverage
pnpm test:coverage

๐Ÿ“ Project Structure

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

๐Ÿ—๏ธ Architecture & Design Patterns

Composables (Custom Hooks)

Located in src/lib/composables/, these provide reusable logic:

  • useIntersectionObserver: Lazy loading images with IntersectionObserver
  • useProducts: Product data fetching and state management

Store Management

All global state is managed through Svelte stores:

  • productsStore: Cached product data
  • categoriesStore: Available categories
  • darkModeStore: Dark mode state with localStorage persistence

Type Safety

Full TypeScript support with interfaces in src/lib/types/:

  • Product: Product data structure
  • PaginatedResponse: API pagination response
  • Category: Category type

Utilities

Clean, testable utility functions:

  • api.ts: API client with error handling
  • debounce.ts: Generic debounce function
  • filters.ts: Product filtering and sorting

๐ŸŽจ Dark Mode

Dark mode is implemented with:

  • Toggle button in the header
  • Persistent state using localStorage
  • Smooth transitions
  • Applies to all pages and components

๐Ÿงช Testing Strategy

Unit Tests

  • โœ… API client (api.test.ts)
  • โœ… Debounce utility (debounce.test.ts)
  • โœ… Filter utilities (filters.test.ts)

Test Coverage

Run pnpm test:coverage to see detailed coverage report.

๐Ÿ“ Code Quality

  • Clean Code: Following SOLID principles
  • Separation of Concerns: Clear separation between UI, logic, and data
  • DRY Principle: Reusable composables and utilities
  • Type Safety: Comprehensive TypeScript typing
  • Error Handling: Proper error handling in API calls

๐Ÿ”„ API Integration

Using FakeStore API for demo data:

  • GET /products - All products
  • GET /products/:id - Single product
  • GET /products/categories - All categories
  • GET /products/category/:name - Products by category

๐Ÿš€ Performance Optimizations

  • Lazy loading images with IntersectionObserver
  • Client-side caching with Svelte stores
  • Debounced search input
  • Pagination for better data handling

๐Ÿ“„ License

MIT

๐Ÿค Contributing

Contributions, issues and feature requests are welcome!


Built with โค๏ธ using SvelteKit and TailwindCSS

Top categories

Loading Svelte Themes