Top

TeamWise documentation

Chat, collaborate, and create teams effortlessly with Teamwise

Welcome to Teamwise !

Introduction

This guide will help you deploy the Teamwise backend on a VPS (Virtual Private Server). The process covers everything from preparing your server environment to running your application securely in production. VPS deployment is the most reliable method for production environments because it gives full control over the runtime, configurations, and performance.

1. System Setup

Once you’ve connected to your VPS via SSH, update your system packages to ensure everything is up-to-date.

  • sudo apt update && sudo apt upgrade -y
  • sudo apt install curl wget git unzip -y

This installs essential utilities like curl, git, and unzip which will be needed in later steps for fetching and setting up your code.

2. Install Node.js Runtime

The Teamwise backend runs on Node.js. Install the latest LTS version of Node.js and npm (Node Package Manager):

  • curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
  • sudo apt-get install -y nodejs
  • node --version
  • npm --version

Verifying the versions ensures the installation was successful.

3. Install and Configure Database

If your backend uses MySQL or another database, install and secure it properly:

  • sudo apt install mysql-server -y
  • sudo mysql_secure_installation

You can create a new database and user for Teamwise using:

  • CREATE DATABASE teamwise;
  • CREATE USER 'teamwise_user'@'localhost' IDENTIFIED BY 'your_password';
  • GRANT ALL PRIVILEGES ON teamwise.* TO 'teamwise_user'@'localhost';
  • FLUSH PRIVILEGES;

This isolates your backend database and makes management easier.

4. Deploy the Application Code

Next, upload or clone your Teamwise backend source code to the server:

  • git clone <your-repo-url>
  • cd teamwise-backend
  • npm install --production

After installation, create an .env file to store all necessary environment variables like database credentials, JWT secrets, and port configuration.

Example

  • APP_PORT=3000
  • DB_HOST=localhost
  • DB_USER=teamwise_user
  • DB_PASSWORD=your_password
  • DB_NAME=teamwise
  • JWT_SECRET=your_secret_key

This file allows your application to load all configurations dynamically and securely.

5. Process Management

To keep your application running continuously (even after closing the terminal or server restart), use a process manager like PM2:

  • sudo npm install -g pm2
  • pm2 start app.js --name teamwise-backend
  • pm2 save
  • pm2 startup

PM2 ensures your backend stays active, restarts automatically if it crashes, and manages logs efficiently.

6. Reverse Proxy Setup (Nginx)

Your Node.js app runs on a port (e.g., 3000), but to make it accessible via your domain (like https://yourdomain.com), you’ll set up Nginx as a reverse proxy.

Create configuration:

  • sudo nano /etc/nginx/sites-available/teamwise

Add the following:

  • server {
  •     listen 80;
  •     server_name your-domain.com;
  •     location / {
  •         proxy_pass http://localhost:3000;
  •         proxy_http_version 1.1;
  •         proxy_set_header Upgrade $http_upgrade;
  •         proxy_set_header Connection 'upgrade';
  •         proxy_set_header Host $host;
  •         proxy_cache_bypass $http_upgrade;
  •         proxy_set_header X-Real-IP $remote_addr;
  •         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  •         proxy_set_header X-Forwarded-Proto $scheme;
  •     }
  • }

Enable the configuration and restart Nginx:

  • sudo ln -s /etc/nginx/sites-available/teamwise
  • /etc/nginx/sites-enabled/
  • sudo nginx -t
  • sudo systemctl restart nginx

Now your application should be accessible via your domain.

7. Enable SSL (HTTPS)

To secure your API traffic, install a free SSL certificate using Certbot:

  • sudo apt install certbot python3-certbot-nginx -y
  • sudo certbot --nginx -d your-domain.com

Set up auto-renewal so your certificate stays valid:

  • 0 12 * * * /usr/bin/certbot renew --quiet

8. Testing and Verification

After deployment, visit your domain (e.g., https://your-domain.com/api) to confirm your backend is running.

You can monitor logs with:

  • pm2 logs teamwise-backend

Check resource usage and verify that all APIs respond correctly in production.

9. Maintenance & Updates

To deploy updates in the future:

You can monitor logs with:

  • git pull origin main
  • npm install
  • pm2 restart teamwise-backend

You should also periodically monitor server metrics (CPU, memory, disk), clean up logs, and apply security patches.

Summary

By following this guide, your Teamwise backend will be properly deployed on a VPS with a secure, stable, and maintainable setup. This approach ensures full control over runtime behavior, scalability, and environment management—making it the preferred deployment method for production use.