Installing (Self‐hosted) - aelassas/movinin GitHub Wiki

Movin' In is cross-platform and can run and be installed on Windows, Linux and macOS.

Before we begin, make sure you have at least 1GB of SWAP memory on your server. You can add it with this script. If you add SWAP memory, you can use your own MongoDB server by installing MongoDB Community Edition.

Below are the installation instructions on Linux.

Prerequisites

  1. Install git, Node.js, NGINX, MongoDB and mongosh. If you want to use MongoDB Atlas, you can skip installing and configuring MongoDB.

  2. Configure MongoDB:

mongosh

Create admin user:

db = db.getSiblingDB('admin')
db.createUser({ user: "admin", pwd: "PASSWORD", roles:["root"]})

Replace PASSWORD with a strong password.

Secure MongoDB:

sudo nano /etc/mongod.conf

Change configuration as follows:

net:
  port: 27017
  bindIp: 0.0.0.0

security:
  authorization: enabled

Restart MongoDB service:

sudo systemctl restart mongod.service
sudo systemctl status mongod.service

Instructions

  1. Clone Movin' In repo:
cd /opt
sudo git clone https://github.com/aelassas/movinin.git
  1. Add permissions:
sudo chown -R $USER:$USER /opt/movinin
sudo chmod -R +x /opt/movinin/__scripts
  1. Create deployment shortcut:
sudo ln -s /opt/movinin/__scripts/mi-deploy.sh /usr/local/bin/mi-deploy
  1. Create Movin' In service:
sudo cp /opt/movinin/__services/movinin.service /etc/systemd/system
sudo systemctl enable movinin.service
  1. Create /opt/movinin/backend/.env file with the following content:
# General
NODE_ENV=production

# Backend server
MI_PORT=4004
MI_HTTPS=false
MI_PRIVATE_KEY=/etc/ssl/movinin.key
MI_CERTIFICATE=/etc/ssl/movinin.pem

# MongoDB
MI_DB_URI="mongodb://admin:[email protected]:27017/movinin?authSource=admin&appName=movinin"
MI_DB_SSL=false
MI_DB_SSL_CERT=/etc/ssl/movinin.pem
MI_DB_SSL_CA=/etc/ssl/movinin.pem
MI_DB_DEBUG=true
MI_DB_SERVER_SIDE_JAVASCRIPT=false

# Auth
MI_COOKIE_SECRET=COOKIE_SECRET
MI_AUTH_COOKIE_DOMAIN=localhost
MI_ADMIN_HOST=http://localhost:3003/
MI_FRONTEND_HOST=http://localhost/
MI_JWT_SECRET=JWT_SECRET
MI_JWT_EXPIRE_AT=86400
MI_TOKEN_EXPIRE_AT=86400

# Email (SMTP)
MI_SMTP_HOST=smtp.sendgrid.net
MI_SMTP_PORT=587
MI_SMTP_USER=apikey
MI_SMTP_PASS="PASSWORD"
[email protected]

# CDN (File storage)
MI_CDN_ROOT=/var/www/cdn
MI_CDN_USERS=/var/www/cdn/movinin/users
MI_CDN_TEMP_USERS=/var/www/cdn/movinin/temp/users
MI_CDN_PROPERTIES=/var/www/cdn/movinin/properties
MI_CDN_TEMP_PROPERTIES=/var/www/cdn/movinin/temp/properties
MI_CDN_LOCATIONS=/var/www/cdn/movinin/locations
MI_CDN_TEMP_LOCATIONS=/var/www/cdn/movinin/temp/locations

# Localization
MI_DEFAULT_LANGUAGE=en

# Business Rules
MI_MINIMUM_AGE=21

# Expo
MI_EXPO_ACCESS_TOKEN=EXPO_ACCESS_TOKEN

# Stripe
MI_STRIPE_SECRET_KEY=STRIPE_SECRET_KEY
MI_STRIPE_SESSION_EXPIRE_AT=82800

# PayPal
MI_PAYPAL_SANDBOX=true
MI_PAYPAL_CLIENT_ID=PAYPAL_CLIENT_ID
MI_PAYPAL_CLIENT_SECRET=PAYPAL_CLIENT_SECRET

# Admin
[email protected]

# Google reCAPTCHA
MI_RECAPTCHA_SECRET=RECAPTCHA_SECRET

# Misc
MI_WEBSITE_NAME="Movin' In"
MI_TIMEZONE=UTC # Timezone for cenverting dates from UTC to local time (used in emails sent from backend). TZ identifier https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

# IPInfo (Geo lookup)
MI_IPINFO_API_KEY=IPINFO_API_KEY # Required for more than 1000 requests/day
MI_IPINFO_DEFAULT_COUNTRY=US

# Language cleanup job
MI_BATCH_SIZE=1000 # Number of documents to process per batch when deleting obsolete language values

# Sentry (Error monitoring & performance tracing)
MI_ENABLE_SENTRY=false # Set to true to enable Sentry
MI_SENTRY_DSN_BACKEND=https://[email protected]/your_project_id # Your backend DSN (keep it secret)
MI_SENTRY_TRACES_SAMPLE_RATE=1.0 # Tracing sample rate: 1.0 = 100%, 0.1 = 10%, 0 = disabled

Set the following options:

MI_DB_URI=mongodb://admin:[email protected]:27017/movinin?authSource=admin&appName=movinin
MI_COOKIE_SECRET=COOKIE_SECRET
MI_JWT_SECRET=JWT_SECRET
MI_AUTH_COOKIE_DOMAIN=localhost
MI_ADMIN_HOST=http://localhost:3003/
MI_FRONTEND_HOST=http://localhost/
MI_SMTP_HOST=smtp.sendgrid.net
MI_SMTP_PORT=587
MI_SMTP_USER=apikey
MI_SMTP_PASS=PASSWORD
[email protected]
MI_TIMEZONE=UTC

If you want to use MongoDB Atlas, put you MongoDB Atlas URI in MI_DB_URI otherwise replace PASSWORD in MI_DB_URI with your MongoDB password. Replace JWT_SECRET with a secret token. Finally, set the SMTP options. SMTP options are necessary for sign up.

Finally, set the SMTP options. SMTP options are necessary for sign up. You can use brevo or any other transactional email provider.

MI_SMTP_HOST=smtp-relay.brevo.com
MI_SMTP_PORT=587
[email protected]
MI_SMTP_PASS=PASSWORD
[email protected]

COOKIE_SECRET and JWT_SECRET should at least be 32 characters long, but the longer the better. You can use an online password generator and set the password length to 32 or longer.

MI_TIMEZONE is used for cenverting dates from UTC to local time in emails. Must be a valid TZ idenfidier. Default is UTC.

Make sure the following environment variables are correctly configured in your backend/.env file. These settings are essential for authentication to work properly. If any of them are misconfigured, login and session handling may fail.

MI_AUTH_COOKIE_DOMAIN=localhost
MI_ADMIN_HOST=http://localhost:3003/
MI_FRONTEND_HOST=http://localhost/

Replace localhost with your actual domain name.

For example, if your admin panel is accessible at https://admin.domain.com/, set the variables as follows:

MI_ADMIN_HOST=https://admin.domain.com/  
MI_FRONTEND_HOST=https://domain.com/  
MI_AUTH_COOKIE_DOMAIN=domain.com

Notes:

  • MI_AUTH_COOKIE_DOMAIN should be a top-level domain (e.g., domain.com) — not a subdomain — to allow cookie sharing between the admin panel and frontend.
  • Use HTTPS in production environments (e.g., https://admin.domain.com/, https://domain.com/).

If you want to enable push notifications in the mobile app, follow these instructions and set the following option:

MI_EXPO_ACCESS_TOKEN=EXPO_ACCESS_TOKEN

If you want to enable stripe payment gateway, sign up for a stripe account, fill the forms and save the publishable key and the secret key from stripe dashboard. Then, set the secret key in the following option in backend/.env:

MI_STRIPE_SECRET_KEY=STRIPE_SECRET_KEY

Don't expose stripe secret key on a website or embed it in a mobile application. It must be secret and stored securely in the server-side.

In stripe, all accounts have a total of four API keys by default-two for test mode and two for live mode:

  • Test mode secret key: Use this key to authenticate requests on your server when in test mode. By default, you can use this key to perform any API request without restriction.
  • Test mode publishable key: Use this key for testing purposes in your web or mobile app’s client-side code.
  • Live mode secret key: Use this key to authenticate requests on your server when in live mode. By default, you can use this key to perform any API request without restriction.
  • Live mode publishable key: Use this key, when you’re ready to launch your app, in your web or mobile app’s client-side code.

Use only your test API keys for testing. This ensures that you don't accidentally modify your live customers or charges.

If you want to use PayPal payment gateway instead of Stripe, you need to set:

MI_PAYPAL_CLIENT_ID=PAYPAL_CLIENT_ID
MI_PAYPAL_CLIENT_SECRET=PAYPAL_CLIENT_SECRET

If you want to test PayPal in sandbox mode, leave:

MI_PAYPAL_SANDBOX=true

If you want to test PayPal in production mode, set:

MI_PAYPAL_SANDBOX=false

If you want to enable HTTPS, you have to set the following options:

MI_HTTPS=true
MI_PRIVATE_KEY=/etc/ssl/movinin.io.key
MI_CERTIFICATE=/etc/ssl/movinin.io.crt
  1. Create /opt/movinin/admin/.env file with the following content:
VITE_NODE_ENV=production
VITE_MI_API_HOST=http://localhost:4004
VITE_MI_DEFAULT_LANGUAGE=en
VITE_MI_PAGE_SIZE=30
VITE_MI_PROPERTIES_PAGE_SIZE=15
VITE_MI_BOOKINGS_PAGE_SIZE=20
VITE_MI_BOOKINGS_MOBILE_PAGE_SIZE=10
VITE_MI_CDN_USERS=http://localhost:4004/cdn/movinin/users
VITE_MI_CDN_TEMP_USERS=http://localhost:4004/cdn/movinin/temp/users
VITE_MI_CDN_PROPERTIES=http://localhost:4004/cdn/movinin/properties
VITE_MI_CDN_TEMP_PROPERTIES=http://localhost:4004/cdn/movinin/temp/properties
VITE_MI_CDN_LOCATIONS=http://localhost:4004/cdn/movinin/locations
VITE_MI_CDN_TEMP_LOCATIONS=http://localhost:4004/cdn/movinin/temp/locations
VITE_MI_AGENCY_IMAGE_WIDTH=60
VITE_MI_AGENCY_IMAGE_HEIGHT=30
VITE_MI_PROPERTY_IMAGE_WIDTH=300
VITE_MI_PROPERTY_IMAGE_HEIGHT=200
VITE_MI_MINIMUM_AGE=21
VITE_MI_PAGINATION_MODE=classic
VITE_MI_CURRENCY=\$
VITE_MI_WEBSITE_NAME="Movin' In"

Set the following options:

VITE_MI_API_HOST=http://localhost:4004
VITE_MI_CDN_USERS=http://localhost:4004/cdn/movinin/users
VITE_MI_CDN_TEMP_USERS=http://localhost:4004/cdn/movinin/temp/users
VITE_MI_CDN_PROPERTIES=http://localhost:4004/cdn/movinin/properties
VITE_MI_CDN_TEMP_PROPERTIES=http://localhost:4004/cdn/movinin/temp/properties
VITE_MI_CDN_LOCATIONS=http://localhost:4004/cdn/movinin/locations
VITE_MI_CDN_TEMP_LOCATIONS=http://localhost:4004/cdn/movinin/temp/locations
VITE_MI_CURRENCY=\$

Replace localhost with your FQDN.

VITE_MI_PAGINATION_MODE: You can choose between classic or infinite_scroll. This option defaults to classic. If you choose classic, you will get a classic pagination with next and previous buttons on desktop and infinite scroll on mobile. If you choose infinite_scroll, you will get infinite scroll on desktop and mobile.

  1. Create /opt/movinin/frontend/.env file with the following content:
VITE_NODE_ENV=production
VITE_MI_API_HOST=http://localhost:4004
VITE_MI_DEFAULT_LANGUAGE=en
VITE_MI_PAGE_SIZE=30
VITE_MI_PROPERTIES_PAGE_SIZE=15
VITE_MI_BOOKINGS_PAGE_SIZE=20
VITE_MI_BOOKINGS_MOBILE_PAGE_SIZE=10
VITE_MI_CDN_USERS=http://localhost:4004/cdn/movinin/users
VITE_MI_CDN_PROPERTIES=http://localhost:4004/cdn/movinin/properties
VITE_MI_CDN_LOCATIONS=http://localhost:4004/cdn/movinin/locations
VITE_MI_AGENCY_IMAGE_WIDTH=60
VITE_MI_AGENCY_IMAGE_HEIGHT=30
VITE_MI_PROPERTY_IMAGE_WIDTH=300
VITE_MI_PROPERTY_IMAGE_HEIGHT=200
VITE_MI_MINIMUM_AGE=21
VITE_MI_PAGINATION_MODE=classic # classic or infinite_scroll
VITE_MI_PAYMENT_GATEWAY=Stripe # Stripe or PayPal
VITE_MI_STRIPE_PUBLISHABLE_KEY=STRIPE_PUBLISHABLE_KEY
VITE_MI_PAYPAL_CLIENT_ID=PAYPAL_CLIENT_ID
VITE_MI_BASE_CURRENCY=USD
VITE_MI_SET_LANGUAGE_FROM_IP=false
VITE_MI_GOOGLE_ANALYTICS_ENABLED=false
VITE_MI_GOOGLE_ANALYTICS_ID=G-XXXXXXXXXXX
VITE_MI_FB_APP_ID=XXXXXXXXXX
VITE_MI_APPLE_ID=XXXXXXXXXX
VITE_MI_GG_APP_ID=XXXXXXXXXX
VITE_MI_MIN_LOCATIONS=4
[email protected]
VITE_MI_WEBSITE_NAME="Movin' In"
VITE_MI_HIDE_AGENCIES=false
VITE_MI_MAP_LATITUDE=36.966428 # Default map latitude
VITE_MI_MAP_LONGITUDE=-95.844032 # Default map longitude
VITE_MI_MAP_ZOOM=5 # Default map zoom

Set the following options:

VITE_MI_API_HOST=http://localhost:4004
VITE_MI_CDN_USERS=http://localhost:4004/cdn/movinin/users
VITE_MI_CDN_PROPERTIES=http://localhost:4004/cdn/movinin/properties
VITE_MI_CDN_LOCATIONS=http://localhost:4004/cdn/movinin/locations
VITE_MI_STRIPE_PUBLISHABLE_KEY=STRIPE_PUBLISHABLE_KEY
VITE_MI_BASE_CURRENCY=USD
VITE_MI_SET_LANGUAGE_FROM_IP=false
VITE_MI_GOOGLE_ANALYTICS_ENABLED=false
VITE_MI_GOOGLE_ANALYTICS_ID=G-XXXXXXXXXXX
VITE_MI_FB_APP_ID=XXXXXXXXXX
VITE_MI_APPLE_ID=XXXXXXXXXX
VITE_MI_GG_APP_ID=XXXXXXXXXX
[email protected]

Replace localhost with your FQDN.

For Google Auth, you need to create OAuth 2.0 client ID and add your domains here and set VITE_MI_GG_APP_ID. Do the samething for VITE_MI_APPLE_ID here and VITE_MI_FB_APP_ID here.

If you want to enable stripe payment gateway, set stripe publishable key in VITE_MI_STRIPE_PUBLISHABLE_KEY. You can retrieve it from stripe dashboard.

VITE_MI_BASE_CURRENCY is the three-letter ISO 4217 alphabetic currency code, e.g. "USD" or "EUR". Required for Stripe payments. Must be a supported currency: https://docs.stripe.com/currencies

reCAPTCHA is by default disabled. If you want to enable it, you have to set VITE_MI_RECAPTCHA_ENABLED to true and VITE_MI_RECAPTCHA_SITE_KEY to Google reCAPTCHA site key.

If you want to use PayPal payment gateway instead of Stripe, you need to set this:

VITE_MI_PAYMENT_GATEWAY=PayPal # Stripe or PayPal
VITE_MI_PAYPAL_CLIENT_ID=PAYPAL_CLIENT_ID

You can find PayPal client id in PayPal Developer Dashboard.

  1. If you want to use the mobile app, create mobile/.env file with the following content:
MI_API_HOST=https://movinin.io:4004
MI_DEFAULT_LANGUAGE=en
MI_PAGE_SIZE=20
MI_PROPERTIES_PAGE_SIZE=8
MI_BOOKINGS_PAGE_SIZE=8
MI_CDN_USERS=https://movinin.io:4004/cdn/movinin/users
MI_CDN_PROPERTIES=https://movinin.io:4004/cdn/movinin/properties
MI_AGENCY_IMAGE_WIDTH=60
MI_AGENCY_IMAGE_HEIGHT=30
MI_PROPERTY_IMAGE_WIDTH=300
MI_PROPERTY_IMAGE_HEIGHT=200
MI_MINIMUM_AGE=21
MI_MINIMUM_AGE=21
MI_STRIPE_PUBLISHABLE_KEY=STRIPE_PUBLISHABLE_KEY
MI_STRIPE_MERCHANT_IDENTIFIER=MERCHANT_IDENTIFIER
MI_STRIPE_COUNTRY_CODE=US
MI_BASE_CURRENCY=USD
MI_WEBSITE_NAME="Movin' In"

Set the following options:

MI_API_HOST=https://movinin.io:4004
MI_CDN_USERS=https://movinin.io:4004/cdn/movinin/users
MI_CDN_PROPERTIES=https://movinin.io:4004/cdn/movinin/properties
MI_MINIMUM_AGE=21
MI_STRIPE_PUBLISHABLE_KEY=STRIPE_PUBLISHABLE_KEY
MI_STRIPE_MERCHANT_IDENTIFIER=MERCHANT_IDENTIFIER
MI_STRIPE_COUNTRY_CODE=US
MI_BASE_CURRENCY=USD

Replace https://movinin.io with an IP, hostname or FQDN.

If you want to enable stripe payment gateway, set stripe publishable key in MI_STRIPE_PUBLISHABLE_KEY. You can retrieve it from stripe dashboard.

MI_STRIPE_MERCHANT_IDENTIFIER is the merchant identifier you registered with Apple for use with Apple Pay.

MI_STRIPE_COUNTRY_CODE is the two-letter ISO 3166 code of the country of your business, e.g. "US". Required for Stripe payments.

MI_BASE_CURRENCY is the three-letter ISO 4217 alphabetic currency code, e.g. "USD" or "EUR". Required for Stripe payments. Must be a supported currency: https://docs.stripe.com/currencies

  1. Configure NGINX:
sudo nano /etc/nginx/sites-available/default

Change the configuration as follows for the frontend:

server {
    root /var/www/movinin/frontend;
    #listen 443 http2 ssl default_server;
    listen 80 default_server;
    server_name _;
    
    #ssl_certificate_key /etc/ssl/movinin.io.key;
    #ssl_certificate /etc/ssl/movinin.io.pem;

    access_log /var/log/nginx/movinin.frontend.access.log;
    error_log /var/log/nginx/movinin.frontend.error.log;

    index index.html;

    location / {
        # First attempt to serve request as file, then as directory,
        # then as index.html, then fall back to displaying a 404.
        try_files $uri $uri/ /index.html =404;
    }

    #location /cdn {
    #  alias /var/www/cdn;
    #}
}

If you want to enable SSL, uncomment and set these lines:

#listen 443 http2 ssl default_server;
#ssl_certificate_key /etc/ssl/movinin.io.key;
#ssl_certificate /etc/ssl/movinin.io.pem;

Add the following configuration for the admin panel:

server {
    root /var/www/movinin/admin;
    #listen 3003 http2 ssl default_server;
    listen 3003 default_server;
    server_name _;

    #ssl_certificate_key /etc/ssl/movinin.io.key;
    #ssl_certificate /etc/ssl/movinin.io.pem;

    #error_page 497 301 =307 https://$host:$server_port$request_uri;

    access_log /var/log/nginx/movinin.admin.access.log;
    error_log /var/log/nginx/movinin.admin.error.log;

    index index.html;

    location / {
        # First attempt to serve request as file, then as directory,
        # then as index.html, then fall back to displaying a 404.
        try_files $uri $uri/ /index.html =404;
    }
}

If you want to enable SSL, uncomment and set these lines:

#listen 3003 http2 ssl default_server;
#ssl_certificate_key /etc/ssl/movinin.io.key;
#ssl_certificate /etc/ssl/movinin.io.pem;
#error_page 497 301 =307 https://$host:$server_port$request_uri;

Then, check NGINX configuration and restart NGINX service:

sudo nginx -t
sudo systemctl restart nginx.service
sudo systemctl status nginx.service
  1. enable firewall and open Movin' In ports:
sudo ufw enable
sudo ufw allow 4004/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 3003/tcp
sudo ufw allow 27017/tcp
  1. Start movinin service:
cd /opt/movinin/backend
npm install
sudo systemctl start movinin.service

Make sure that movinin service is running with the following command:

sudo systemctl status movinin.service

Make sure that the database connection is established by checking the logs with the following command:

tail -f /var/log/movinin.log

Or this one:

sudo journalctl -xfu movinin.service

Or by opening this file:

tail -f /opt/movinin/backend/logs/all.log

Error logs are written in:

tail -f /opt/movinin/backend/logs/error.log
  1. Deploy Movin' In:
mi-deploy all

Movin' In admin panel is accessible on port 3003 and the frontend is accessible on port 80.

  1. If you don't want to use the demo database, create an admin user by running the following command from backend to create admin user:
npm run setup

It will create an admin user with the email provided in MI_ADMIN_EMAIL in backend/.env and M00vinin as password. Change the password once you login to the admin panel.

To delete the admin user with the email provided in MI_ADMIN_EMAIL, run the following command from backend:

npm run reset

If you want to deploy the frontend only, run the following command:

mi-deploy frontend

If you want to deploy the admin panel only, run the following command:

mi-deploy admin

If you want to deploy the admin panel and the frontend only, run the following command:

mi-deploy ui

If you want to deploy the backend only, run the following command:

mi-deploy backend

If you want to deploy the backend, the admin panel and the frontend, run the following command:

mi-deploy all

To change the currency, follow these instructions.