Installation - paolopertino/TeachME GitHub Wiki

On this page the installation steps for both the front-end and back-end are provided.

Firstly, clone the repository using the following command:

git clone https://github.com/itsPeetah/polimi-mdproject-2024-teachme.git

From now on, the PATH of the repository will be referenced in this document as <PATH_TO_TEACHME>.

Front-end

Here is the guide for installing the front end.

System prerequisites

Environment

To successfully run the front-end application you have to set the following environment variables in the .env.local file in the ui directory of the project, so in the <PATH_TO_TEACHME>/ui/.env.local (create it if not already present).

The content of the file must be the following:

NEXT_PUBLIC_SPEECH_KEY=<YOUR AZURE TTS API KEY>
NEXT_PUBLIC_SPEECH_REGION='westeurope'
NEXT_PUBLIC_BACKEND_URL_BASE=<URL FOR THE BACKEND>

You have to substitute <YOUR AZURE TTS API KEY> with a valid Azure API key that can be generated here. should be in the shape protocol://hostname:port, if non is provided it will be http://127.0.0.1:5000, which is the default dev url.

Dependencies installation

To install the front-end dependencies, use the following commands:

cd <PATH_TO_TEACHME>/ui # change directory to the front-end one
npm install

Back-end

Here is the guide for installing the backend.

System prerequisites

Before starting, we recommend the creation of a Python virtual environment to manage all the dependencies of the backend application. To create a new python virtual environment you can use the following commands:

cd <PATH_TO_TEACHME>/
python3 -m venv teachmeVENV

Finally, you can activate your virtual environment using the following commands:

cd <PATH_TO_TEACHME>/
source teachmeVENV/bin/activate

Database setup

To run the backend application, a MongoDB Atlas database instance must be created. MongoDB Atlas is a fully managed cloud database that handles all the complexity of deploying, managing, and healing your deployments on the cloud.

Follow these steps to set up your MongoDB database instance for TeachMe:

  1. Register an account on MongoDB Atlas.
  2. Log-in to your account. You should land on the dashboard page.
  3. Create a new project and insert the name you prefer.
  1. Once completed, click on the Database button on the left sidebar, and then on the Create cluster button.
  1. Compile the form that shows up with the following parameters:
  1. Submit the form. Now your cluster should be set up and it should show up in your Database page.
  2. Click on the connect button that you can find on the card related to the cluster you have just created.
  3. Create the database admin user by providing a username and a password, then click on Create Database User. You must remember the password to perform the following steps.
  1. In the form that shows up click on Drivers:
  1. Scroll down until section 3 to find the MongoDB URI to connect to your cluster:

NOTE: Replace with the password for the user you created in the previous steps. Finally, copy the URI. We will refer to this string with MONGODB_URI from now on.

  1. On the left sidebar, click on the Network access button. In the page that shows up click on Add IP Address and compile the form inserting the IP 0.0.0.0/0 (allow access to the DB from every IP address. This is done to make testing easier. Once the application is deployed on a server, only the IP address of the application server should be allowed to access the DB).
  1. Download MongoDB Compass to access your database instance. Once installed, open it.
  2. Click on New Connection + and insert the MONGODB_URI you just copied.
  1. Once connected, on the left sidebar, on the right of the Databases label, click on the + symbol to create a new DB. You must call it teachme_main, as shown in the picture.
  1. Finally, by accessing the db just created, add the following five collections using exactly the name provided in the picture.

You have now successfully set up your database instance for running TeachMe. Keep your MONGODB_URI copied so that it can be set as an environment variable as shown in the next section.

Do you want to know more on how the data is stored by the application? Visit the Database structure page for more insights.

Environment

To successfully run the back-end application you have to set the following environment variables in the .env file in the backend directory of the project, so in the <PATH_TO_TEACHME/backend/.env (create it if not already present).

OPENAI_API_KEY=<YOUR OPENAI API KEY>
MONGODB_URI=<YOUR MONGODB ATLAS URI>

You have to replace <YOUR OPENAI API KEY> with a valid OpenAI API key that can be generated here. Moreover, you have to replace <YOUR MONGODB ATLAS URI> with the token of your MongoDB Atlas database instance obtained following the steps described in the previous section.

Dependencies installation

To install all the required python libraries you can use the following commands:

NOTE: if you created a virtual environment remember to activate it before executing the commands!

cd <PATH_TO_TEACHME>/backend/
pip install -r requirements.txt

Using Docker

Here is a brief guide to start using TeachMe using Docker.

System prerequisites

Note that it is required to set up the .env.local and the .env files as described in the previous sections (.env.local, or .env).

Container build

In order to build the containers of both the frontend and backend, please run the following commands:

cd <PATH_TO_TEACHME>
docker-compose build --no-cache

You are now ready to run the application. Visit the Running page for more details.

⚠️ **GitHub.com Fallback** ⚠️