Basic store front that allows users to add products to their shopping cart and remove products with updated checkout total. Discount codes can be applied to reduce the overall price.
The application is split into two components: React frontend & FastAPI Backend
There are 4 seperate deployments that can be accessed:
FastAPI-staging: https://a1-fastapi-staging.herokuapp.com/docs
FastAPI-production: https://a1-fastapi-production.herokuapp.com/docs
storefront-staging: https://a1-storefront-staging.herokuapp.com
storefront-production: https://a1-storefront-production.herokuapp.com
The fastapi routes can be tested on each environment with the openAPI playground independent to the backend code. This can be used to validate what we are passing back from the backend as well look at our model schemas for data without having to dive into the code and installing dependencies.
Testing the frontend is as simple as playing around with the deployed front end.
There are two types of discount codes declared in the backend to use:
GIVEMEMEAT - 50% off everything
FREEFRUITS - 100% off everything
- Clone the repo locally and cd into it
- Install NodeJS and npm to install yarn (machine dependent preferred to be done in wsl)
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash nvm install node npm install -g yarn
- Install python >=3.8 Create a python virtual environment in server directory
cd server python -m venv env source activate/env/bin/activate
- Install python dependencies
pip install -r requirements/requirements.txt -r requirements/dev-requirements.txt
- Run backend (will need two terminals one for running backend and other for frontend)
-
python entrypoint.py
-
- Open new terminal and cd into client directory to install frontend requirements
-
cd client yarn install
-
- Run frontend
-
yarn start
-
If the last part is followed by setting up environments only minimal additions must be added.
- cd from root into client_front_end_tests
- Follow part (3) from running application locally to create venv
Test Backend Unit Tests:
- cd into server from root
- activate the venv for this directory (assuming dependencies installed)
-
sh run-tests.sh
- will run Pytest on all test files in server/api/tests/
- reports coverage on all endpoint files and test case failure
Test Frontend Unit Tests:
- cd into client_front_end_tests from root
- activate the venv for this directory
-
pip install -r requirements/requirements.txt
- Ensure that the frontend and backend are running (follow from last section)
-
pytest .
- will run selenium headless client on frontend by clicking components and
- validating their reactiveness and change in components