⚙️Backend API
Quick Start Guide
Jump to
Running Locally
Running this application requires Node.js (Version 20+).
To run the application, fulfill all prerequisites and cd
into the /backend
folder.
Add a .env file 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:
Run the app, using the following command:
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 tutorial 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 is 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 tutorial 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 here.
Once your account is setup and you've obtained your Cloudflare Account ID
and API key
. You'll need to configure the following image variants in your dashboard:
Variant Name
ncHeader
Width
1366
Height
768
Fit
Cover
Metadata
Strip All
Make Public
Yes
Blur
0
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 guide.
Environment Variables
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
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
Was this helpful?