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>
.
Here is the guide for installing the front end.
- Node.js 18.17 or later
- npm package manager
- Next.js, the React framework for Web
- Browser Compatibility
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.
To install the front-end dependencies, use the following commands:
cd <PATH_TO_TEACHME>/ui # change directory to the front-end one
npm install
Here is the guide for installing the backend.
- Python 3
- pip packet manager
- MongoDB Compass
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
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:
- Register an account on MongoDB Atlas.
- Log-in to your account. You should land on the dashboard page.
- Create a new project and insert the name you prefer.
- Once completed, click on the
Database
button on the left sidebar, and then on theCreate cluster
button.
- Compile the form that shows up with the following parameters:
- Submit the form. Now your cluster should be set up and it should show up in your Database page.
- Click on the connect button that you can find on the card related to the cluster you have just created.
- 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.
- In the form that shows up click on
Drivers
:
- 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.
- 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 IP0.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).
- Download MongoDB Compass to access your database instance. Once installed, open it.
- Click on
New Connection +
and insert theMONGODB_URI
you just copied.
- 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 itteachme_main
, as shown in the picture.
- 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.
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.
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
Here is a brief guide to start using TeachMe using Docker.
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).
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.