An open API service indexing awesome lists of open source software.

https://github.com/thebrianbug/svelte-turbo-starter

For use and reuse
https://github.com/thebrianbug/svelte-turbo-starter

Last synced: 12 months ago
JSON representation

For use and reuse

Awesome Lists containing this project

README

          

# Turborepo Svelte Starter

A full-featured monorepo using [Turborepo](https://turbo.build/) + [SvelteKit 2](https://kit.svelte.dev/) with domain-driven design.

## Quick Start

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

git clone git@github.com:thebrianbug/svelte-turbo-starter.git
cd svelte-turbo-starter
npm install
npm run dev
```

## Features

- ๐Ÿ“ฆ [Turborepo](https://turbo.build/) + [SvelteKit 2](https://kit.svelte.dev/)
- ๐ŸŽจ [Tailwind CSS](https://tailwindcss.com/) + [TypeScript](https://www.typescriptlang.org/)
- ๐Ÿ—„๏ธ [Drizzle ORM](https://orm.drizzle.team/) + PostgreSQL
- ๐Ÿงช [Vitest](https://vitest.dev/) + [Playwright](https://playwright.dev/)
- ๐Ÿ—๏ธ Domain-driven design architecture

### Roadmap

- [ ] Set up e2e tests according to [README](apps/web/README.md#e2e-testing-with-database-access)
- [ ] Users CRUD UI
- [ ] [Svelte-Clerk](https://github.com/wobsoriano/svelte-clerk) auth
- [ ] [Storybook](https://storybook.js.org/)
- [ ] Tailwind v4 ([issue](https://github.com/vercel/turborepo/issues/9895))

## Development

```sh
# 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
```sh
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:

```md
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](./scripts/README.md) for additional utility scripts to help with LLM.

## License

This project is licensed under the MIT License - see the [LICENSE](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