The Backend API portion of the Project Delivery App for Out In Tech U Mentorship Fall 2020.
Thanks to the global pandemic, restaurants and food services are struggling to keep their head above water without getting everyone else infected. Thanks to the significant social movement of #BlackLivesMatter, there's a huge focus to support racial justice and struggling BIPOC+-owned businesses.
The significant problem with trying to order food is dealing with the deluge of apps such as Uber Eats, GrubHub, DoorDash, etc. And that doesn't even start to include other proprietary apps or ordering through a phone call. And even then, it might not be clear if the app is ordered for pickup or delivery.
This map app utilizing MapBox help to aggregate and display all the restaurants that shows delivery and pickup along with their methods and outlets to order safely. This app also allow filtering the restaurants to "BIPOC+-Owned", "LGBTQ+-Owned", "LGBTQ+ Friendly", and "Wheelchair Accessibility" to ensure that everyone should order safely whether it's delivery or driving to pickup their takeout in a safe and contactless manner.
This is the backend portion of the app that integrate betweens the frontend app and the database, ready to be deployed in a serverless environment in an API gateway.
- Runtime + Language: Python (Working with 3.8 but can work with 3.6+)
- Framework: FastAPI
- Testing: pytest
- Coverage: Coverage.py
- CD/CI: Travis CI
- Hosting: [TBD]
To get a local copy up and running follow these simple steps.
Have a valid Python version that can work. This project is being working with version 3.8.6 but CI testing verifys that it works from 3.6+ onward. You can either install the latest version or this specific version at Python's official download page.
However, I recommend using pyenv
to install your desired version from there.
$ pyenv install -v 3.8.6
#...
Installed Python-3.8.6 to $HOME/.pyenv/versions/3.8.6
$ pyenv global 3.8.6
$ python -V
Python 3.8.6
Aloing with that, I use a plugin called pyenv-virtualenv
to manage virtual environments in conjunction with pyenv.
-
Clone this repo.
$ git clone https://github.com/EndyPremier/project-deliver-api.git $ cd project-deliver-api
-
Setup a virtual environment. You can use your virtual environment manager of choice such as
virtualenv
orpipenv
. This is how you create a virtual environment for pyenv using pyenv-virtualenv.$ pyenv virtualenv 3.8.6 deliver-api
To make it more convenient, create a file at the project root called
.python-version
so when you reach the directory, it activates the virtual environment that is pointing in~/.pyenv/versions/
directory.# at project root $ echo 3.8.6/env/deliver-api > '.python-version'
-
Install pip packages and dev packages
# at project root $ pip install -r requirements.txt $ pip install -r requirements_dev.txt
Just type this command and it will be run on http://127.0.0.1:8000
to be able to fiddle around.
# at project root
$ uvicorn deliver.main:app --reload
[TODO: Add more detail on setting up AWS, install serverless framework]
... but if you figure that out, The thing you needed is install some node package requirements for serverless.
# at project root
$ npm i
Finally, deploy it with this command deploy.
# at project root
$ sls deploy
It's also important to deactivate it once you're done.
# at project root
$ sls remove
.
├── deliver
│ ├── models
│ │ ├── __init__.py
│ │ ├── enums.py
│ │ ├── hours.py
│ │ ├── location.py
│ │ ├── services.py
│ │ └── utils.py
│ ├── __init__.py
│ └── main.py
├── tests
│ ├── models
│ │ ├── __init__.py
│ │ ├── test_location.py
│ │ ├── test_restaurant.py
│ │ ├── test_services.py
│ │ └── test_utils.py
│ ├── __init__.py
│ └── test_main.py
├── .gitignore
├── .pylintrc
├── .travis.yml
├── LICENSE
├── README.md
├── requirements.txt
├── requirements_dev.txt
├── package.json
├── package-lock.json
└── serverless.yml
# at project root
$ python -m pytest
# running test... and then show result
# at project root
$ python -m coverage run --source=deliver -m pytest
# running test... and then show result
$ python -m coverage report -m
# get coverage report from ".coverage" file from test
[TBA]
Distributed under the GNU GPL v3 License. See LICENSE
for more information.
Mentee: Endy Iskandar Imam - LinkedIn - @EndyPremier - [email protected]
Mentor: Rory Chinchilla - LinkedIn
Project Link: https://github.com/EndyPremier/project-deliver-api