minerva-university / diet-management

Diet management final project
1 stars 0 forks source link

Welcome to CS162 Final Project

This is a Diet Managment web application that produce diet recommendations and weight tracking. Here is a demo of the app: https://www.loom.com/share/e2496cdb1e734657a7ca7c3e65dd9542

Project's branches

The project has two branches:

We recommend using the docker deployment to not have interference between environments.

Main Branch

Run the application

Run Virtual Environment

Virtual environment is a key component in ensuring that the application is configured in the right environment

Requirements
brew install python3

Pip3 is installed with Python3

Installation

To install virtualenv via pip run:

pip3 install virtualenv
Usage

Creation of virtualenv:

virtualenv -p python3 venv

If the above code does not work, you could also do

python3 -m venv venv

To activate the virtualenv:

source venv/bin/activate

Or, if you are using Windows - reference source:

venv\Scripts\activate

To deactivate the virtualenv (after you finished working):

deactivate

Install dependencies in virtual environment:

pip3 install -r requirements.txt

Run Application

Start the server by running:

python3 run.py

if you are on windows:

for only one time of initializing the db

python3 insert_meals.py

Then:

python3 server.py

Deployment branch

This branch uses Docker containers to deploy the application. You have firstly to checkout to the branch using git.

git checkout deployment

running the application

To run the application you should have docker installed and then run the following commands:

docker build -t diet .
docker swarm init
docker stack deploy -c docker-compose.yml diet-swarm

For turning the application off:

docker stack rm diet-swarm
docker swarm leave --force

To run the integration tests:

docker-compose -f docker-compose-test.yml up --build --abort-on-container-exit test
docker-compose -f docker-compose-test.yml down
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

General for both branches

Environment Variables

All environment variables are stored within the .env file and loaded with dotenv package.

Never commit your local settings to the Github repository!

Unit Tests

To run the unit tests use the following commands:

python3 -m venv venv_unit
source venv_unit/bin/activate
pip install -r requirements.txt
pytest unit_test

For windows:

python3 -m venv venv_unit
venv_unit/scripts/activate
pip install -r requirements.txt
pytest unit_test