If you want to skip this for now, feel free to ignore the “Connecting to Modelence Cloud” section below and continue with the MongoDB setup section.
Connecting to Modelence Cloud
1
Create a Modelence Account
First, you need to create a free Modelence account by going to Modelence Cloud.
2
Create an Application
After you’ve logged in, create a new application and name it after your project.
3
Create an Environment
After you’ve created an application, create a new environment. There are 2 types of environments: cloud and local. The cloud environment will provision and deploy your application to Modelence Cloud servers, while the local environment will only provision a remote MongoDB database for your local development.
You can also connect to an external MongoDB database instead of using Modelence’s provisioned database. See the “Setting up MongoDB” section below for more details.
4
Connect Your Project
After you’ve created a new environment, open its Settings page and click on The second command should be executed in the project directory and it connects the project to Modelence Cloud. Here is how the command looks like:It will automatically create a
Setup Local Environment button.It will open a modal with 2 steps. The first step creates a project (it’s optional) by running the following command..modelence.env file with the necessary environment variables.5
Starting The Development Server
Run the following command in the project directory
npm run dev to start the development server.Now, if everything is set up correctly, you should see your environment status go from inactive to active in the Modelence Cloud dashboard.Deploy to Modelence Cloud
To deploy your Modelence application to the cloud, follow these steps:1
Create a Cloud Environment
In your Modelence Cloud dashboard, navigate to your application and create a new environment. This time, select cloud as the environment type instead of local. Cloud environments will provision infrastructure and deploy your application to Modelence Cloud servers.
2
Open Environment Settings
After creating the cloud environment, navigate to its Settings page. You’ll find deployment configuration and commands here.
3
(Optional) Create a New Project
If you don’t have an existing project, you can create one using the command from Step 1 in the settings modal:Replace
my-app with your preferred project name and choose the template that fits your needs.4
Deploy Your Project
Copy the deployment command from Step 2 in the settings page. The command will look like this:Run this command in your project directory to deploy your application to Modelence Cloud. The deployment process will:
- Build your application
- Upload it to Modelence Cloud
- Provision necessary resources (MongoDB database, server infrastructure)
- Start your application
active and you’ll receive a URL to access your deployed application.Cloud deployments include automatic scaling, monitoring, and a production-ready MongoDB database. You can view logs, metrics, and manage your deployment from the Modelence Cloud dashboard.
Setting up MongoDB
If you’ve connected your local project to Modelence Cloud, as described in the section above, no more setup is needed - you are automatically set up with a MongoDB database that is included with your remote environment and can skip this section.
Setting up MongoDB with Atlas
Create an Atlas Account
Create an Atlas Account
- Go to MongoDB Atlas
- Sign up for a new account or log in if you already have one
Create a Free Cluster
Create a Free Cluster
- Click “Build a Database”
- Choose the “FREE” tier (labeled as “Shared” or “M0”)
- Select your preferred cloud provider and region
- Click “Create” to deploy your cluster (this may take a few minutes)
Set up Database Access
Set up Database Access
- In the Security Quickstart page, select “Username and Password” authentication
- Enter a username in the first text field
- For the password, either:
- Enter your own secure password, or
- Click “Autogenerate Secure Password” to let Atlas create one
- Click “Create User”
Configure Network Access
Configure Network Access
- In the Security Quickstart page, select “My Local Environment”
- In the “Add entries to your IP Access List” section, you can either:
- Click “Add My Current IP Address” to add your current IP
- For development, click “Allow Access from Anywhere” (0.0.0.0/0)
- Click “Finish and Close”
Get Your Connection String
Get Your Connection String
- Return to the “Database” page
- Click “Connect” on your cluster
- Select “Drivers” under “Connect Your Application”
- Choose the latest Node.js version and copy the connection string
- Replace the
<username>and<password>in the string with your database user’s username and password - Add your desired database name to the connection string (otherwise it will default to
test), so it looks like this:
Configure Environment Variables
Without the Modelence Cloud setup, you need to manually add your database configuration. Once you have your connection string, you’ll need to add it to your Modelence environment variables. Create a.modelence.env file in your project root (if it doesn’t exist already) and add: