Coder Social home page Coder Social logo

blockcovid-server's Introduction

Build status codecov code style: spotless

BlockCOVID-server

Description

Server module for the project BlockCOVID. This module provides all the API required for the android and web modules, together with all the interactions with an ethereum network (for testing we recommend ganache)

Usage

Prerequisites

MongoDB

This application uses a mongodb instance as database. You can start and stop a mongodb daemon trough the provided scripts spawnMongo.sh and killMongo.sh. The folder ./db will be used as mongo database folder.

Https

To run the server make sure you have a PKCS12 keystore with your public key, this is important in order to ensure https requests are handled properly. Without a valid keystore the server will fail to start. You can either create a self-signed pkcs12 keystore or issue one with a CA (such as letsencrypt)

Blockchain

In order to save the hashes of generated reports on a blockchain network you need to:

  • Select a network to deploy your contract: you can simply use the provided containered solution and test the server behavior trough ganache. Otherwise, you should have an endpoint to communicate to the selected ethereum network, such as Infura;

  • Open an account on that particular network.

once you have such information compile the file .env. An example could be the following (also included in the project)

# The private key of your account on the network
export BLOCKCHAIN_ACCOUNT=0xb43436657ed0d6b922f3e7fab75dc32c610796d374daa6d7f1878669ff79d0e5
# The network to interface with
export BLOCKCHAIN_NETWORK=http://ganache:8545
# If you have already deployed the same contract for any reason you can specify 
# its address here, otherwise a new contract will be deployed 
export BLOCKCHAIN_CONTRACT=

# the uri of the mongodb instance keeping all your data
export MONGODB_URI=mongodb://mongo:27017/blockcovid-test
# SSL certificate information
export KEYSTORE_TYPE=
export KEYSTORE=
export KEYSTORE_PASSWORD=
export KEYSTORE_ALIAS=
export SSL_ENABLED=false
# server port, this will only affect the container exposed port,
# not the internal port
export SERVER_PORT=8091
# existing directory where reports will be saved
export REPORT_DIR=
# This should be commented when deploying on a real network,
# specifies the active profile of the application, the ganache profile is made
# specifically to interact with ganache  
export spring_profiles_active=ganache

Building

./gradlew build

will build the single artifact based on the provided application.properties and will store it at build/libs. This artifact can then be run on the JVM.

Running

Once all the prerequisites are satisfied, and the artifact is built the application can be launched in several ways:

Test container start

This way you can test the application with a container version of mongodb and ganache cli

sudo docker-compose up --build

The containers will then be created and started. Eventually when the run ends you can dismantle the built containers with

sudo docker-compose down

Standalone Application

In this case an instance of mongodb and valid network credentials must be supplied trough environment variables, for simplicity you can just source the .env file:

source .env && ./gradlew bootRun

will start the application, in this case you handle both the mongodb instance and the interaction with the blockchain network

Contributing

We adopt a Gitflow workflow. So in order to contribute to the application the steps are:

  • start from develop branch
  • git flow feature start [faeture name] (alternatively git checkout -b feature/[feature name])
  • Implement the new feature and the corresponding tests
  • commit your changes
  • git flow feature pulish [feature name] (alternatively git push -u origin feature/[feature name])
  • open a pull request describing your changes and addressing issues if necessary eventually an administrator will review your work and merge it in the develop branch.

pre-commit hook

Builds will fail if the code is not compiant with the spotless formatting. Therefore add this hook to git that prevents you from committing anything that is not correctly formatted

cp pre-commit.sh .git/hooks/pre-commit

text can be formatted with

./graldew spotlessApply

blockcovid-server's People

Contributors

lusergit avatar nr3d avatar mitch97 avatar theasel avatar lmodica avatar

Watchers

James Cloos avatar

Forkers

nr3d

blockcovid-server's Issues

Limit reservation intervals

Right now users can book reservations that start and end at opening times, but those reservations can still spawn across closing times.
Checks should be performed to prevent such possibility.

View desk state

Given a datetime instant the system shall return informations about the desk state and availability

Room and desk entities

Each room has a given number of desks and some properties (such as availablity and size).

Each desk needs a representation of its position relative to its associated room.

Mark room as cleaned

Cleaners can mark a room as cleaned.

Informations about the time of such sanifications shall persiste in the system.

UC15

Use Swagger UI annotations

https://github.com/swagger-api/swagger-core/wiki/Annotations

REST API documentation should provide the following informations:

  • Description
  • URL
  • Call method (GET, POST, PUT, etc.)
  • Accepted media type
  • Request paramethers
    • name
    • type or syntax
    • position (Body, Header, Path, etc.)
  • Return values
    • description
    • status code
    • media type
    • possible type or structure of the return value

Use Swagger UI annotations to add those attributes where not implicitly generated

Add desk identification

Add a generated Id on each desk such that they can be identified independetly of their location

Fix authentication

Currently if the user provides the wrong password when trying to moditfy it userService throws an error that is not catched, throwing an internal server error. Instead the user should be informed that the provided credentials are wrong

Room view

Let every user view informations about:

  • a single room
  • a list of available rooms

Track desk usage

Keep track of real start and end usage of a desk

Also keep track of desk sanification

Modify Desk

Let Admins modify an already existing Desk

Create Desk

Let Admins create new desks, given an associated room.

Delete account

Give admins the possibility to delete any common user's account

Change password

  • Give users the possibility to change their password
  • Let admins change any user's password

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.