svelte-turbo-starter Svelte Themes

Svelte Turbo Starter

For use and reuse

Turborepo Svelte Starter

A full-featured monorepo using Turborepo + SvelteKit 2 with domain-driven design.

Quick Start

# Prerequisites: Node.js >= 18, npm >= 10, Docker/Podman

git clone [email protected]:thebrianbug/svelte-turbo-starter.git
cd svelte-turbo-starter
npm install
npm run dev

Features

Roadmap

Development

# Start development
npm run dev
npm run build    # Build all
npm run lint     # Lint/format

# Testing
npm test         # Run all tests
npm run test:e2e # E2E only

# Database
npm run docker:up   # Start PostgreSQL
npm run docker:down # Stop PostgreSQL

Project Structure

.
โ”œโ”€โ”€ apps/
โ”‚   โ”œโ”€โ”€ docs/    # Documentation
โ”‚   โ””โ”€โ”€ web/     # Main app
โ””โ”€โ”€ packages/
    โ”œโ”€โ”€ bll/     # Business logic
    โ”œโ”€โ”€ db/      # Database layer
    โ”œโ”€โ”€ ui/      # Shared UI
    โ””โ”€โ”€ config/  # Tooling configs

Architecture

Domain-Driven Design

  1. Models (db/src/models/)

    • Entities and value objects
    • Aggregate roots
    • Rich domain models
  2. Services (bll/src/domains/)

    • Business rules
    • Aggregate coordination
  3. Repositories (db/src/repositories/)

    • Data access patterns
    • Transaction handling

Error Handling

  1. DB Layer (db/)

    • DatabaseError wrapping
    • Data validation
    • Operation context
  2. BLL Layer (bll/)

    • Domain-specific errors
    • Business validation
    • Error mapping
  3. Shared Layer (shared/)

    • Base error types
    • Error serialization
    • Error metadata

Testing

Integration Tests (*/tests/integration/)

  • Transaction-based with rollback
  • Factory function services
  • Domain-organized structure

Unit Tests (*.test.ts)

  • Next to source files
  • ts-mockito for mocking
  • TDD principles

E2E Tests (apps/*/tests/)

  • Full workflow testing
  • Playwright-based
  • Automatic cleanup
    npm run build
    npm run preview  # Preview the built applications
    

Type Checking

The project uses TypeScript for static type checking:

  • Run npm run check to verify types across all projects
  • TypeScript configuration is shared through the typescript-config package
  • Each app and package has its own tsconfig.json that extends the shared config
  • Database schema types are automatically generated by Drizzle ORM

LLM Coding Assistant Context

When using AI coding assistants like GitHub Copilot or Claude, provide this system context for optimal code generation:

Tech Stack:

- Frontend: Svelte 5 (Svelte 5 syntax only) + TypeScript, Vite v6, TailwindCSS v3
- Backend: PostgreSQL with Docker/Podman, Drizzle ORM
- Architecture: Domain-driven design, Modular structure (UI, BLL, DB layers)
- Testing: Vitest for unit/integration, Playwright for E2E
- Quality: TypeScript v5, ESLint (security, promise, sonar, unicorn plugins), Prettier with Svelte plugin
- Node.js >=18, NPM 10

Testing Notes:

- ts-mockito is used for mocking in unit tests
- Follow TDD principles: write tests first, then implementation
- Place unit tests next to source files with .test.ts extension
- E2E tests go in the tests/ directory of each app

Note: See the scripts for additional utility scripts to help with LLM.

License

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

Contributing

  1. Ensure you have the prerequisites installed
  2. Fork and clone the repository
  3. Install dependencies: npm install
  4. Create a branch for your changes
  5. Make your changes
  6. Run tests: npm run test
  7. Submit a pull request

Top categories

Loading Svelte Themes