Backend Deployment

This guide provides two options for deploying your backend built with NestJS: using Railway (full-stack deployment including MongoDB) or deploying only the backend to your preferred platform.

Option 1: Railway

Railway allows seamless full-stack deployment, including your backend and database. Use the pre-configured template to deploy your backend, frontend, and MongoDB with minimal setup. If you have done the frontend setup you already go everything running dont repeat all steps.

Steps to Deploy

  1. Access the pre-configured Railway template via this link:Railway Deployment Template.
  2. Sign in or create an account on Railway.
  3. Click "Deploy Now" to fork the template into your account.
  4. Disconnect the repo of the backend service and connect it to your cloned version of MatureStack.
  5. Configure the necessary environment variables, such as database connection strings and JWT secrets:
    DATABASE_URL
    JWT_SECRET
    PORT
    URL
  6. Click "Deploy" and wait for the backend and database to be deployed. Railway will handle the deployment process.

After deployment, Railway will provide a unique URL for your backend API.

Option 2: Custom Deployment

If you prefer to deploy only the backend, you can use any Node.js hosting platform (e.g., AWS, Heroku, or DigitalOcean, Adaptable.io). MatureStack comes with a predefined Dockerfile which should work on any platform.

Steps to Deploy

  1. Push your backend code to a Git repository (e.g., GitHub, GitLab).
  2. Set up a hosting service for Node.js applications. For example:
    • Heroku: Use the Heroku CLI to deploy your backend.
    • AWS: Set up an Elastic Beanstalk application for Node.js.
    • DigitalOcean: Deploy your backend using an App Platform or a Docker container.
  3. Configure the required environment variables on your hosting platform:
    DATABASE_URL
    JWT_SECRET
    PORT
    URL
  4. Deploy your backend and ensure that the application is running.

Once deployed, your backend API will be available at the URL provided by your hosting platform.

Best Practices

  • Use separate environments (e.g., development, staging, and production) for testing and deployment.
  • Monitor application logs and metrics to ensure performance and reliability.
  • Secure your application by using strong secrets for JWT and database credentials.

For additional details, refer to the documentation of your chosen hosting platform or NestJS documentation.

MatureStack LogoBuilt with MatureStack