sveltekit-todo-assessment Svelte Themes

Sveltekit Todo Assessment

SvelteKit Todo App with Supabase and shadcn-svelte for Stewart Brothers assessment

Quick-List ๐Ÿ“

A modern, responsive todo application built with SvelteKit and Supabase. Stay organized and get things done with a clean, intuitive interface.

โœจ Features

  • ๐Ÿ” Authentication: Secure user registration and login with Supabase Auth
  • ๐Ÿ“‹ Todo Management: Create, read, update, and delete todos
  • โœ… Task Completion: Toggle task completion status
  • ๐Ÿ“Š Progress Tracking: Visual stats showing total, active, and completed tasks
  • ๐ŸŽจ Modern UI: Clean, responsive design with Tailwind CSS
  • ๐ŸŒ™ Dark Mode: Built-in dark/light mode toggle
  • ๐Ÿ“ฑ Mobile Friendly: Fully responsive design for all devices
  • โšก Real-time: Instant updates with Supabase real-time features
  • ๐Ÿ”’ Secure: Row-level security with user-specific data isolation

๐Ÿ› ๏ธ Tech Stack

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • A Supabase account and project

1. Clone & Install

git clone <repository-url>
cd my-todo-app
npm install

2. Environment Setup

Create a .env file in the root directory:

PUBLIC_SUPABASE_URL=your-supabase-project-url
PUBLIC_SUPABASE_PUBLISHABLE_KEY=your-supabase-anon-key

Get these values from your Supabase Dashboard โ†’ Settings โ†’ API.

3. Database Setup

Run this SQL in your Supabase SQL Editor to create the todos table:

-- Enable Row Level Security
create table if not exists todos (
  id uuid default gen_random_uuid() primary key,
  user_id uuid references auth.users(id) on delete cascade not null,
  task text not null,
  is_done boolean default false,
  created_at timestamp with time zone default timezone('utc'::text, now()) not null,
  updated_at timestamp with time zone default timezone('utc'::text, now()) not null
);

-- Enable RLS
alter table todos enable row level security;

-- Create policies
create policy "Users can view their own todos" on todos
  for select using (auth.uid() = user_id);

create policy "Users can create their own todos" on todos
  for insert with check (auth.uid() = user_id);

create policy "Users can update their own todos" on todos
  for update using (auth.uid() = user_id);

create policy "Users can delete their own todos" on todos
  for delete using (auth.uid() = user_id);

4. Start Development

npm run dev

Visit http://localhost:5173 to see your app! ๐ŸŽ‰

๐Ÿ“ Project Structure

src/
โ”œโ”€โ”€ lib/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ ui/           # Reusable UI components
โ”‚   โ”‚   โ”œโ”€โ”€ Auth.svelte   # Authentication component
โ”‚   โ”‚   โ”œโ”€โ”€ TodoApp.svelte# Main todo application
โ”‚   โ”‚   โ””โ”€โ”€ TodoItem.svelte# Individual todo item
โ”‚   โ”œโ”€โ”€ database.types.ts # TypeScript definitions
โ”‚   โ”œโ”€โ”€ supabase.ts      # Supabase client
โ”‚   โ””โ”€โ”€ utils.ts         # Utility functions
โ”œโ”€โ”€ routes/
โ”‚   โ”œโ”€โ”€ +layout.svelte   # App layout
โ”‚   โ”œโ”€โ”€ +layout.server.ts# Layout server logic
โ”‚   โ”œโ”€โ”€ +page.svelte     # Home page
โ”‚   โ”œโ”€โ”€ +page.server.ts  # Page server actions
โ”‚   โ””โ”€โ”€ auth/            # Authentication routes
โ””โ”€โ”€ app.html             # HTML template

๐Ÿงช Testing

The project includes comprehensive unit tests using Vitest with TypeScript support.

Test Structure

src/
โ”œโ”€โ”€ lib/
โ”‚   โ”œโ”€โ”€ utils.test.ts         # Utility function tests
โ”‚   โ””โ”€โ”€ formatters.test.ts    # Date formatting and helper tests
โ””โ”€โ”€ demo.spec.ts              # Demo test file

Running Tests

# Run all tests
npm run test

# Run tests in watch mode
npm run test:unit

# Run tests with coverage
npm run test -- --coverage

Test Features

  • โœ… Utility Functions: Tests for class name merging, date formatting, and user initials
  • โœ… Business Logic: Todo filtering, form validation, and authentication checks
  • โœ… TypeScript Support: Full type checking in tests
  • โœ… Mocking: Mock implementations for external dependencies
  • โœ… Fast Execution: Optimized test runner with parallel execution

Available Scripts

# Development
npm run dev              # Start dev server
npm run build           # Build for production
npm run preview         # Preview production build

# Quality
npm run check           # Type checking
npm run check:watch     # Type checking in watch mode
npm run lint            # Run ESLint
npm run format          # Format code with Prettier

# Testing
npm run test            # Run all tests
npm run test:unit       # Run unit tests

๐ŸŽจ UI Components

The app uses a custom component library built on top of Tailwind CSS:

  • Button: Various styles and sizes
  • Input: Form inputs with validation
  • Card: Content containers
  • Badge: Status indicators
  • Avatar: User profile pictures
  • Dropdown Menu: Contextual menus
  • Checkbox: Todo completion toggles

๐Ÿ”ง Configuration

Tailwind CSS

Configured with:

  • Custom color palette
  • Form plugins
  • Typography plugin
  • Custom border radius variables

TypeScript

Strict TypeScript configuration with:

  • Full type safety
  • Supabase type generation
  • Custom type definitions

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is open source and available under the MIT License.

๐Ÿ™ Acknowledgments


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

Top categories

Loading Svelte Themes