getmeli / meli

Platform for deploying static sites and frontend applications easily. Automatic SSL, deploy previews, reverse proxy, and more.
Other
2.4k stars 97 forks source link

Deploy Remix app with Prisma and Postgres #260

Open kubeworkz opened 1 year ago

kubeworkz commented 1 year ago

Would it be possible to use Meli to deploy an application built with Remix using Prisma/Postgres on the backend? The backend would be hosted elsewhere (like Supabase or something). If so, we were wondering if you're available for some consulting.

gempain commented 1 year ago

Hi there 👋 This is a great question, thanks for brining it up. When we wrote Meli, we went with Mongo because at the time that's what we were used to work with. To be honest, I have now adopted TypeORM for all my latest projects. I'm not against Prisma as I have heard it's becoming very popular, and is probably more actively maintained than TypeORM. I am also curious to try out this new ORM. I don't have much time on my ends at the moment, but I would certainly like to stop the dependency on Mongo and start using Postgres as a default. Whether it be with Prisma (totally for it) or TypeORM (what I am used to) it could be the next major change in Meli. Is this something you would be interested to get into ? My free time has been very limited for the past few months, reason why not many commits have seen daylight here, but I am eagerly seeking help from the community to start digging with me on this.

kubeworkz commented 1 year ago

Thanks for getting back. If you could give me a quick high level overview of what would be required to make the change, I can review it. I think this is something worth checking out.

gempain commented 1 year ago

The db directory contains the code used for initializing the db + setting up migrations. That's where TypeORM's code such as createDatasource and migrations handling will go. This directory also contains index definitions for Mongo entities, but with TypeORM these definitions are annotations defined on the entity class.

In the entities directory, you will find one directory per entity and that's where you'll find the model definitions. For example, in the releases contains a file named release.ts at its root, which creates the Mongo model as export const Releases = () => AppDb.db.collection<Release>('releases');. This Releases model is "Mongo ORM" object used everywhere else in the project to manage releases from the db (created, read, update, delete...). This is the equivalent of your TypeORM "entity".

Other than that, most of the work required will be to translate the existing Mongo models into TypeORM definitions. Then, you'll need to update the deployment files (docker-compose etc). There's also the docs to update and explain to people how you would convert your existing deployment to the Postgres one. We'll need to write a migration tool to copy the data from Mongo to Postgres.

This is a global overview, the best option is to navigate the code and try developing locally.