SvelteKit Full-Stack Starter

A production-ready starter template for building modern, full-stack web applications. This repository provides a robust foundation featuring a clean architecture, type-safe database access with Drizzle, and a complete authentication system.

This project is designed to be a launchpad, saving you from the boilerplate and letting you focus on building features.


Features

This starter template comes packed with a modern tech stack and tooling, all configured to work seamlessly together.

Category Technology / Tool Purpose
Framework SvelteKit A full-stack framework for building high-performance web applications.
Language TypeScript For robust, type-safe code across the entire stack.
UI Components shadcn-svelte A collection of beautifully designed, accessible UI components.
Database ORM Drizzle ORM A next-generation TypeScript ORM for type-safe database access.
Database PostgreSQL A powerful, open-source object-relational database system.
Container Docker For consistent development and production environments.
Forms SvelteKit Superforms A comprehensive library for building robust, validated forms.
Validation Zod For schema declaration and validation on both client and server.
Testing Vitest & Playwright For unit, component, and end-to-end testing.
Code Quality ESLint & Prettier For maintaining a clean and consistent codebase.

Getting Started

Follow these instructions to get the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Node.js: v22.x or higher
  • npm: v10.x or higher
  • Docker: Required to run the PostgreSQL database.

Installation & Setup

  1. Clone the repository:

    git clone https://github.com/shandysiswandi/sveltekit-app.git
    cd sveltekit-app
    
  2. Configure Environment Variables: Copy the example .env file and update it with your local settings.

    cp .env.example .env
    
  3. Install Dependencies:

    npm install
    
  4. Start the Database: This command uses Docker Compose to start a PostgreSQL container in the background.

    npm run db:start
    
  5. Run Database Migrations: This command applies the Drizzle ORM schema to your new database.

    npm run db:migrate
    
  6. Run the Development Server:

    npm run dev
    

The application will now be available at http://localhost:5173.


Project Structure

This project follows a feature-driven architecture designed for scalability and maintainability.

  • src/lib/components: Contains reusable Svelte components.
    • ui/: Low-level, unstyled components from shadcn-svelte.
    • custom/: Your own application-specific components.
  • src/lib/server: Houses all backend logic, guaranteed to only run on the server.
    • db/: Drizzle ORM setup and schema definitions.
    • data/: The Data Access Layer (Repositories) for database interactions.
    • usecase/: The Business Logic Layer (Services) that orchestrates actions.
  • src/lib/model: Defines the core data models (classes or types) for the application.
  • src/routes: Defines all pages and API endpoints, using SvelteKit's file-based routing. Route groups (auth) and (main) are used to apply different layouts.
  • tests/: Contains all unit and end-to-end tests.

Available Scripts

This project includes a set of npm scripts to streamline common development tasks:

  • npm run dev: Starts the development server.
  • npm run build: Compiles the application for production.
  • npm run start: Runs the production-ready build.
  • npm run lint: Lints the codebase for errors.
  • npm run format: Formats all files with Prettier.
  • npm run test:unit: Runs all unit tests.
  • npm run db:migrate: Applies pending database migrations.
  • npm run db:studio: Opens the Drizzle Studio to browse your database.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Top categories

svelte logo

Need a Svelte website built?

Hire a professional Svelte developer today.
Loading Svelte Themes