This repo sets up a basic typescript monorepo.
This monorepo uses Turborepo and contains the following structure:
apps: Contains the applications (e.g.,web,docs).packages: Contains shared packages used across applications (e.g.,ui,config,db).
Environment variables are managed using pnpm. There's 3 layers to it:
.env.production // used for production builds
.env // used in local development and preview builds
.env.local // used in local developmentTo set an environment variable, use:
pnpm env:set <VARIABLE_NAME> <VALUE>This command updates the .env file in the root by default.
Use the -f flag to target a specific file, for e.g. .env.localor .env.production :
pnpm env:set <VARIABLE_NAME> <VALUE> -f .env.localThe .env.local file is ignored by Git and allows you to have local-specific settings.
The values in all .env files are encrypted by default so it can be easily shared across teams. Refer to the dotenvx documentation for more.
This project uses PostgreSQL as its database. A Docker Compose setup is provided for easy local development when you run pnpm dev
You'll need Docker to be running.
Run pnpm dev to start up the frontend and server.
Finally visit https://localhost:6969 to see your dev
server
If this is your first time setting things up, you'll have to do a few extra things:
- Run
docker compose up -dto launch the postgres DB. - Run
pnpm db:pushto update the db with the default schema - Run
pnpm dev. Note you might have to accept some certs since we use themkcertvite plugin to develop onhttpsby default.
To add a new package to the monorepo, run:
pnpm new:packageThis command will walk you through the process of scaffolding a new package directory under packages/with the necessary basic configuration files.
To build the applications for production, run:
pnpm build:productionTo build and preview the applications, run:
pnpm build:previewThe main difference is that pnpm build:production uses the .env.production file while build:preview uses the .env file.
This repository was originally inspired by via create t3 turbo and wouldn't be possible without all the other open source tooling.