Store Manager is a web application for use in a single store. There are two users: Administrator and Attendant.
The Administrator is the Store Owner and can add Store Attendants to the application. The Store Owner can also add, modify and delete products. The Store Owner will also be able to view all Sale Records created by the different Store Attendants.
The Store Attendant will be able to sell products and create Sale Records. The Attendant will also be able to view all his/her sale individual sale records.
The Front-End design of the application can be viewed here: Store Manager UI
The API is hosted on heroku and can be found here: Store Manager API
To test the application locally, first configure the environment as follows:
-
Install PostgreSQL if not already installed and ensure it is up and running.
-
Ensure Python3 is installed
-
Create a folder on your computer, once in the newly created repository, clone the project by running the following command:
git clone https://github.com/johnwayodi/sm-api-v2.git
-
Install virtualenv which will aid in the creation of a vitual environment. Once virtual environment is installed, create a new virtual environment named venv
virtualenv venv
-
Activate the created virtual environment and install all the packages for use in the app,
The packages used by the flask app are contained in a
requirements.txt
file:source venv/bin/activate
pip install -r requirements.txt
-
Set up the environment variables,
export JWT_SECRET_KEY="your jwt secret key" export API_SECRET_KEY="your secret key" export DATABASE_NAME="name of database" export DATABASE_HOST="database host" export DATABASE_USER="database username" export DATABASE_PASS="database password" export FLASK_APP=run.py
-
After all is set, run the application, export the application and pass the following command:
flask run
The API exposes the following endpoints:
-
The
/auth
endpoint allow the registration of users and a login route to allow registered. users to log into the applicationThe users can also logout of the application, doing so will revoke their access token and to access the the protected endpoinnts they'll have to login again.
POST /auth/register Register new user, first user to register will automatically be the Admin POST /auth/login Users can login to the system DELETE /auth/logout Users can logout of the system -
The
/api/v2/users
endpoint allows the management of attendants by the admin, the admin can add, update or remove an attendant accountsPOST /users Create a new attendant, only accessible to admin PUT /users/{user_id} Update details of a user account, only accessible to the admin DELETE /users/{user_id} Remove a user account, only accessible to the admin -
The
/api/v2/categories
endpoint allows all the CRUD operations on the category items.POST /categories Add new category, only accessible to the admin GET /categories Retrieve all categories, only accesible by admin GET /categories/{category_id} Retrieve a single category, only accesible by admin PUT /categories/{category_id} Update a specific category, only accesible by admin DELETE /categories/{category_id} Remove a category, only accesible by admin -
The
api/v2/products
endpoint allows all CRUD operations on product itemsPOST /products Add new product, only accessible to the admin GET /products Retrieve all products GET /products/{product_id} Retrieve a specific product PUT /products/{product_id} Update a specific product, only accessible to admin DELETE /products/{product_id} Remove a product, only accesible by admin -
The
api/v2/sales
endpoint allows the following operations on sale itemsPOST /sales Add new sale, only accessible to the attendant GET /sales Retrieve all sales GET /sales/{sale_id} Retrieve a single sale, displays a list of sold products in the sale
The following software tools were used in the development of this application:
- Python: Programming language.
- Flask: The underlying web framework.
- Flask-RESTful: For the development of the API.
- Flasgger: For the generation of the API Docs.
- Pytest: For testing and debugging.
- PostgreSQL: Database.