- Deployment in Production Environment
- Local Deployment via Docker
- Setup Guide for Direct Deployment
- API Documentations
- Database
- Unit tests
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.
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:
- While in the root directory of the repository, build the Docker environment with:
docker compose up -d - 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.
- Navigate to
http://localhostin your browser and you should see the UI of the application.
- Create a Python venv in the root directory of the repository with the command:
python -m venv venv - Activate the created virtual environment.
- On macOS & Linux with:
source venv/bin/activate- On Windows with:
source venv\Scripts\activate
Once the virtual environment is activated, install the required Python libraries with:
pip install -r server/requirements.txtStart the Flask backend with:
python server/app.pyNote
By default, Flask runs at: http://127.0.0.1:5000/
Open a new terminal or command prompt and move into the React (client) folder:
cd clientBefore running React, install the necessary Node.js packages:
npm installTo launch the frontend, run:
npm startNote
This will start a development server at: http://localhost:3000/ (the browser should open automatically).
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.
This app uses SQLAlchemy in combination with pysqlite3 as a database so it should generally be compatible with any sqlite 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.csvYou 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.csvThe 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:
-
Navigate to the
serverfolder with:cd GET-Food/server -
Run the API unit tests with:
pytest test_api.py -
Run the database unit tests with
pytest test_db.py