Giter VIP home page Giter VIP logo

united_backend's Introduction

UNITED BACKEND

Backend to control and manage robots.

Contain django-admin panel for creating/managing robots and users. Using robot view in django admin we can see robot live statistics (pagination implemented).

USER AUTHENTICATION:

Backend use JWT for http and ws authentication. For both 'authentication' header is required. Token can be obtained on endpoint:

/users/obtain_token/

ROBOT AUTHENTICATION:

Backend use custom token authentication for robot ws authentication. Time valid token is created based on robot login data, cached and send back to robot. Using this token robot can login to ws. Implementation for robot authentication is very basic, can be easily extended by additional security features. Token can be obtained on endpoint:

/robots/robot/obtain_token

Rules:

  • user can have multiple robots

  • robots can be shared between users

  • user can access only to robots that's are assigned to him

  • user need to logged to access robot/robots

  • user can fetch robot statistics using channel

  • user can change robot state by calling proper view

  • robot need to be logged to have channel access

  • robot used token based access to channel

  • robot log to backend using two channels

    • channel for data
    • channel for commands
  • robot using data channel send his own data frames and get confirmation (for each data frame)

  • robot using commands channel get user sended commands and change his state

UNITED TEST ROBOT

Test robot is in file robot.py Update SETTINGS token and serial (based on one created by admin panel)and run it.

It's very simple PoC, robot just:

  • obtain his channel token based on his settings
  • log in into two channels
  • send some random data
  • listen for commands and update his internal state CACHE

TODO

I got limited time so TODO list looks like that:

  • more tests for channel and edge cases
  • small refactor for RobotStatusChannel
  • creating staging/production compose files
  • adding app logger
  • add some app exceptions and switch to exception flow in some cases
  • switch to better solution for robot statistics logging in case of high data volume
  • add event model to app and log what user do with robot
  • clear requirements

SETUP

NOT TESTED ON MAC

Project setup:

$ cp example.envs .envs
$ docker-compose build
$ docker-compose up --detach
$ docker-compose exec backend python manage.py collectstatic

Create admin user:

$ docker-compose exec backend python manage.py createsuperuser

Login and create tests robots in django admin:

127.0.0.1:8000/admin/robots/robot/add/

Close:

$ docker-compose down

COMMANDS

Run:

$ docker-compose up

Stop:

$ docker-compose down

Stop destroy data:

$ docker-compose down --volume

black:

$ black -S --config black.conf app/

flake8:

$ flake8 --config flake8 app/

tests:

$ docker-compose run backend pytest --ds settings.development

united_backend's People

Contributors

t1waz avatar

Watchers

 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.