Corgam / SS23_ADSP_TCF

An official repository for the "Tangible Climate Futures" project from the ADSP (SS23) course at TU Berlin.
1 stars 2 forks source link

Welcome to the SS23_ADSP_TCF Repository!

This is an official repository for the Tangible Climate Futures project for the (Advanced) Distributed Systems Prototyping SS23 course at TU Berlin. The description and the structure of our project, together with a detailed structure of implemented JSON objects, can be found in our wiki.

Project Developers:

Project Deployment

Our Project can be deployed in multiple ways, including full-Docker deployment, developer deployment, and on the Google Cloud Platform (using Terraform).

Setup:

  1. Install Git (Ubuntu: sudo apt update && sudo apt install git).
  2. Clone this repository (git clone https://github.com/Corgam/SS23_ADSP_TCF).
  3. Go the the root folder (Ubuntu: cd SS23_ADSP_TCF) and run the .sh script (Ubuntu: sh setup.sh, do not use sudo).
  4. Please restart your terminal for the changes to take effect. If you're running Linux in a virtual machine, it may be necessary to restart the virtual machine for changes to take effect.
  5. Inside frontend/src/environments/ folder, fill in the Firebase API keys for web applications in files: environment.ts and environment.development.ts (For a detailed guide follow: https://firebase.google.com/docs/projects/api-keys?hl=en). Remember to enable Email Authentication inside Firebase.
  6. Run the npm run setup command inside the root folder, this will install all necessary npm packages.

Note: We use .sh script for automatic setup. In case of errors, or manual installation, follow the steps descripted in the setup.sh file.

Docker Deployment

The full-Docker deployment is the recommended way for using the application, where all of the components are deployed as individual Docker containers. If you are a developer, you can use the Developer Deployment described in the section below. While we have tested this deployment on a clean Ubuntu 22.04 LTS (Jammy Jellyfish, 64-bit), it should work on all machines with Docker installed.

  1. Go to the root folder cd SS23_ADSP_TCF and run npm run deploy, which will deploy all necessary Docker containers (including FE, BE, and all microservices). Make sure that the Docker Service is running (docker ps).

Notes:

Developer Deployment (reduced-Docker)

The developer deployment (or reduced-Docker) is a deployment recommended for developing the project. All components, except MongoDB, are deployed locally (no Docker containers) allowing for easier development (live reloading). This deployment was tested on a clean Ubuntu 22.04 LTS (Jammy Jellyfish, 64-bit).

  1. Run npm run dev:all to run all components as the dev version (live reloading) as background processes. The MongoDB will be still deployed as a Docker container, thus make sure that the Docker Service is running (docker ps).

Notes:

Cloud Deployment (GCP using Terraform)

This cloud deployment will deploy our complete project on GCP using Terraform. It is intended to be used as a production-ready deployment, thus making the project publicly available.

  1. First install the Terraform.
  2. Download the GCP access keys (be aware to not commit them) from GCP and save them as a JSON file on your machine.
  3. Create an environment variable GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/key.json
  4. Inside frontend/src/environments/ folder, fill in the Firebase API keys in files: environment.ts and environment.development.ts
  5. Inside our project, go to the deploy directory using cd deploy
  6. Setup your terraform environment with terraform init
  7. Apply the infrastructure with terraform apply, you can access the app under the provided above URLs.
  8. For shutdown use terraform destroy.

Useful Scripts for MongoDB

Once the project is set up, and the MongoDB container is running, you can execute some helpful scripts:

Note: Make sure you have the MongoDB instance running.

Seed the Database with Random Data

To seed the database with random documents, use the following command python3 scripts/mongo/main.py seed

Options:

Cleanup the Database

To clean up the database, simply run the following command python3 scripts/mongo/main.py cleanup --mongo-url <string>

NPM Scripts Documentation

Here is a list and description of all npm scripts included in the main package.json file: