SvelteKit_better_auth_squlit Svelte Themes

Sveltekit_better_auth_squlit

SvelteKit_better_auth_squlit

SystemCore - Enterprise SvelteKit Application

SystemCore is a modern, scalable, and highly secure web application built with a focus on Domain-Driven Design (DDD) and robust software architecture. It features a complete authentication system and a responsive dashboard layout.

🚀 Tech Stack

🏗️ Architecture & Best Practices

This project strictly follows enterprise-grade software engineering patterns:

  • Domain-Driven Design (DDD): Database schemas and business logic are isolated by domain (e.g., auth, users) inside src/lib/domains/.
  • Barrel File Pattern: Centralized schema export (src/lib/domains/schema.ts) to maintain type-safety and keep database connection files clean.
  • Component-Driven UI: UI is broken down into small, reusable components (e.g., Navbar.svelte, UserForm.svelte) keeping the page files lightweight.
  • Server-Side Route Protection: Authentication checks are handled at the middleware level (hooks.server.ts) preventing unauthorized access to protected routes.
  • Defensive Programming: Implementation of TypeScript strict mode, Optional Chaining, and robust error handling.

📦 Features Implemented So Far

  1. Authentication System:

    • Sign Up and Log In pages with email/password.
    • Secure session management using Better Auth.
    • Global Route Protection (Redirects unauthenticated users to /login).
    • Secure Log Out functionality.
  2. Database Management:

    • Integrated Drizzle ORM with SQLite.
    • Automated UUID generation using $defaultFn(() => crypto.randomUUID()).
    • Automated timestamps (createdAt, updatedAt).
  3. Dashboard Layout:

    • Global +layout.svelte integrating a persistent Navbar.
    • Dynamic user profile display in the navigation bar.

🛠️ Installation & Local Setup

1. Clone the repository

Ensure you have Bun installed on your machine.

2. Install dependencies

```bash bun install

src/ ├─ lib/ │ ├─ components/ # Reusable UI components (Navbar, Forms, etc.) │ ├─ domains/ # Domain-Driven schema and logic (Auth, Users) │ │ └─ schema.ts # The central Barrel File for all schemas │ ├─ server/ │ │ ├─ db.ts # Database connection setup │ │ └─ auth.ts # Better Auth server configuration │ └─ auth-client.ts # Better Auth client instance │ ├─ routes/ │ ├─ api/auth/[...all]/# Catch-all route for Better Auth endpoints │ ├─ login/ # Sign-in page │ ├─ signup/ # Registration page │ ├─ +layout.svelte # Global dashboard layout & Navbar │ └─ +page.svelte # Main dashboard / User Management UI │ ├─ hooks.server.ts # Server-side middleware & route protection └─ app.d.ts # Global TypeScript interfaces (Typed Locals)

Code snippet

Secret key for Better Auth (use a strong random string in production)

BETTER_AUTH_SECRET="my-super-secret-key-for-learning"

Base URL for the application

PUBLIC_BASE_URL="http://localhost:5173"

git init git add . git commit -m "first commit" git branch -M main git remote add origin https://github.com/nextnayan/SvelteKit_better_auth_squlit.git git push -u origin main

Top categories

Loading Svelte Themes