Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/noviel/next.js-firebase-typescript-workspaces

Scalable monorepo architecture example project
https://github.com/noviel/next.js-firebase-typescript-workspaces

firebase gatsby mobx monorepo next-js node-js react typescript web-workers yarn-workspaces

Last synced: 9 days ago
JSON representation

Scalable monorepo architecture example project

Awesome Lists containing this project

README

        

# Fullstack scalable monorepo project

## Technical desicions

- Monorepo via Yarn workspaces
- TypeScript as a main language
- React as an UI layer
- Server side rendering with Next.js and Firebase functions
- Static site via Gatsby
- Universal interface for interaction with Domain Host that can be local, in a WebWorker, on a remote server
- Support for multiple build/deploy targets

## Install

```sh
$ yarn install
```

## Run

Next.js application:

```sh
$ yarn dev -t next -c local
```

Gatsby application:

```sh
$ yarn dev -t static-site -c local
```

API Server:

```sh
$ yarn dev:server
```

## DevOps-ish

### Contours

Contour - is a collection of environment variables. With contours you can seamlessly build and deploy application to different environments.

There are 3 contours: `local`, `dev`, `prod`.

For example, web application requires API url. For local development you may want to point it to local development sever. For `dev` build it should points to remote dev/staging server, and to corresponding server for production build.

## Environment variables

There are two types of environment variables: private and public.

Public variables can be set up per contour in `app.config.js`.

Private variables should not be in the repository. They can be defined directly inside a working (CI/CD platform) enviroment of in a `.env.{contour}` files. These files should be excluded from the repository.

Client applications require `process.env.PUBLIC_CLICKER_API_URL` variable to connect to the remote API.

### Scripts

There are 4 main scripts for buildable or/and deployable packages: `build`, `dev`, `deploy`, `release`.

Every one accepts the following arguments:
- --target (-t) - target package
- --contur (-c) - target contour

`build` takes an additional `--prod` flag for production builds. It will be automatically turned on for `prod` contour.

### Examples

Build `next` application for production:
```sh
$ yarn build -t next -c prod
```

Build `static-site` for local contour in production mode:
```sh
$ yarn build -t static-site -c local --prod
```

## Deploy

### Firebase

In order to deploy to Firebase you need to specify your project ID in `.firebaserc`. Project is using two Firebase projects: one for `dev` contour, second for `prod` contour.

### Docker

To do