Skip to content
Snippets Groups Projects
Commit e58f4f97 authored by Victor Löfgren's avatar Victor Löfgren
Browse files

Add libraries section to backend

parent ef15108e
Branches
No related tags found
1 merge request!164Resolve "Update documentation"
...@@ -6,6 +6,17 @@ It also needs to make sure that only authorized people can access these. ...@@ -6,6 +6,17 @@ It also needs to make sure that only authorized people can access these.
The other responsibility is to sync slides, timer and answers between clients in an active competition. The other responsibility is to sync slides, timer and answers between clients in an active competition.
Both of these will be described in more detail below. Both of these will be described in more detail below.
## Libraries
The server is built in [Flask](https://flask.palletsprojects.com/en/2.0.x/).
A few extensions to Flask are also used.
[flask-smorest](https://flask-smorest.readthedocs.io/en/latest/) is used to defined the API routes.
It is this libray that automatically documents the API on `localhost:5000` using Swagger.
[marshmallow](https://marshmallow.readthedocs.io/en/stable/) is used to convert database objects in JSON and to parse JSON back into Python objects.
[SQLAlchemy](https://www.sqlalchemy.org/) is used to interface with the SQL database that is used.
More specifically [Flask-SQLAlchemy](https://flask-sqlalchemy.palletsprojects.com/en/2.x/) is used to integrate it with Flask.
[Flask-Bcrypt](https://flask-bcrypt.readthedocs.io/en/latest/) is used to encrypt passwords.
## Receiving API calls ## Receiving API calls
An API call is a way for the client to communicate with the server. An API call is a way for the client to communicate with the server.
...@@ -65,14 +76,14 @@ In this way, for example, an entire competition with its teams, codes, slides an ...@@ -65,14 +76,14 @@ In this way, for example, an entire competition with its teams, codes, slides an
## Active competitions ## Active competitions
Slides, timers, and answers needs to be synced during an active presentation. Slides, timers, and answers needs to be synced during an active presentation.
This is done using SocketIO together with flask_socketio. This is done using SocketIO together with flask*socketio.
Sent events are also authorized via JWT, basically the same way as the for the API calls. Sent events are also authorized via JWT, basically the same way as the for the API calls.
But for socket events, the decorator that is used to authenticate them is `@authorize_user()`. But for socket events, the decorator that is used to authenticate them is `@authorize_user()`.
Whenever a client joins a competition they will connect via sockets. Whenever a client joins a competition they will connect via sockets.
A single competition cannot be active more than once at the same time. A single competition cannot be active more than once at the same time.
This means that you will need to make a copy of a competition if you want to run the same competition at several locations at the same time. This means that you will need to make a copy of a competition if you want to run the same competition at several locations at the same time.
All of the functionality related to an active competition and sockets can be found in the file `app/core/sockets.py`. All of the functionality related to an active competition and sockets can be found in the file `app/core/sockets.py`.
The terms *active competition* and *presentation* are equivalent. The terms \_active competition* and _presentation_ are equivalent.
### Starting and joing presentations ### Starting and joing presentations
...@@ -84,7 +95,7 @@ The server can see what is stored in the JWT and do different things depending o ...@@ -84,7 +95,7 @@ The server can see what is stored in the JWT and do different things depending o
### Syncing between clients ### Syncing between clients
[comment]: # (What does `sync` mean? It isn't explained) [comment]: # "What does `sync` mean? It isn't explained"
The operator will emit the `sync` event and provide either a slide or a timer to update it on the server. The operator will emit the `sync` event and provide either a slide or a timer to update it on the server.
The server will then send `sync` to all connected clients with the updated values, regardless of what was actually updated. The server will then send `sync` to all connected clients with the updated values, regardless of what was actually updated.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment