Git Product home page Git Product logo

innovativeproject-inventory-of-supplies's Introduction

Table of Contents

How to run

Prerequisites

Install docker and docker-compose. Install yarn and expo.

Run

Build docker images.

$ docker-compose build

Run docker-compose.

$ docker-compose up

Or run docker-compose in background.

$ docker-compose up -d

Exit

Command below will kill all docker containers assigned to this docker-compose.

$ docker-compose stop

Interaction

Below instructions assume that you've built and ran docker-compose using commands above.

API

Authentication uses JSON Web Tokens. To authenticate your request, you will need to obtain access token.

This can be done by either registration:

curl -X POST -d "username=testuser&password1=testpassword&password2=testpassword&[email protected]&first_name=John&last_name=Doe" http://localhost/rest-auth/name-registration/

# Returns:
# {"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo0LCJ1c2VybmFtZSI6InRlc3R1c2VyMjExIiwiZXhwIjoxNTUzMjAyMDk1LCJlbWFpbCI6InRlc3QzMkBlbWFpbC5jb20iLCJvcmlnX2lhdCI6MTU1MzE5ODQ5NX0.PI_csWibxJ13UfmF1ePRXmc_0tlCULJgbPSfo8f763o","user":{"pk":1,"username":"testuser","email":"[email protected]","first_name":"John","last_name":"Doe"}}
# token is just a example, yours will look different but will be in the same format

or login:

curl -X POST -d "username=testuser&password=testpassword" http://localhost/rest-auth/login/

# Returns:
# {"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VybmFtZSI6InRlc3R1c2VyIiwiZXhwIjoxNTUzMjAyMTgyLCJlbWFpbCI6InRlc3RAZW1haWwuY29tIiwib3JpZ19pYXQiOjE1NTMxOTg1ODJ9.zSd3NyP3rDcmP_CCZCwL8oqjctWMdVAO5w6OKTDUAJ0","user":{"pk":1,"username":"testuser","email":"[email protected]","first_name":"","last_name":""}}

Finally use the access token you authenticate your request:

curl -X GET http://localhost/api/users/1/ -H "Authorization: JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VybmFtZSI6InRlc3R1c2VyIiwiZXhwIjoxNTUzMjAyMTgyLCJlbWFpbCI6InRlc3RAZW1haWwuY29tIiwib3JpZ19pYXQiOjE1NTMxOTg1ODJ9.zSd3NyP3rDcmP_CCZCwL8oqjctWMdVAO5w6OKTDUAJ0"

# Returns:
# {"username":"testuser","email":"[email protected]","first_name":"","last_name":""}

Browsable API documentation

Head to http://localhost/docs/. You will be able to view API endpoints and try them out. Keep in mind that permissions are applied and mocking a request to some of them will require authentication.

To authenticate, use the default admin account (username: admin, password: admin) that is created automatically for development.

First, go to obtain-token endpoint and press "Interact":

Obtain token view

Then, input the default admin's account credentials into form fields and press "Send request". A token in JSON format should be generated. Copy it's value.

Obtain token login

On the bottom-left of the page, press the "Authentication" tab to draw out the possible options and choose "token":

Docs authentication

Lastly, fill out the Token Authentication form:

Scheme: JWT
Token: <put your token here>

Docs token

Your browsable API docs session should be authenticated now. With admin privileges you should be able to test out all the endpoints with built-in mock feature.

Backend

To run Django manage.py command, use instruction:

$ docker-compose exec backend python manage.py <command>

Create admin account (keep in mind that admin:admin account is created automatically):

$ docker-compose exec backend python manage.py createsuperuser

Due to docker-compose configuration, the Django server is reloaded automatically every time a change to the code is made.

To interact with API through web browser, navigate to http://localhost/api or http://0.0.0.0/api

To execute tests run:

$ docker-compose exec backend python manage.py test

Frontend

To open application frontend navigate to http://localhost/ or http://0.0.0.0/

To install new packages use:

$ docker-compose exec frontend npm i package-name --save

Database

To interact with database run:

$ docker-compose exec db psql -h localhost -p 5432 -U postgres postgres
Password for user postgres: postgres
$ \dt # show tables

Mobile

For development:

cd mobile - change directory

yarn - install dependencies

yarn start or sudo yarn start - run app

For production:

expo build:android or sudo expo build:android

License

MIT

innovativeproject-inventory-of-supplies's People

Contributors

r-kaminski avatar marekpokropinski avatar adobrzanski avatar kbialecki avatar hubertwnukiewicz avatar shackyshell avatar ekaczmar avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.