/electron-trpc-drizzle-starter

A starter template for building Electron apps with tRPC and Drizzle ORM

Primary LanguageTypeScript

Electron-tRPC-Drizzle Starter

A starter template for building Electron applications with tRPC and Drizzle ORM .

Recommended IDE Setup

Features

  • Electron application with tRPC integration over IPC
  • Drizzle ORM for database operations
  • PostgreSQL database running in Docker to work with on dev
  • electron-vite for fast builds and hot module replacement
  • Tailwind CSS for utility-first styling

Overview

This template is designed to provide a solid foundation for developing desktop applications with Electron. It integrates tRPC for type-safe API calls over IPC (Inter-Process Communication) and Drizzle ORM for managing database interactions. With these tools, you can efficiently build and maintain scalable and reliable applications.

Why tRPC with IPC Communication?

We chose tRPC for its strong type safety and ease of use in creating APIs. In the context of Electron applications, where the main and renderer processes need to communicate efficiently, using tRPC over IPC provides several benefits:

  • Type Safety: tRPC ensures that the API calls between the main and renderer processes are type-safe, reducing runtime errors and enhancing developer productivity.
  • Ease of Integration: tRPC seamlessly integrates with Electron's IPC, making it straightforward to set up and use.
  • Code Sharing: With tRPC, you can share code between the server (main process) and the client (renderer process), promoting code reuse and consistency.

Why Drizzle ORM?

Drizzle ORM was selected for its modern, TypeScript-first approach to database management. It offers several advantages:

  • TypeScript Support: Drizzle ORM provides full TypeScript support, ensuring type safety throughout your database operations.
  • Simplicity and Flexibility: It offers a simple API for defining and interacting with database schemas, making it easy to use while remaining flexible.
  • Compatibility: Drizzle ORM works seamlessly with PostgreSQL, which is our database of choice for this template, running in a Docker container for development convenience.

Prerequisites

Installation

  1. Clone the repository:
$ git clone https://github.com/islem-boudja/electron-trpc-drizzle-starter.git
  1. Install dependencies:
$ bun install
  1. Start the PostgreSQL database (ensure Docker is running):
$ ./start-database.sh

Note: Review the start-database.sh script before running to ensure it meets your requirements. 4. Push the database schema:

$ bun run db:push

Development

$ bun run dev

Build

# For windows
$ bun run build:win

# For macOS
$ bun run build:mac

# For Linux
$ bun run build:linux