Since my final project is now graded, the time has come to ammend issues I faced during testing stage of deployed application. The most important is the low security on the mongoDB side allowing for some form of data extraction. My mongoDB database was constatnly exploited by unknown. Beware of this before pushing things into production.
- Install MongoDB
Fedora 35 MongoDB installation instruction can be found HERE, on my GitHub Pages.
-
Install Docker
-
Install docker-compose
- Create virtual environment (called "trade_env" or whatever you like)
python3 -m venv trade_env
or **
virtualenv tradegame_venv
- Activate the virtual environemnt
trade_env\Scripts\activate.bat
or **
source tradegame_venv/bin/activate
-
Navigate to the root directory (where the three directories backend, database and frontend are present)
-
Install Python packages to the virtual environment
pip install -r backend/requirements.txt
If pip doesnt work, use code below and run pip install again:
python -m pip install -U --force pip
- Install Node Package Manager (npm)
- Navigate into /frontend directory (where package.json is present)
- Install the React dependencies with npm
npm install
-
Navigate to the root directory (where the three directories backend, database and frontend are present) or start your existing MongoDB server
-
Make sure you have MongoDB installed on your machine and system variable path is set correctly.
Again: GitHub Pages regarding MongoDB installation on Fedora 35.
Remember to set up the MongoDB URL and db-name in the /TG-backend/toml.conf file
- Start MongoDB server with mongod
mongod --dbpath=database
OR
Run :
docker-compose up
This will spin your Docker container with the mongoDB running on it.
(if you modified the docker-compose.yml - also remember to make sure it agrees with the .toml file)
- The MongoDB server will be hosted at its default port
-
Navigate into /backend directory (where main.py is present)
-
Activate the virtual environemnt
trade_env\Scripts\activate.bat
or
trade_env/bin/activate
- Start FastAPI server
uvicorn main:app --reload
If it doesnt work, use:
python -m uvicorn main:app --reload
*** If above return an error:
ERROR: Error loading ASGI app. Could not import module "app".
It probably means your database is not running, or you are trying to execute uvicorn server while (with cmd) beeing in the incorrect directory. Your new MongoDB installation might also require super user privelages.
Try:
sudo mkdir /var/lib/mongodb
sudo mkdir /var/log/mongodb
sudo service mongod start
try also:
sudo service mongod restart
then:
sudo mongod --dbpath=database
-
The FastAPI server will be hosted at its default port 3000
-
To access SwaggerUI for API testing and documentation, goto http://localhost:3000/docs
- Navigate to /frontend directory (where package.json is present)
- Start React Web Application
npm start
- The React web application will be hosted at its default port 8000, goto http://localhost:8000/