Skip to content

Latest commit

 

History

History
1505 lines (1026 loc) · 60.8 KB

README.md

File metadata and controls

1505 lines (1026 loc) · 60.8 KB

Projects Service

GitHub package.json version (subfolder of monorepo) License


The Project building block facilitates the creation and engagement with micro-improvement projects.

Supported Operating Systems

  • Ubuntu (Recommended: Version 20 and above)
  • Windows (Recommended: Version 11 and above)
  • macOs (Recommended: Version 12 and above)

Setup Options

Project services can be setup using two methods:

Note : This guide outlines two setup methods, detailed below. For a quick, beginner-friendly setup and walkthrough of services, it is recommended to use the Dockerized Services & Dependencies setup with the Docker-Compose file.

Dockerized Services & Dependencies Using Docker-Compose File

Dockerized Services & Dependencies

Expectation: By diligently following the outlined steps, you will successfully establish a fully operational Project application setup, including both the portal and backend services.

Prerequisites

To set up the Project application, ensure you have Docker and Docker Compose installed on your system. For Ubuntu users, detailed installation instructions for both can be found in the documentation here: How To Install and Use Docker Compose on Ubuntu. To install and use Nodejs in Ubuntu machine, you can follow instructions here: How To Install Nodejs in Ubuntu. For Windows and MacOS users, you can refer to the Docker documentation for installation instructions: Docker Compose Installation Guide. Once these prerequisites are in place, you're all set to get started with setting up the Project application.

Installation

Create project Directory: Establish a directory titled project.

Example Command: mkdir project && cd project/

Note: All commands are run from the project directory.

Operating Systems: Linux / macOS

Caution: Before proceeding, please ensure that the ports given here are available and open. It is essential to verify their availability prior to moving forward. You can run below command in your terminal to check this

for port in 3000 3001 3002 6000 5001 4000 9092 5432 7007 2181 2707 3569; do
    if lsof -iTCP:$port -sTCP:LISTEN &>/dev/null; then
        echo "Port $port is in use"
    else
        echo "Port $port is available"
    fi
done
  1. Download and execute main setup script: Execute the following command in your terminal from the project directory.

    curl -OJL https://github.com/ELEVATE-Project/project-service/raw/main/documentation/1.0.0/dockerized/scripts/mac-linux/setup_project.sh && chmod +x setup_project.sh && sudo ./setup_project.sh
    

    Note : The script will download all the essential files and launch the services in Docker. Once all services are successfully up and running, you can proceed to the next steps.

    General Instructions :

    1. All containers which are part of the docker-compose can be gracefully stopped by pressing Ctrl + c in the same terminal where the services are running.

    2. All docker containers can be stopped and removed by using below command.

      sudo ./docker-compose-down.sh
      
    3. All services and dependencies can be started using below command.

      sudo ./docker-compose-up.sh
      

Keep the current terminal session active, and kindly open a new terminal window within the project directory.

After successfully completing this, please move to the next section: Enable Citus Extension

Operating Systems: Windows

  1. Download Docker Compose File: Retrieve the docker-compose-project.yml file from the Project service repository and save it to the project directory.

    curl -OJL https://github.com/ELEVATE-Project/project-service/raw/main/documentation/1.0.0/dockerized/docker-compose-project.yml
    

    Note: All commands are run from the project directory.

  2. Download Environment Files: Using the OS specific commands given below, download environment files for all the services.

    • Windows

      curl -L ^
       -O https://github.com/ELEVATE-Project/project-service/raw/main/documentation/1.0.0/dockerized/envs/interface_env ^
       -O https://github.com/ELEVATE-Project/project-service/raw/main/documentation/1.0.0/dockerized/envs/entity_management_env ^
       -O https://github.com/ELEVATE-Project/project-service/raw/main/documentation/1.0.0/dockerized/envs/project_env ^
       -O https://github.com/ELEVATE-Project/project-service/raw/main/documentation/1.0.0/dockerized/envs/notification_env ^
       -O https://github.com/ELEVATE-Project/project-service/raw/main/documentation/1.0.0/dockerized/envs/scheduler_env ^
       -O https://github.com/ELEVATE-Project/project-service/raw/main/documentation/1.0.0/dockerized/envs/user_env ^
       -O https://github.com/ELEVATE-Project/project-service/raw/main/documentation/1.0.0/dockerized/envs/env.js
      

    Note: Modify the environment files as necessary for your deployment using any text editor, ensuring that the values are appropriate for your environment. The default values provided in the current files are functional and serve as a good starting point. Refer to the sample env files provided at the Project, User, Notification, Scheduler, Interface and Entity-management repositories for reference.

    Caution: While the default values in the downloaded environment files enable the Project Application to operate, certain features may not function correctly or could be impaired unless the adopter-specific environment variables are properly configured.

  3. Download replace_volume_path Script File

    • Windows

      curl -OJL https://raw.githubusercontent.com/ELEVATE-Project/project-service/main/documentation/1.0.0/dockerized/scripts/windows/replace_volume_path.bat
      
  4. Run replace_volume_path Script File

    • Windows

      Run the script file either by double clicking it or by executing the following command from the terminal.

      replace_volume_path.bat
      

      Note: The provided script file replaces the host path for the portal service container volume in the docker-compose-project.yml file with your current directory path.

      volumes:

      - /home/shikshalokam/elevate/single-click/linux/env.js:/usr/src/app/www/assets/env/env.js

  5. Download docker-compose-up & docker-compose-down Script Files

    • Windows

      curl -OJL https://github.com/ELEVATE-Project/project-service/raw/main/documentation/1.0.0/dockerized/scripts/windows/docker-compose-up.bat
      
      curl -OJL https://github.com/ELEVATE-Project/project-service/raw/main/documentation/1.0.0/dockerized/scripts/windows/docker-compose-down.bat
      
  6. Run All Services & Dependencies:All services and dependencies can be started using the docker-compose-up script file.

    • Windows

      docker-compose-up.bat
      

      Double-click the file or run the above command from the terminal.

      Note: During the first Docker Compose run, the database, migration seeder files, and the script to set the default organization will be executed automatically.

  7. Remove All Service & Dependency Containers: All docker containers can be stopped and removed by using the docker-compose-down file.

    • Windows

      docker-compose-down.bat
      

    Caution: As per the default configuration in the docker-compose-project.yml file, using the down command will lead to data loss since the database container does not persist data. To persist data across down commands and subsequent container removals, refer to the "Persistence of Database Data in Docker Containers" section of this documentation.

Enable Citus Extension (Optional)

User management service comes with this bundle relies on PostgreSQL as its core database system. To boost performance and scalability, users can opt to enable the Citus extension. This transforms PostgreSQL into a distributed database, spreading data across multiple nodes to handle large datasets more efficiently as demand grows.

For more information, refer Citus Data.

To enable the Citus extension for user services, follow these steps.

  1. Create a sub-directory named user and download distributionColumns.sql into it. (Skip this for linux/macOs)

    mkdir user && curl -o ./user/distributionColumns.sql -JL https://github.com/ELEVATE-Project/project-service/raw/main/documentation/1.0.0/distribution-columns/user/distributionColumns.sql
    
  2. Set up the citus_setup file by following the steps given below.

    • Ubuntu/Linux/Mac

      1. Enable Citus and set distribution columns for user database by running the citus_setup.shwith the following arguments.
        sudo ./citus_setup.sh user postgres://postgres:postgres@citus_master:5432/user
        
    • Windows

      1. Download the citus_setup.bat file.
         curl -OJL https://github.com/ELEVATE-Project/project-service/raw/main/documentation/1.0.0/dockerized/scripts/windows/citus_setup.bat
        
      2. Enable Citus and set distribution columns for user database by running the citus_setup.batwith the following arguments.
        citus_setup.bat user postgres://postgres:postgres@citus_master:5432/user
        

        Note: Since the citus_setup.bat file requires arguments, it must be run from a terminal.

Persistence Of Database Data In Docker Container (Optional)

To ensure the persistence of database data when running docker compose down, it is necessary to modify the docker-compose-project.yml file according to the steps given below:

  1. Modification Of The docker-compose-project.yml File:

    Begin by opening the docker-compose-project.yml file. Locate the section pertaining to the Citus and mongo container and proceed to uncomment the volume specification. This action is demonstrated in the snippet provided below:

    mongo:
    image: 'mongo:4.4.14'
    restart: 'always'
    ports:
        - '27017:27017'
    networks:
        - project_net
    volumes:
        - mongo-data:/data/db
    logging:
        driver: none
    
    citus:
        image: citusdata/citus:11.2.0
        container_name: 'citus_master'
        ports:
            - 5432:5432
        volumes:
            - citus-data:/var/lib/postgresql/data
  2. Uncommenting Volume Names Under The Volumes Section:

    Next, navigate to the volumes section of the file and proceed to uncomment the volume names as illustrated in the subsequent snippet:

    networks:
        elevate_net:
            external: false
    
    volumes:
        citus-data:
        mongo-data:

By implementing these adjustments, the configuration ensures that when the docker-compose down command is executed, the database data is securely stored within the specified volumes. Consequently, this data will be retained and remain accessible, even after the containers are terminated and subsequently reinstated using the docker-compose up command.

Sample User Accounts Generation

During the initial setup of Project services with the default configuration, you may encounter issues creating new accounts through the regular SignUp flow on the project portal. This typically occurs because the default SignUp process includes OTP verification to prevent abuse. Until the notification service is configured correctly to send actual emails, you will not be able to create new accounts.

In such cases, you can generate sample user accounts using the steps below. This allows you to explore the Project services and portal immediately after setup.

Warning: Use this generator only immediately after the initial system setup and before any normal user accounts are created through the portal. It should not be used under any circumstances thereafter.

  • Ubuntu/Linux/Mac

    sudo ./insert_sample_data.sh user postgres://postgres:postgres@citus_master:5432/user
    
  • Windows

    1. Download The sampleData.sql Files:

      mkdir sample-data\user 2>nul & ^
      curl -L "https://raw.githubusercontent.com/ELEVATE-Project/project-service/main/documentation/1.0.0/sample-data/windows/user/sampleData.sql" -o sample-data\user\sampleData.sql
      
    2. Download The insert_sample_data Script File:

      curl -L -o insert_sample_data.bat https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/dockerized/scripts/windows/insert_sample_data.bat
      
    3. Run The insert_sample_data Script File:

      insert_sample_data.bat user postgres://postgres:postgres@citus_master:5432/user
      

    After successfully running the script mentioned above, the following user accounts will be created and available for login:

    Email ID Password Role
    aaravpatel@example.com Password1@ State Education Officer
    arunimareddy@example.com Password1@ State Education Officer
    aaravpatel@example.com Password1@ State Education Officer

Sample Data Creation For Projects

This step will guide us in implementing a sample project solution following the initial setup of the project service.

  1. Insert Sample Data To Database:

    • Ubuntu/Linux/Mac

      1. Insert sample data by running the following command.

        sudo ./add_sample_project_entity_data.sh
        
    • Windows

      1. Download entity-project-sample-data.bat Script File:

        curl -L ^
        -O https://github.com/ELEVATE-Project/project-service/raw/main/documentation/1.0.0/dockerized/scripts/windows/entity-project-sample-data.bat ^            
        
      2. Make the setup file executable by running the following command.

        entity-project-sample-data.bat
        

Default Forms Creation for Portal Configuration

This step inserts configuration forms into MongoDB, enabling or disabling features and fields on portal pages.

Insert Forms Data into Database

  • Ubuntu/Linux/Mac:

    curl -OJL https://github.com/ELEVATE-Project/project-service/raw/main/documentation/1.0.0/dockerized/scripts/mac-linux/import_forms_mongo.sh && chmod +x import_forms_mongo.sh && sudo ./import_forms_mongo.sh mongodb://mongo:27017/elevate-project
    
  • Windows:

    1. Download the import_forms_mongo.bat file:
      curl -L -O https://github.com/ELEVATE-Project/project-service/raw/main/documentation/1.0.0/dockerized/scripts/windows/import_forms_mongo.bat
    2. Run the script:
      import_forms_mongo.bat mongodb://localhost:27017/elevate-project

Explore the Portal

Once the services are up and the front-end app bundle is built successfully, navigate to localhost:7007 to access the Project app.

Warning: In this setup, features such as Sign-Up, Project Certificate, Project Sharing, and Project PDF Report will not be available because cloud storage credentials have been masked in the environment files for security reasons.

Natively Installed Services & Dependencies

PM2 Managed Services & Natively Installed Dependencies

System Requirements

  • Node.js®: v20
  • PostgreSQL: 16
  • Apache Kafka®: 3.5.0
  • MongoDB: 4.4.14
  • Gotenberg: 8.5.0

Expectation: Upon following the prescribed steps, you will achieve a fully operational ELEVATE-Project application setup. Both the portal and backend services are managed using PM2, with all dependencies installed natively on the host system.

Prerequisites

Before setting up the following ELEVATE-Project application, dependencies given below should be installed and verified to be running. Refer to the steps given below to install them and verify.

  • Ubuntu/Linux

    1. Download dependency management scripts:

      curl -OJL https://raw.githubusercontent.com/ELEVATE-Project/project-service/main/documentation/1.0.0/native/scripts/linux/check-dependencies.sh && \
      curl -OJL https://raw.githubusercontent.com/ELEVATE-Project/project-service/main/documentation/1.0.0/native/scripts/linux/install-dependencies.sh && \
      curl -OJL https://raw.githubusercontent.com/ELEVATE-Project/project-service/main/documentation/1.0.0/native/scripts/linux/uninstall-dependencies.sh && \
      chmod +x check-dependencies.sh && \
      chmod +x install-dependencies.sh && \
      chmod +x uninstall-dependencies.sh
      
    2. Verify installed dependencies by running check-dependencies.sh:

      ./check-dependencies.sh
      

      Note: Keep note of any missing dependencies.

    3. Install dependencies by running install-dependencies.sh:

      ./install-dependencies.sh
      

      Note: Install all missing dependencies and use check-dependencies script to ensure everything is installed and running.

    4. Uninstall dependencies by running uninstall-dependencies.sh:

      ./uninstall-dependencies.sh
      

      Warning: Due to the destructive nature of the script (without further warnings), it should only be used during the initial setup of the dependencies. For example, Uninstalling PostgreSQL/Citus using script will lead to data loss. USE EXTREME CAUTION.

      Warning: This script should only be used to uninstall dependencies that were installed via installation script in step 3. If same dependencies were installed using other methods, refrain from using this script. This script is provided in-order to reverse installation in-case issues arise from a bad install.

  • MacOS

    1. Install Node.js 20:

      brew install node@20
      
      brew link --overwrite node@20
      
    2. Install Kafka:

      brew install kafka
      

      Note: To install Kafka on older macOS versions like Monterey (Intel architecture), you need to follow the manual installation process instead of using Homebrew. The process includes downloading Kafka, setting up ZooKeeper, and running Kafka services. You can find the official Kafka installation guide here: Kafka Quickstart Guide.This ensures compatibility with older macOS systems. Follow the steps outlined in the documentation for a smooth setup.

    3. Install PostgreSQL 16:

      brew install postgresql@16
      
    4. Install PM2:

      sudo npm install pm2@latest -g
      
    5. Install Redis:

      brew install redis
      
    6. Install mongDB:

      brew tap mongodb/brew
      
      brew install mongodb-community@4.4
      
      brew link mongodb-community@4.4 --force
      
      brew services start mongodb-community@4.4
      
    7. Download check-dependencies.sh file:

      curl -OJL https://github.com/ELEVATE-Project/project-service/raw/main/documentation/1.0.0/native/scripts/macos/check-dependencies.sh && \
      chmod +x check-dependencies.sh
      
    8. Verify installed dependencies by running check-dependencies.sh:

      ./check-dependencies.sh
      

      Note : If you've manually installed Kafka without Homebrew, the script might incorrectly indicate that Kafka and Homebrew are not installed, as it checks only for Homebrew installations. In such cases, you can safely ignore this warning. Ensure that both Kafka and ZooKeeper are running on their default ports (ZooKeeper on 2181, Kafka on 9092). This will confirm proper installation and functionality despite the script's output.

  • Windows

    1. Install Node.js 20:

      Download and install Node.js v20 for Windows platform (x64) from official Node.js download page.

    2. Install Kafka 3.5.0:

      1. Adapt the instructions given in the following "Apache Kafka on Windows" documentation to install Kafka version 3.5.0.

        Note: As per the instructions, Kafka server and Zookeeper has to be kept active on different WSL terminals for the entire lifetime of ELEVATE-Project services.

        Note: Multiple WSL terminals can be opened by launching Ubuntu from start menu.

      2. Open a new WSL terminal and execute the following command to get the IP of the WSL instance.

        ip addr show eth0
        

        Sample Output:

        2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1492 qdisc mq state UP group default qlen 1000
        link/ether 11:56:54:f0:as:vf brd ff:ff:ff:ff:ff:ff
        inet 172.12.46.150/20 brd 172.24.79.255 scope global eth0
            valid_lft forever preferred_lft forever
        inet6 fe80::215:5dff:fee7:dc52/64 scope link
            valid_lft forever preferred_lft forever
        

        Keep note of the IP address shown alongside inet. In the above case, 172.12.46.150 is IP address of the WSL instance.

      3. In the same WSL terminal, navigate to config directory of Kafka from step 1 and make the following changes to server.properties file.

        • Uncomment listeners=PLAINTEXT://:9092 line and change it to listeners=PLAINTEXT://0.0.0.0:9092 to allow connections from any IP.

        • Uncomment advertised.listeners line and set it to advertised.listeners=PLAINTEXT://172.12.46.150:9092. Replace 172.12.46.150 with the actual IP address of your WSL instance.

      4. Restart the Zookeeper and Kafka Server from their own WSL terminals from step 1.

    3. Install Redis:

      1. Follow the instructions given in the official Redis Documentation to install Redis using WSL.

      2. Using the WSL terminal, open the Redis configuration file in a text editor, such as nano:

        sudo nano /etc/redis/redis.conf
        
      3. Find the line containing bind 127.0.0.1 ::1 and change it to bind 0.0.0.0 ::.. This change allows Redis to accept connections from any IP address. Then save and exit the file.

      4. Restart Redis to apply the changes:

        sudo service redis-server restart
        
    4. Install PM2:

      npm install pm2@latest -g
      
    5. Install PostgreSQL 16:

      1. Download and install PostgreSQL 16 from EnterpriseDB PostgreSQL download page.

        Note: Set username and password for the default database to be 'postgres' during installation.

      2. Once installed, Add C:\Program Files\PostgreSQL\16\bin to windows environment variables. Refer here or here for more information regarding how to set it.

    6. Install MongoDB:

      Follow the official MongoDB Website to install MongoDB.

    7. Install Gotenberg via Docker:

      1. Download Docker Desktop for Windows from Docker Website

      2. Run the installer and follow the setup instructions.

      3. Ensure Docker Desktop is running and configured to use Linux containers(default settings).

      4. Open a terminal (e.g., Command Prompt).

      5. Pull the Gotenberg image:

        docker pull gotenberg/gotenberg:latest
        
      6. Run the Gotenberg container with the following command:

        docker run -d --name gotenberg -p 3000:3000 gotenberg/gotenberg:latest
        
      7. Verify the container is running. You should see the Gotenberg container listed after running the below command.

        docker ps
        

Installation

  1. Create ELEVATE-Project Directory: Create a directory named ELEVATE-Project.

    Example Command: mkdir ELEVATE-Project && cd ELEVATE-Project/

  2. Git Clone Services And Portal Repositories

    • Ubuntu/Linux/MacOS

      git clone -b main https://github.com/ELEVATE-Project/project-service.git && \
      git clone -b main https://github.com/ELEVATE-Project/entity-management.git && \
      git clone -b master https://github.com/ELEVATE-Project/user.git && \
      git clone -b master https://github.com/ELEVATE-Project/notification.git && \
      git clone -b main https://github.com/ELEVATE-Project/interface-service.git && \
      git clone -b master https://github.com/ELEVATE-Project/scheduler.git && \
      git clone -b main https://github.com/ELEVATE-Project/observation-survey-projects-pwa
      
    • Windows

      git clone -b staging https://github.com/ELEVATE-Project/project-service.git &
      git clone -b staging https://github.com/ELEVATE-Project/entity-management.git &
      git clone -b master https://github.com/ELEVATE-Project/user.git &
      git clone -b master https://github.com/ELEVATE-Project/notification.git &
      git clone -b main https://github.com/ELEVATE-Project/interface-service.git &
      git clone -b master https://github.com/ELEVATE-Project/scheduler.git &
      git clone -b main https://github.com/ELEVATE-Project/observation-survey-projects-pwa
      
  3. Install NPM Packages

    • Ubuntu/Linux/MacOS

      cd project-service && npm install && cd ../ && \
      cd entity-management/src && npm install && cd ../.. && \
      cd user/src && npm install && cd ../.. && \
      cd notification/src && npm install && cd ../.. && \
      cd interface-service/src && npm install && cd ../.. && \
      cd scheduler/src && npm install && cd ../.. && \
      cd observation-survey-projects-pwa && npm install --force && cd ..
      
    • Windows

      cd project-service && npm install && cd ..
      cd user\src && npm install && cd ..\..
      cd notification\src && npm install && cd ..\..
      cd interface-service\src && npm install && cd ..\..
      cd scheduler\src && npm install && cd ..\..
      cd observation-survey-projects-pwa && npm install --force && cd ..
      

      Note: Entity-management service runs only on node-16 for Windows native setup.

      nvm use 16
      
      cd entity-management\src && npm install && cd ..\..
      

      Note: Change the node version as it was before.

  4. Download Environment Files

    • Ubuntu/Linux

      curl -L -o project-service/.env https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/envs/project_env && \
      curl -L -o entity-management/src/.env https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/envs/entity_management_env && \
      curl -L -o user/src/.env https://github.com/ELEVATE-Project/project-service/raw/refs/heads/main/documentation/1.0.0/native/envs/user_env && \
      curl -L -o notification/src/.env https://github.com/ELEVATE-Project/project-service/raw/refs/heads/main/documentation/1.0.0/native/envs/notification_env && \
      curl -L -o interface-service/src/.env https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/envs/interface_env && \
      curl -L -o scheduler/src/.env https://github.com/ELEVATE-Project/project-service/raw/refs/heads/main/documentation/1.0.0/native/envs/scheduler_env && \
      curl -L -o observation-survey-projects-pwa/src/environments/environment.ts https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/envs/enviroment.ts
      
    • MacOs

      curl -L -o project-service/.env https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/envs/project_env && \
      curl -L -o entity-management/src/.env https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/envs/entity_management_env && \
      curl -L -o user/src/.env https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/envs/non-citus/user_env && \
      curl -L -o notification/src/.env https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/envs/non-citus/notification_env && \
      curl -L -o interface-service/src/.env https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/envs/interface_env && \
      curl -L -o scheduler/src/.env https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/envs/scheduler_env && \
      curl -L -o observation-survey-projects-pwa/src/environments/environment.ts https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/envs/enviroment.ts
      
    • Windows

      curl -L -o project-service\.env https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/envs/project_env &
      curl -L -o entity-management\src\.env https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/envs/entity_management_env &
      curl -L -o user\src\.env https://github.com/ELEVATE-Project/project-service/raw/refs/heads/main/documentation/1.0.0/native/envs/user_env &
      curl -L -o notification\src\.env https://github.com/ELEVATE-Project/project-service/raw/refs/heads/main/documentation/1.0.0/native/envs/notification_env &
      curl -L -o interface-service\src\.env https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/envs/interface_env &
      curl -L -o scheduler\src\.env https://github.com/ELEVATE-Project/project-service/raw/refs/heads/main/documentation/1.0.0/native/envs/scheduler_env &
      curl -L -o observation-survey-projects-pwa\src\environments\environment.ts https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/envs/enviroment.ts
      

    Note: Modify the environment files as necessary for your deployment using any text editor, ensuring that the values are appropriate for your environment. The default values provided in the current files are functional and serve as a good starting point. Refer to the sample env files provided at the Project, User, Notification, Scheduler, Interface and Entity-Management repositories for reference.

    Caution: While the default values in the downloaded environment files enable the ELEVATE-Project Application to operate, certain features may not function correctly or could be impaired unless the adopter-specific environment variables are properly configured.

    Important: As mentioned in the above linked document, the User SignUp functionality may be compromised if key environment variables are not set correctly during deployment. If you opt to skip this setup, consider using the sample user account generator detailed in the Sample User Accounts Generation section of this document.

  5. Create Databases

    • Ubuntu/Linux

      1. Download create-databases.sh Script File:

        curl -OJL https://raw.githubusercontent.com/ELEVATE-Project/project-service/main/documentation/1.0.0/native/scripts/linux/create-databases.sh
        
      2. Make the executable by running the following command:

        chmod +x create-databases.sh
        
      3. Run the script file:

        ./create-databases.sh
        
    • MacOs

      1. Download create-databases.sh Script File:

        curl -OJL https://raw.githubusercontent.com/ELEVATE-Project/project-service/main/documentation/1.0.0/native/scripts/macos/create-databases.sh
        
        
      2. Make the executable by running the following command:

        chmod +x create-databases.sh
        
      3. Run the script file:

        ./create-databases.sh
        
    • Windows

      1. Download create-databases.bat Script File:
        curl -OJL https://raw.githubusercontent.com/ELEVATE-Project/project-service/main/documentation/1.0.0/native/scripts/windows/create-databases.bat
        
      2. Run the script file:
        create-databases.bat
        
  6. Run Migrations To Create Tables

    • Ubuntu/Linux/MacOS

      1. Run Migrations:
        cd user/src && npx sequelize-cli db:migrate && cd ../.. && \
        cd notification/src && npx sequelize-cli db:migrate && cd ../..
        
    • Windows

      1. Run Migrations:
        cd user\src && npx sequelize-cli db:migrate && cd ..\.. && cd notification\src && npx sequelize-cli db:migrate && cd ..\..
        
  7. Enabling Citus And Setting Distribution Columns (Optional)

    To boost performance and scalability, users can opt to enable the Citus extension. This transforms PostgreSQL into a distributed database, spreading data across multiple nodes to handle large datasets more efficiently as demand grows.

    NOTE: Currently only available for Linux based operation systems.

    1. Download user distributionColumns.sql file.

      curl -o ./user/distributionColumns.sql -JL https://github.com/ELEVATE-Project/project-service/raw/refs/heads/main/documentation/1.0.0/distribution-columns/user/distributionColumns.sql
      
    2. Set up the citus_setup file by following the steps given below.

      • Ubuntu/Linux

        1. Download the citus_setup.sh file:

          curl -OJL https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/scripts/linux/citus_setup.sh
          
          
        2. Make the setup file executable by running the following command:

          chmod +x citus_setup.sh
          
        3. Enable Citus and set distribution columns for user database by running the citus_setup.shwith the following arguments.

          ./citus_setup.sh user postgres://postgres:postgres@localhost:9700/users
          
  8. Insert Initial Data

    • Ubuntu/Linux/MacOS

      1. Download entity-project-sample-data.sh Script File:

        1.1. For ubuntu/linux

        curl -OJL https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/scripts/linux/entity-project-sample-data.sh
        

        1.1. For mac

        curl -OJL https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/scripts/macos/entity-project-sample-data.sh
        
      2. Make the executable by running the following command:

        chmod +x entity-project-sample-data.sh
        
      3. Run the script file:

        ./entity-project-sample-data.sh
        
      4. Run seeders of user service

        cd user/src && npm run db:seed:all && cd ../..
        
    • Windows

      1. Download entity-project-sample-data.bat Script File:

        curl -OJL https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/scripts/windows/entity-project-sample-data.bat
        
      2. Run the script file:

        entity-project-sample-data.bat
        
      3. Run seeders of user service

        cd user\src && npm run db:seed:all && cd ..\..
        
  9. Insert Forms Data into Database

    • Ubuntu/Linux/MacOS

      1. Download import_forms.js Script File And Make the setup file executable by running the following command:

        curl -s https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/scripts/linux/import_forms.js | node
        
    • Windows

      1. Download import_forms_mongo.bat Script File and execute the file by running the following commands:

        curl -OJL https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/scripts/windows/import_forms_mongo.bat
        
        import_forms_mongo.bat
        
  10. Start The Services

    Following the steps given below, 2 instances of each ELEVATE-Project backend service will be deployed and be managed by PM2 process manager.

    • Ubuntu/Linux

      (cd project-service && pm2 start app.js --name project-service && cd -) && \
      (cd entity-management/src && pm2 start app.js --name entity-management && cd -) && \
      (cd user/src && pm2 start app.js --name user && cd -) && \
      (cd notification/src && pm2 start app.js --name notification && cd -) && \
      (cd interface-service/src && pm2 start app.js --name interface && cd -) && \
      (cd scheduler/src && pm2 start app.js --name scheduler && cd -)
      
    • MacOs

      cd project-service && npx pm2 start app.js -i 2 --name project-service && cd .. && \
      cd entity-management/src && npx pm2 start app.js -i 2 --name entity-management && cd ../.. && \
      cd user/src && npx pm2 start app.js -i 2 --name user && cd ../.. && \
      cd notification/src && npx pm2 start app.js -i 2 --name notification && cd ../.. && \
      cd interface-service/src && npx pm2 start app.js -i 2 --name interface && cd ../.. && \
      cd scheduler/src && npx pm2 start app.js -i 2 --name scheduler && cd ../..
      
    • Windows

      cd project-service && pm2 start app.js --name project-service && cd ..
      cd entity-management\src && pm2 start app.js --name entity-management && cd ..\..
      cd user\src && pm2 start app.js --name user && cd ..\..
      cd notification\src && pm2 start app.js --name notification && cd ..\..
      cd interface-service\src && pm2 start app.js --name interface && cd ..\..
      cd scheduler\src && pm2 start app.js --name scheduler && cd ..\..
      
  11. Run Service Scripts

    • Ubuntu/Linux/MacOS

      cd user/src/scripts && node insertDefaultOrg.js && node viewsScript.js && cd ../../..
      
    • Windows

      cd user\src\scripts && node insertDefaultOrg.js && node viewsScript.js && cd ..\..\..
      
  12. Start The Portal

    ELEVATE-Project portal utilizes Ionic for building the browser bundle, follow the steps given below to install them and start the portal.

    • Ubuntu/Linux/Windows

      1. Install the Ionic framework:

        npm install -g ionic
        
      2. Install the Ionic client:

        npm install -g @ionic/cli
        
      3. Navigate to observation-survey-projects-pwa directory:

        cd observation-survey-projects-pwa
        
      4. Run the project on your local system using the following command:

        ionic serve
        

    Navigate to http://localhost:8100 to access the ELEVATE-Project Portal.

Sample User Accounts Generation

During the initial setup of ELEVATE-Project services with the default configuration, you may encounter issues creating new accounts through the regular SignUp flow on the ELEVATE-Project portal. This typically occurs because the default SignUp process includes OTP verification to prevent abuse. Until the notification service is configured correctly to send actual emails, you will not be able to create new accounts.

In such cases, you can generate sample user accounts using the steps below. This allows you to explore the ELEVATE-Project services and portal immediately after setup.

Warning: Use this generator only immediately after the initial system setup and before any normal user accounts are created through the portal. It should not be used under any circumstances thereafter.

  • Ubuntu/Linux

    curl -o insert_sample_data.sh https://raw.githubusercontent.com/ELEVATE-Project/project-service/main/documentation/1.0.0/native/scripts/linux/insert_sample_data.sh && \
    chmod +x insert_sample_data.sh && \
    ./insert_sample_data.sh
    
  • MacOS

    curl -o insert_sample_data.sh https://raw.githubusercontent.com/ELEVATE-Project/project-service/refs/heads/main/documentation/1.0.0/native/scripts/macos/insert_sample_data.sh && \
    chmod +x insert_sample_data.sh && \
    ./insert_sample_data.sh
    
  • Windows

    curl -o insert_sample_data.bat https://raw.githubusercontent.com/ELEVATE-Project/project-service/main/documentation/1.0.0/native/scripts/windows/insert_sample_data.bat && ^
    insert_sample_data.bat
    

After successfully running the script mentioned above, the following user accounts will be created and available for login:

Email ID Password Role
aaravpatel@example.com Password1@ State Educational Officer
arunimareddy@example.com Password1@ State Educational Officer
devikasingh@example.com Password1@ State Educational Officer

Postman Collections

Adding New Projects to the System

With implementation scripts, you can seamlessly add new projects to the system. Once a project is successfully added, it becomes visible on the portal, ready for use and interaction. For a comprehensive guide on setting up and using the implementation script, please refer to the documentation here.

Team

Open Source Dependencies

Several open source dependencies that have aided Projects's development:

NodeJS Apache Kafka Redis Jest Git