Skip to content

thaitype/typescript-clean-architecture

Repository files navigation

TypeScript Clean Architecture

Test and Build

In progess!

This is turborepo starter with Drizzle ORM and PostgreSQL pre-configured.

Note

This example uses pnpm as package manager.

Using this example

Clone the repository:

git clone https://github.com/htsh-tsyk/turbo-drizzle.git

What's inside?

This Turborepo includes the following packages/apps:

Apps and Packages

  • web: another Next.js app
  • @repo/database: Drizzle ORM wrapper to manage & access your database
  • @repo/ui: a stub React component library shared by a web application
  • @repo/eslint-config: eslint configurations (includes eslint-config-next and eslint-config-prettier)
  • @repo/typescript-config: tsconfig.jsons used throughout the monorepo

Each package/app is 100% TypeScript.

Utilities

This Turborepo has some additional tools already setup for you:

Build

To build all apps and packages, run the following command:

cd turbo-drizzle
cp apps/web/.env.default apps/web/.env
pnpm install
pnpm build

Database

We use Drizzle ORM to manage & access our database. As such you will need a database for this project, either locally or hosted in the cloud.

To make this process easier, we offer a docker-compose.yml file to deploy a PostgreSQL server locally with a new database named repo_development (To change this update the POSTGRES_DB environment variable in the docker-compose.yml file):

cd turbo-drizzle
docker-compose up -d

Once deployed you will need to copy the .env.default file to .env in order for Drizzle to have a DATABASE_URL environment variable to access.

cp apps/web/.env.default apps/web/.env

If you added a custom database name, or use a cloud based database, you will need to update the DATABASE_URL in your .env accordingly.

Once deployed & up & running, you will need to create & deploy migrations to your database to add the necessary tables. This can be done using Drizzle Migrate:

in database package: (command drizzle-kit generate)

pnpm generate
pnpm turbo db:migrate

An optional additional step is to seed some initial or fake data to your database.

To do this update check the seed script located in packages/database/scripts/seed.ts & add or update any users you wish to seed to the database.

Once edited run the following command to run tell Drizzle to run the seed script defined in the Drizzle configuration:

pnpm turbo db:seed

Develop

To develop all apps and packages, run the following command:

pnpm dev

Useful Links

Learn more about the power of Turborepo:

References

About

TypeScript Template for Clean Architecture

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published