diff --git a/README.md b/README.md index e95bce2..7b4f050 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,111 @@ -[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/A0A01I0NP5) - # BackendV2 +follow me on [GitHub](https://github.com/FifthWit) -[![Donate](https://img.shields.io/badge/Donate-GitHub%20Sponsors-PURPLE)](https://github.com/sponsors/FifthWit) +BackendV2 is a from scratch rewrite of movie-web's backend using [Nitro](https://nitro.build), and [Prisma](https://prisma.io). -BackendV2 is a from scratch rewrite for the old Fastify and MikroOrm version with backwards compatibility! +## Deployment +There are multiple supported ways to deploy BackendV2 based on your needs: +### NixPacks +1. Install NixPacks with +```sh +# Mac +brew install nixpacks +# POSIX (mac, linux) +curl -sSL https://nixpacks.com/install.sh | bash +# Windows +irm https://nixpacks.com/install.ps1 | iex +``` +2. Build the backend +```sh +nixpacks build ./path/to/app --name my-app # my-app will be the container name aswell +``` +3. Run the container +```sh +docker run my-app +``` +[!TIP] +If you use a tool like Dokploy or Coolify, NixPacks support is out of the box +### Railpack +Railpack is the successor to NixPacks, to run the backend via Railpack: -## Tech Stack +1. Install [Railpack](https://railpack.com/installation) -This repo uses: +2. Run BuildKit and set BuildKit host +```sh +docker run --rm --privileged -d --name buildkit moby/buildki -- [Nitro](https://nitro.build) -- [Prisma](https://pris.ly) -- [Zod](https://zod.dev) +export BUILDKIT_HOST='docker-container://buildkit' +``` -along with other minor libraries, we chose Nitro for its fast DX, easy support for caching, minimal design, and rapid prototyping. Prisma due to it's clear syntax, typesafety, and popularity. Zod for validation. +3. Build Backend +```sh +cd ./path/to/backend +railpack build . +``` -# Goals +4. Run Backend container +```sh +# Run manually +docker run -it backend +# Run in the background +docker run -d -it backend +``` -Since we've changed the codebase so much for better DX that comes with more changes! +5. Verify it's running +```sh +docker ps +# You should see backend, and buildkit running +``` -- [ ] Recommendations using ML models to provide accurate Recommendations via embeddings using a vector database -- [x] Ratings, partly for the affirmentioned goal -- [ ] Client wrapper library for any site that wants to keep user data related to movies, films, and recommendations +### Manually +1. Git clone the environment +```sh +git clone https://github.com/p-stream/backend.git +cd backend +``` +2. Build the backend +```sh +npm install && npm run build +``` +3. Run the backend +```sh +node .nitro/index.mjs +``` -## Minor information +## Setup your environment variables: +To run the backend you need environment variables setup +1. Create .env file +```sh +cp .env.example .env +``` -Only make PRs to `beta` branch -Production deployments are [here](https://backend.fifthwit.net) -Beta deployments are [here](https://beta.backend.fifthwit.net) +2. Fill in the values in the .env file + +[!NOTE] for postgres you may want to use a service like [Neon](https://neon.tech) or host your own with docker, to do that just look it up + +## Contributing +We love contributors, it helps the community so much, if you are interested in contributing here are some steps: + +1. Clone the repo +```sh +git clone https://github.com/p-stream/backend.git +cd backend +``` + +2. Install Deps/Run the backend +```sh +npm install && npm run dev +``` + +3. Set your Environment variables: check above as there is a guide for it! + +4. Make your changes! Go crazy, so long as you think it is helpful we'd love to see a Pull Request, have fun, this project is FOSS and done in my our maintainers free time, no pressure, just enjoy yourself + +### Philosophy/Habits for devs +Here is a general rule of thumb for what your changes and developments should look like if you plan on getting it merged to the main branch: + +- Use Prettier & ESLint: We aren't going to be crazy if it's not well formatted but by using the extensions it keeps our code consistent, which makes it a lot easier for maintainers to help merge your code +- Keep it minimal, things like Email are out of the question, we want to keep it small, if you think that it's **really** needed, make an issue on our GitHub to express your interest in it, and a maintainer will confirm or deny whether we would merge it +- Understand our tech stack, this is a generic piece of advice but if you haven't use NitroJS for example, read their docs and make sure you're familiar with the framework, it makes your code quality much better, and makes reviewing much easier + +Star this repo and please follow me on [GitHub](https://github.com/FifthWit)! \ No newline at end of file