Skip to content

arshdoda/fatmug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Fatmug

Table of Contents
  1. Getting Started
  2. Usage
  3. API Endpoints
  4. Data Creation

Getting Started

The app is publically availabe on github and is also deployed on aws (http://13.235.81.184/admin/). This doucment focuses on setting up the app on local machine.

Prerequisites

The app requires python 3.10 or later to run and it can work both on windows and linux.

  • windows
    https://www.python.org/downloads/windows/
  • linux
    sudo apt install python3

Installation

Follow the steps to setup the app on local machine.

  1. Open the terminal on linux or powershell on windows
  2. Clone the repo
    git clone https://github.com/arshdoda/fatmug
  3. Create a virtual env
    cd fatmug
    python3 -m venv .venv
  4. Activate the virtual env
  • windows
    .venv/Scripts/activate
  • linux
    source .venv/bin/activate
  1. Install Dependencies
    pip install -r requirements.txt
  2. Run the app
    cd backend
    python3 manage.py runserver

Usage

This app support Token based authentication and Session based authentication (in local env only). Use the following credentials to login/get token.

  • Online URL: 13.127.83.149
  • Local URL: 127.0.0.1:8000
  • Username: fatmug
  • Password: fatmug@123
Session Authentication
The session based authentication provides drf-templates which is very easy to use. To use session based authentication, go to http://13.235.81.184/admin/ and login with above credentials. You can now use the secured apis.
Token Authentication
For token based authentication, go to http://13.235.81.184/api/token/ and login with above credentials. You will get access token and refresh token.

Then, use curl to call the api's as shown below.

 curl -H "Authorization: JWT {access token}" http://13.235.81.184/api/vendors/

Api Endpoints

To use the endpoint locally, replace "13.127.83.149" with "127.0.0.1:8000"

Session Authentication

http://13.235.81.184/admin/

Token Authentication

http://13.235.81.184/api/token/ http://13.235.81.184/api/token/refresh/

  • Following apis require a user to be authenticated. You can use both Token and Session base authentication.
Vendors

http://13.235.81.184/api/vendors/ http://13.235.81.184/api/vendors/{id}/ http://13.235.81.184/api/vendors/{id}/performance/

PO

http://13.235.81.184/api/purchase_orders/ http://13.235.81.184/api/purchase_orders/{id}/ http://13.235.81.184/api/purchase_orders/{id}/performance/

Data Creation

The db.sqlite3 already contains 5 vendors and 100000 PO data. To start from scratch follow the steps

  1. Delete the db.sqlite3 file from backend.
  2. Create DB and run migrations
    python3 manage.py migrate
  3. Create superuser
    python3 manage.py createsuperuser

Now, you can use the above api's to create the data. If you want to generate data in one go then continue with the following steps

  1. Modify the dummy_data.py file as required.
  2. Run Django shell
    python3 manage.py shell
  3. Run Data Creation script
    exec(open('dummy_data.py').read())
  4. Required only if data is generated using script: To calculate the performance matrix for the vendors, authenticate the user with any of the authentication method and then go to the http://127.0.0.1:8000/api/purchase_orders/calculate_matrix

(back to top)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published