Backend service for ICAT Climate Action Assessment Tool for Transport Sector - TraCAD.
Supported by Initiative for Climate Action Transparency - ICAT.
Built using Node.js 16 and Nest framework.
This application uses a MySQL Database. The ICAT-country.sql
configuration file containing the database schema and some dummy data is provided in the root folder. This database is also used by the CountryScheduler application.
-
Download and install the Node.js 16 LTS version for your operational system.
-
Download or clone this repository.
-
In the terminal, go to this repository's main folder.
-
Install the NPM dependencies (including Nest) with the command:
$ npm install --force
- Set up the Environment Variables
-
In the machine:
- Windows: using the
set
command in the terminal - Linux/MacOS: using the
export
command in the terminal
- Windows: using the
-
Or creating a
.env
file using.env.example
as base
- Run the app:
$ npm run start
This is an example cloud installation using Docker and Google Cloud Plataform. The provided
Dockerfile
can be used for local or cloud installation with different services.
-
In GCP Console, go to Artifact Registry and enable the Artifact Registry API
-
In the Artifact Registry, create a new repository:
- Format: Docker
- Type: Standard
- Location: desired application location
- Encryption: Google-managed key
-
Download and install gcloud CLI.
-
Download or clone this repository.
-
In the terminal, go to this repository's main folder.
-
Build your container in the Artifacts Register using the provided
Dockerfile
. The container path can be found on the Artifact Registry's repository page.
$ gcloud builds submit --tag [CONTAINER PATH]
- Go to Cloud Run and create a New Service:
- Choose the option
Deploy one revision from an existing container image
and select the container image updated in the previous step - Add a service name
- Select the application region
- Select
Allow unauthenticated invocations
in the Authentication option - In the Container section:
- Select Container port 8080
- Add the Environment Variables
- Add the Cloud SQL connections
- Choose the option
Noticed that some special permissions in GCP can be necessary to perform these tasks.
The environment variables should be declared as follow:
Variable name | Description |
---|---|
PORT |
Application Port |
DATABASE_HOST |
Database Host(*) |
SOCKET_PATH |
Database Socket Path(*) |
DATABASE_PORT |
Database Port |
DATABASE_USER |
Database Socket User |
DATABASE_PASSWORD |
Database Password |
DATABASE_NAME |
Database Name |
BASE_URL |
Current Application URL |
CLIENT_URL |
Country Service Web URL |
PWD_RESET_URL |
Country Service Web URL + /reset-password |
CAL_ENGINE_BASE_URL |
Calculation Engine URL |
MAC_PNG_URL |
Python Application URL |
API_KEY_1 |
API key. Should be the same as used by clients |
API_KEY_2 |
API key. Should be the same as used by clients |
(*) Can be used the Database Host or the Database Socket Path depending of the database configuration
After the application installation, the API Documentation is available in the application URL + /api/
with Swagger.
Some default users are provided for the application test. The Admin
user can create, edit or delete new users.
We recommend deleting the default users before deploying the application to production.
Role | Username | Password | Description |
---|---|---|---|
Country Admin | country_admin | country1234 | User with administrative permissions |
Data Collection Team | country_dct | country1234 | Normal user |
This application provides API service to CountryPortalWeb application and consumes data from CalculationEngine application API.
The complete dependency diagram of TraCAD Country and PMU applications:
TraCAD - CountryPortalService is Affero GPL licensed.