https://github.com/jpb06/nest-prisma-monorepo
Multiple databases POC built with nestjs & prisma
https://github.com/jpb06/nest-prisma-monorepo
monorepo multiple-databases nestjs prisma proof-of-concept rxjs
Last synced: 7 months ago
JSON representation
Multiple databases POC built with nestjs & prisma
- Host: GitHub
- URL: https://github.com/jpb06/nest-prisma-monorepo
- Owner: jpb06
- Created: 2021-11-17T21:29:47.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-01T15:18:55.000Z (over 1 year ago)
- Last Synced: 2025-04-08T01:01:43.874Z (about 1 year ago)
- Topics: monorepo, multiple-databases, nestjs, prisma, proof-of-concept, rxjs
- Language: TypeScript
- Homepage:
- Size: 512 KB
- Stars: 38
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nest-prisma-monorepo
[](https://github.dev/jpb06/nest-prisma-monorepo)

[](https://sonarcloud.io/summary/new_code?id=jpb06_nest-prisma-monorepo)
[](https://sonarcloud.io/summary/new_code?id=jpb06_nest-prisma-monorepo)
[](https://sonarcloud.io/summary/new_code?id=jpb06_nest-prisma-monorepo)
[](https://sonarcloud.io/summary/new_code?id=jpb06_nest-prisma-monorepo)
[](https://sonarcloud.io/summary/new_code?id=jpb06_nest-prisma-monorepo)
[](https://sonarcloud.io/summary/new_code?id=jpb06_nest-prisma-monorepo)
[](https://sonarcloud.io/summary/new_code?id=jpb06_nest-prisma-monorepo)
[](https://sonarcloud.io/summary/new_code?id=jpb06_nest-prisma-monorepo)
[](https://sonarcloud.io/summary/new_code?id=jpb06_nest-prisma-monorepo)
[](https://sonarcloud.io/summary/new_code?id=jpb06_nest-prisma-monorepo)

Here is the POC of a monorepo built with nestjs and prisma used to expose several apps, relying on several databases.
## ⚡ Requirements
You will need the following to use this POC :
| Item | Description | Documentation |
| -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------ |
|
nodejs | Duh! | |
|
Docker | we will use docker to launch a postgres instance | |
|
bun | We will use bun as the package manager for this project | |
## ⚡ How to start
### 🔶 Firstof, let's start our database using docker
You may need to give execution permission to the entry point script file, that is responsible for creating our three databases:
```bash
chmod +x docker/pg-init-scripts/create-multiple-db.sh
```
Let's then use docker compose :
```bash
bun docker
```
### 🔶 Then we can migrate our schemas and seed the databases
```bash
bun dev:db
```
### 🔶 Launching our backends in dev mode
```bash
# Hiking app (port 5001)
bun dev hiking-app
# Projects app (port 5002)
bun dev projects-app
```
### 🔶 Accessing apps swaggers
Now we can access the swaggers of our apps using the following urls:
- [Hiking app](http://localhost:5001/api)
- [Projects app](http://localhost:5002/api)
### 🔶 Building our apps for production
```bash
bun run build
```
## ⚡ Project structure
### 🎉 Apps
| Database | Description |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 🚀 Hiking app | This kiking app allows users to check and join hiking groups planning to do a walk on some trail. This app owns a database but also uses the Users database. |
| 🚀 Projects app | This projects app allows users to check contributions made to repositories. This app owns a database and also uses the Users database. |
### 🧩 Libs
| Database | Description |
| ------------- | ----------------------------------------------------------------------------- |
| 🧩 Boostraper | The code necessary to create an app is defined there and shared between apps. |
| 🧩 Databases | The base prisma services are defined on this shared module. |
| 🧩 Decorators | Decorators used in all our apps. |
| 🧩 Filters | Filters used in all our apps. |
| 🧩 Pipes | Pipes used in all our apps. |
| 🧩 Rxjs | Rxjs helpers. |
| 🧩 Tests | Test related code. |
## ⚡ Data model
We have three databases:
| Database | Description |
| ----------- | ----------------------------------------------------------------------------------------------------------------------- |
| 👨 Users | Contains our users (duh). This database will serve as the single base of truth for everything user related in our apps. |
| 🏔️ Hiking | Database dedicated to the hiking backend service. |
| 🧳 Projects | Database dedicated to the projects backend service. |
Let's take a look at the schema:
