📦 Getting Started

The default configuration for KitForStartups uses SQLite as a database through Turso.

Prerequisites

  • Node.js 18+
  • MySQL 8.1+
  • pnpm
  • Docker Compose (optional)

Installation

  1. Setup

Clone or fork the starter folder of this repository:

degit https://github.com/okupter/kitforstartups/starter my-project
  1. Install dependencies
cd my-project
pnpm install
  1. Setup the environment variables

Duplicate the .env.example file and rename it to .env. Then, fill in the values for the environment variables.

cp .env.example .env
  1. Setup the database

For easy local development, there is a ./docker/mysql.yml file that you can use to spin up a MySQL database in a Docker container. If you don’t want to use Docker, you can install MySQL locally and skip this step.

docker-compose -f docker/mysql.yml up -d
Remember to update the MYSQL_* environment variables in the .env file with your database credentials.
  1. Run the migrations

We use Drizzle Kit for automatic SQL migrations and prototyping.

To run the migrations for MySQL, run the following command:

pnpm generate-migrations:mysql

This will generate the SQL migrations, as well as migrations metadata files in the ./src/lib/drizzle/mysql/migrations/data directory.

You can now run the following command to push the migrations to the database:

pnpm migrate:mysql

In early stage of development or when you’re at the prototyping stage, you can use directly update the database schema and run the following command to directly push the schema changes to the database:

pnpm push:mysql
  1. Setup MailHog for local email testing

We use MailHog to send and test emails locally. The boilerplate is configured to automatically send emails to MailHog when running in development mode.

Check ./src/lib/emails/send.ts for more details about the implementation.

We also provide a Docker Compose file to quickly spin up a MailHog container.

docker-compose -f docker/mailhog.yml up -d

The MailHog server will be available at http://localhost:8025.

Remember to update the TRANSACTIONAL_EMAILS_* environment variables in the .env file with your sender name and address.
  1. Run the app
pnpm dev

Changing the database

Right now, there is no CLI or configuration file to change the database. You will have to do some search and replace in the codebase to change the database.

The default database is SQLite. If you want to use PostgreSQL, you will have to:

  • Change occurences of $lib/lucia/turso to $lib/lucia/postgres in the ./src directory
  • Change occurences of $lib/drizzle/mysql/models to $lib/drizzle/postgres/models in the ./src directory

This should be enough to get you started with PostgreSQL.

PS: This won’t be necessary in the future, as we plan to add a central configuration file for the app and a CLI to generate a starter project with the database of your choice.