Skip to content

Zippo00/GET-Food

 
 

Repository files navigation

Table of Contents





Deployment in Production Environment

The API and Client can be deployed in a production environment.

Branch prod includes detailed instructions on how this can be done.

The instructions described from here on are meant for local deployment only, and differ from the instructions found in prod branch.


Local Deployment via Docker

The application can be deployed with the latest version of Docker. Docker automatically sets up the server and client, as well as populates the database with the data found in example_data/example_data.csv.

To deploy the application locally:

  1. While in the root directory of the repository, build the Docker environment with:
    docker compose up -d
  2. After Docker is finished building the environment, two containers should be up and running named GET-Food-Server and GET-Food-Client.

Note

GET-Food-Client container includes NGINX as a proxy server to serve the client on the default HTTP port 80.

  1. Navigate to http://localhost in your browser and you should see the UI of the application.

🚀 Setup Guide for Direct Deployment

Running the Flask Backend (Server)

1️⃣ Create and activate a Python Virtual Environment

  1. Create a Python venv in the root directory of the repository with the command:
    python -m venv venv
  2. Activate the created virtual environment.
    • On macOS & Linux with:
    source venv/bin/activate
    • On Windows with:
    source venv\Scripts\activate

2️⃣ Install Python Dependencies

Once the virtual environment is activated, install the required Python libraries with:

pip install -r server/requirements.txt

3️⃣ Run the Flask Server

Start the Flask backend with:

python server/app.py

Note

By default, Flask runs at: http://127.0.0.1:5000/

⚛️ Running the React Frontend (Client)

1️⃣ Navigate to the Frontend Folder

Open a new terminal or command prompt and move into the React (client) folder:

cd client

2️⃣ Install Dependencies

Before running React, install the necessary Node.js packages:

npm install

3️⃣ Start the React Development Server

To launch the frontend, run:

npm start

Note

This will start a development server at: http://localhost:3000/ (the browser should open automatically).

API Documentations

The API documentations are done with Swagger. After you have the Flask application running, you can find the documentations via a browser at URL/apidocs.

For example, if you have the application running on localhost, you would find the API documentations at http://localhost/apidocs.

Database

This app uses SQLAlchemy in combination with pysqlite3 as a database so it should generally be compatible with any sqlite database.

Populating the Database

You can initially populate the Database with the provided script. The data for the population should be in an csv-file, with each row beeing an individual food item, its properties being seperated by a comma and a semicolon indicating the corresponding pictures. You seperate the food items using a line break to indicate the next food item.

An example-file, example_data.csv with some images can be found in the example_data folder. Note that the path to the image is expected to be a relative path. You can populate the database with the example data by running the following (when in the project folder):

python ./server/populate_db.py ./example_data/example_data.csv

You can then accordingly run the script for populating the database using the following command (when in the project folder):

python ./server/populate_db.py path/to/data.csv

Unit tests

The repository contains unit tests for testing the functionalitites of the API endpoint.

After the backend (server) has been successfully set up, you can run the unit tests for the API and Database:

  1. Navigate to the server folder with:

    cd GET-Food/server
  2. Run the API unit tests with:

    pytest test_api.py
  3. Run the database unit tests with

    pytest test_db.py

About

Web application for restaurants. Allows customers to make food orders via the application.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 50.0%
  • JavaScript 46.8%
  • HTML 1.6%
  • Dockerfile 1.1%
  • CSS 0.5%