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:
- Simon Albani (Frontend, User Authentication)
- Emil Balitzki (Backend: Public-API, MongoDB, Filtering)
- Theodor Barkow (Frontend, Team Leader)
- Alexander Guttenberger (Backend: Public-API, Python)
- Florian Jäger (Frontend)
- Frederik Stalschus (Development Features & Deployment, Backend: Python)
Our Project can be deployed in multiple ways, including full-Docker deployment, developer deployment, and on the Google Cloud Platform (using Terraform).
Setup:
- Install Git (Ubuntu:
sudo apt update && sudo apt install git
). - Clone this repository (
git clone https://github.com/Corgam/SS23_ADSP_TCF
). - Go the the root folder (Ubuntu:
cd SS23_ADSP_TCF
) and run the .sh script (Ubuntu:sh setup.sh
, do not use sudo). - 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.
- Inside
frontend/src/environments/
folder, fill in the Firebase API keys for web applications in files:environment.ts
andenvironment.development.ts
(For a detailed guide follow: https://firebase.google.com/docs/projects/api-keys?hl=en). Remember to enable Email Authentication inside Firebase. - 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.
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.
- Go to the root folder
cd SS23_ADSP_TCF
and runnpm 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:
- BE is located at
localhost:40000
with Swagger Docs atlocalhost:40000/docs
- FE is located at
localhost:8080
- MongoDB is located at
localhost:27017
inside a Docker Container - Python Microservice is located at
localhost:50000
with Swagger Docs atlocalhost:50000/docs
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)
.
- 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:
- BE is located at
localhost:40000
with Swagger Docs atlocalhost:40000/docs
- FE is located at
localhost:8080
- MongoDB is located at
localhost:27017
inside a Docker Container - Python Microservice is located at
localhost:50000
with Swagger Docs atlocalhost:50000/docs
- The processes for all components will be run in a single terminal, thus for easier development of individual components, use specific npm scripts, described at the bottom of the README. These scripts will allow for the deployment of individual services in separate terminals.
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.
- First install the Terraform.
- Download the GCP access keys (be aware to not commit them) from GCP and save them as a JSON file on your machine.
- Create an environment variable
GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/key.json
- Inside
frontend/src/environments/
folder, fill in the Firebase API keys in files:environment.ts
andenvironment.development.ts
- Inside our project, go to the
deploy
directory usingcd deploy
- Setup your terraform environment with
terraform init
- Apply the infrastructure with
terraform apply
, you can access the app under the provided above URLs. - For shutdown use
terraform destroy
.
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.
To seed the database with random documents, use the following command python3 scripts/mongo/main.py seed
Options:
--num-documents <int>
- the number of documents to seed (default 10).--mongo-url <string>
- the URL to the database (defaultmongodb://localhost:27017/datastore
)- Example:
python3 scripts/mongo/main.py seed --num-documents 20 --mongo-url mongodb://localhost:27017/mydatabase
To clean up the database, simply run the following command python3 scripts/mongo/main.py cleanup --mongo-url <string>
- Example:
python3 scripts/mongo/main.py cleanup --mongo-url mongodb://localhost:27017/datastore
Here is a list and description of all npm scripts included in the main package.json
file:
npm run setup
- Installes all necessary npm packages, for both the FE and BE.npm run setup:frontend
- Installes all necessary npm packages for just the FE.npm run setup:backend
- Installes all necessary npm packages for just the BE.npm run setup:python
- Installes all required Python libraries for the Python Microservice.npm run deploy
- Deploys the whole app in Docker containers, including FE, BE, MongoDB, and Python Microservice.npm run deploy:mongo
- Deploys just the MongoDB Docker container.npm run dev:backend
- Deploys the MongoDB and Python Docker containers and the dev version (live reloading) of the BE.npm run dev:frontend
- Deploys the dev version (live reloading) of the FE.npm run dev:ds
- Deploys just the Python Microservice as the dev version (live reloading).npm run dev:pub
- Deploys just the BE as the dev version (live reloading).npm run dev:all
- Deploys the whole app as the dev version (live reloading) as background processes.