Giter Site home page Giter Site logo

olssonmalin / bsv-chef Goto Github PK

View Code? Open in Web Editor NEW

This project forked from julianfrattini/bsv-chef

0.0 0.0 0.0 46 KB

A simple toy system for the course PA1417 Basic System Verification

License: GNU General Public License v3.0

Python 98.81% Dockerfile 1.19%

bsv-chef's Introduction

Tiny Chef

A simple toy system for the 2023 exam of the course PA1417 Basic System Verification at BTH. It currently consists of a backend implemented in Flask and is connected to a MongoDB database. A frontend is anticipated according to the requirements, but not yet implemented.

Structure

This repository is structured as follows:

  • backend: Directory containing the backend
    • src: Source code of the backend
    • test: Location for all test files
    • .env: Environment variables
    • Dockerfile: Definition of a docker image
    • main.py: Main starting point of the backend, to be started with python -m main
    • pytest.ini: Pytest configuration
    • requirements.txt: Libraries required by the backend, to be installed via pip install -r requirements.txt
  • documentation: Markdown-files containing the context and requirements specification.

Using the System

While not essential for the PA1417 exam, you can setup and run the system to familiarize yourself with its functionality.

Setup

To set up the system, you have two choices: you can either run the system locally or run the dockerized version.

Local Setup

Make sure that Python 3.10 and MongoDB are available on your system. Then, perform the following steps for preparation:

  1. Make sure that the data base path data\db exists in the root folder of this repository.
  2. Install the requirementens in the backend folder by running python -m pip install -r requirements.txt.

Finally, get the system running with the following commands (each executed in its own shell):

  1. To start the data base, run mongod --port 27017 --dbpath data\db from the root folder in a console with admin rights (make sure that the direction of the slashes matches your operating system).
  2. To start the the server, run python -m main from the backend folder.

Dockerized Setup

Make sure that Docker is available on your system. Then, perform the following steps:

  1. With Docker Desktop running, execute docker-compose up from the root folder in a console with admin rights.

Accessing the System

Once the system is running, you can interact with it for example using Postman. Verify that the system is running by executing GET http://localhost:5000/ which should return a heartbeat in the form of a version string { "version" : "v0.5.0" }.

The database stores pantry items, which you can view via GET http://localhost:5000/items/all. At the beginning, the database is empty and this REST call should return an empty array []. Populate the database by running POST http://localhost:5000/populate, which will take the dummy data and adds them to the database. Now, GET http://localhost:5000/items/all should list several items. You can create further items via POST http://localhost:5000/items/create, where the body must contain the name, quantity, and unit field.

Finally, you can explore the main functionality of the system by running GET http://localhost:5000/receipes (containing the diet and usage_mode fields in the body as specified in the method description), which generates a random receipe. For example, calling the aforementioned request with diet = normal and usage_mode = optimal should - if the populate function had been run - return a receipe for banana bread, while changing diet = vegan should return a receipe for whole grain bread.

You can retrace the database by connecting to it using MongoDB Compass. Connect on the url mongodb://localhost:27017/ (if you are using a local setup) or mongodb://root:root@localhost:27017/ (if you are using a dockerized setup). In the tinychef database, you will find the item collection, where all the items are stored.

bsv-chef's People

Contributors

julianfrattini avatar olssonmalin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.