βš™οΈBackend API

Quick Start Guide

Jump to

Running Locally

Running this application requires Node.js (Version 20+)arrow-up-right.

To run the application, fulfill all prerequisites and cd into the /backend folder.

Add a .env filearrow-up-right with all the requisite environment variables - you don't need to specify the HOST and PORT variables to run the app locally.

Install dependencies, by running:

npm install

Run the app, using the following command:

node app

Please ensure that port 8080 is available and that you are not connected to a VPN before you run the app.

Prerequisites

Setting up the Backend API requires an instance of MongoDB Atlas, Clerk, Cloudflare Images and an API key for the OpenAI Platform.

Setup up a MongoDB Atlas instance

The project uses MongoDB Atlas as its datastore.

This tutorialarrow-up-right provides guidance on setting up a database on MongoDB Atlas. You do not need to create collections once your database is setup - this will be done automatically when the application connects with the database.

Make sure to name the database "ninjarecipes".

Using any instance of MongoDB, other than MongoDB Atlas, will break the search feature and the scheduled workers used for cleaning submission tracking logs.

Setup up a Clerk instance

Clerk arrow-up-rightis used as the authentication service for the project.

Thus, setting up a Clerk account and obtaining an API key is a mandatory requirement for running the application.

This tutorialarrow-up-right provides a detailed walkthrough of setting up an account and obtaining a Clerk Secret Key.

Configure Cloudflare Images

The API is designed to use Cloudflare Images as the CDN for image delivery. Documentation for Cloudflare Images is available herearrow-up-right.

Once your account is setup and you've obtained your Cloudflare Account ID and API key. You'll need to configurearrow-up-right the following image variants in your dashboard:

Property
Value

Variant Name

ncHeader

Width

1366

Height

768

Fit

Cover

Metadata

Strip All

Make Public

Yes

Blur

0

Property
Value

Variant Name

ncThumbnail

Width

405

Height

300

Fit

Cover

Metadata

Strip All

Make Public

Yes

Blur

0

Get an OpenAI Platform Key

All AI features in the application have been built on top of the OpenAI SDK and require an API Key to access models hosted by OpenAI. You can obtain an API key by following this guidearrow-up-right.

Environment Variables

Variable
Description
Purpose

API Key to communicate with MongoDB Atlas Instance.

Auth

API Key to authenticate and communicate with Clerk.

Auth, Session Management

API Key to authenticate with OpenAI Models.

Auth

Cloudflare Account ID

Auth

API key to access Cloudflare Images

Auth

Host for binding the runtime process, 127.0.0.1 if unspecified.

Config

Port for binding the runtime process, 8080 if unspecified.

Config

Deployment

The application can be simply deployed by specifying its configuration details and adding environment variables, when you use modern app hosting services such as Railway and DigitalOcean App Platform.

You may refer to these guides, for such services:

If you wish to manually deploy this application on a server, please follow these guides:

Configuration Details

Property
Value
Addl. Details

Runtime

Node.js

Version 20

Build Command

None

Build output directory

None

Install Command

npm install

Start Command

node app

Default HOST is 127.0.0.1, Default PORT is 8080. Change using environment variables.

Root directory

/backend

Entrypoint

./app.js

Last updated