/mono-ts-apollo-bp

Boilerplate monorepo with Lerna, Apollo Server, TS, and CRA

Primary LanguageTypeScriptMIT LicenseMIT

mono-ts-apollo-bp

lerna code style: prettier Code style: airbnb

Welcome to mono-ts-apollo-bp!

This repository is a sample boilerplate project (titled monots) composed of a FE (via CRA) and Apollo GraphQL BE, managed via Lerna and TypeScript throughout.

The sample project sits within a Docker container and locally orchestrated using docker-compose. A 3rd package stores shared utility functions and type definitions between the FE and BE. This project uses PostgreSQL as the persistence layer and Auth0 as the 3rd party for authentication.

Digging into the technicals a bit further: prettier and ESLint are used for linting and analysis, jest for unit tests/coverage, and TailwindCSS for styles/themeing.

Getting Started

git clone git@github.com:davidvuong/mono-ts-apollo-bp.git

Install dependencies on your host machine, allowing VSCode or otherwise to pick up linting and autocompletion:

yarn

Compile CSS for the FE app:

lerna run build:css

Configure environment variables for api, cp example.env.list to local.env.list.

cp ./packages/api/example.env.list ./packages/api/local.env.list

Start local development, starting all services and dependencies:

docker-compose up

To start the sample React app, Apollo GraphQL API, and PostgreSQL database.

Database Migrations

Database migrations are fully managed by Flyway. To create a new migration, create a new file in packages/api/migrations. The pattern must be in the form of:

# Pattern
Vxxx__<name>.sql

# For instance,
V002__Create_accounts_relation.sql
V003__Add_indexes_to_accounts.sql

Database migrations need to be executed before the application can run:

yarn db:migrate

Read more about flyway here.