Skip to content

Commit

Permalink
Merge pull request #119 from erikzimmermann/development
Browse files Browse the repository at this point in the history
First release
  • Loading branch information
erikzimmermann authored Dec 9, 2022
2 parents 9d1a0a3 + dc25d9c commit 498a825
Show file tree
Hide file tree
Showing 234 changed files with 30,665 additions and 121,072 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mensa_recommend/notebooks
frontend/node_modules
162 changes: 161 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,161 @@
*.env
*.env
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
Binary file added ERM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 94 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# data-integration-recommender
Recommender System in Python using Django
# Mensa Today Recommender System

Münster is a distributed University with various different canteens and bistros that serve different ranges of food which change every week. As a student who eats at those places frequently, you have to look through all of these dishes to find a meal you want to eat. The idea of our recommender system is to suggest meals based on various different factors: Your eating habits, location (based on semester schedule), weather,…).

## Setup Postgres Database
In order to be able to connect to the databse inside of the docker container the environment variables have to be set correctly. Therefore create a `database-variables.env` file in the `mensa_recommend` directory. Copy the following environment variables into the .env file and change the variables respectively:

````
In order to be able to connect to the database inside of the docker container the environment variables have to be set correctly. Therefore create a `database-variables.env` file in the `mensa_recommend` directory. Copy the following environment variables into the .env file and change the variables respectively:

```
POSTGRES_DB = YOUR_DB_NAME
POSTGRES_USER = YOUR_DB_USER
POSTGRES_PASSWORD = YOUR_DB_PASSWORD
Expand All @@ -13,4 +15,91 @@ POSTGRES_PORT = 5433
PGADMIN_DEFAULT_EMAIL = YOUR_PGADMIN_EMAIL
PGADMIN_DEFAULT_PASSWORD = YOUR_PGADMIN_PASSWORD
````
```

After creating the file start docker:

1. `docker-compose up`
2. In a seccond terminal connect to app container `docker exec -it mensa_recommend-app-1 bash`
3. `python manage.py makemigrations`
4. `python manage.py migrate`
5. `python manage.py createsuperuser`

Done now you can connect to your database.

## Environment files

To run the local as well as production environment specific environment files has to be created. For the local development create a `local-variables.env` file in the root directory that should contain the following:

```
VUE_APP_BASE_URL = YOUR_URL
GOOGLE_API_KEY = YOUR_API_KEY # currently not required
GOOGLE_PROJECT_CX = YOUR_PROJECT_CX_KEY # currently not required
```

For development the `VUE_APP_BASE_URL = http://localhost:9999/api/v1/` and for production `VUE_APP_BASE_URL = http://10.14.28.50:9999`
For the Production see next section.

## Production

To deploy the django app use the `docker-compose-prod.yaml` file. This file requires a `prod-variables.env` file which have to be create:

```
SECRET_KEY = foo
DEBUG = False
JWT_EXPIRATION_DETLA = 10800
PRODUCTION = True
GOOGLE_API_KEY = YOUR_API_KEY # currently not required
GOOGLE_PROJECT_CX = YOUR_PROJECT_CX_KEY # currently not required
PRIVATE_KEY = YOUR_PRIVATE_KEY
HTTP_PROXY=http://wwwproxy.uni-muenster.de:3128
HTTPS_PROXY=http://wwwproxy.uni-muenster.de:3128
```

## Notebooks

Jupyter notebooks for testing purposes can be created at the notbooks folder. Please follow the naming convetion: `initials-dd-mm-yyy-name_of_the_notebook`

## Celery

Celery is an open source asynchronous task queue or job queue which is based on distributed message passing. While it supports scheduling, its focus is on operations in real time. Celery is used in combination with the message broker redis. Usage example:

## Data Structure

![erm](ERM.png)

## Contribution

### Code Documentation Template

Every class/method documentation should consist of the following elements:

- A short description of the method
- A description of the input parameters:
- Parametername : Type - [optional]
- Short description [(default: Value)]
- A description of the output parameters:
- Parametername : Type
- Short description

```Python
def create_vgg16(input_shape = (1024, 1024, 3)):
"""Create a vgg16 pretrained network
Parameters
----------
input_shape : tuple
Shape of the images (default : (1024, 1024, 3))
Return
------
model : keras model
The resulting keras model
"""

....
your_custom_code
....

return model
```
79 changes: 79 additions & 0 deletions docker-compose.local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
version: '3.8'
services:
app:
image: mensa_app
build:
context: mensa_recommend
dockerfile: Dockerfile.local
volumes:
- ./mensa_recommend/:/app
ports:
- 9999:9999
command: python manage.py runserver 0.0.0.0:9999
env_file:
- database-variables.env
- local-variables.env
environment:
- CELERY_BROKER=redis://redis:6379/0
- CELERY_BACKEND=redis://redis:6379/0
depends_on:
- db
- redis
db:
image: postgres:15
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file:
- database-variables.env
expose:
- '5433'
ports:
- '5433:5432'
command: -p 5433
pgadmin:
image: dpage/pgadmin4
container_name: pgadmin
depends_on:
- db
env_file:
- database-variables.env
ports:
- '8888:80'
volumes:
- pgadmin_data:/var/lib/pgadmin
restart: always
celery:
build:
context: mensa_recommend
dockerfile: Dockerfile.local
command: celery -A mensa_recommend worker -l INFO
volumes:
- ./mensa_recommend/:/usr/src/app
env_file:
- database-variables.env
- local-variables.env
environment:
- CELERY_BROKER=redis://redis:6379/0
- CELERY_BACKEND=redis://redis:6379/0
depends_on:
- app
- redis
redis:
image: 'redis:alpine'
frontend:
build:
context: frontend
dockerfile: Dockerfile.local
ports:
- '8080:8080'
command: npm run serve
container_name: vue-ui
env_file:
- local-variables.env
volumes:
- ./frontend:/usr/src/app
- /usr/src/app/node_modules/

volumes:
postgres_data:
pgadmin_data:
Loading

0 comments on commit 498a825

Please sign in to comment.