Skip to content

karstenpedersen/dm585-project

Repository files navigation

DM585 x Innovation Project

Final project for DM585.

Prerequisites

To use the system you need the following:

  • Docker and Docker Compose.

Note: The Dockerfiles are setup to use Jolie 1.12.2, so we have not tested other version.

Get Started

You can start and stop the system using the following commands in your terminal:

# Start services
docker compose up

# Seed system with users and rewards
npm run seed

# Stop services
docker compose stop

You can also run them manually using Jolie. You can use our devcontainer to get Jolie.

Web

The RouletteWeb will be running on http://localhost:8015/index.html, and can be opened in your browser of choice.

If you have run npm run seed then you can sign in as alice@domain.dk or bob@domain.dk on the roulette game.

Note: Right now the system does not unlock the user every day, and for testing we have placed a button "RESET ROULETTE" on the result screen after spinning the wheel, so you can try it again.

Double note: Sometimes the correct reward isn't displayed as the EventRelay hasn't put it into RewardHistory yet after spinning. This is due to timings, and because in development mode we can play multiple times a day, as the same user.

Tools

The Jolie services found in tools can be used to run tests and seed the system (inserting users and rewards).

Seeding

When the system is running you can run the npm run seed file to run the Seed service.

  • This will insert users alice@domain.dk and bob@domain.dk which can be used to sign in with on the website.
  • It will also insert some rewards.

You can see what this service will insert in seed.json.

Spin Roulette Wheel

You can spin the roulette wheel from the terminal using npm run test:roulette or do it from http://localhost:8015/catalogue/roulette/index.html

Get Reward History

You can see the reward history from the terminal using npm run test:history or see it from http://localhost:8015/catalogue/roulette/index.html?page=history.

Reset System

You reset the system (delete the database files) using npm run reset.

You can preview what it will do with npm run reset:preview.

Screenshots

frontpage

roulette wheel page

Overview

Here is a overview over our different Jolie services.

Component Diagram

component diagram

Services

Folder Structure

. # Root Jolie monorepo.
├── common # common interfaces and types, like Email.
│   ├── interfaces.ol
│   └── types.ol
├── compose.yaml # Docker Compose.
├── params.global.jsonc # Central service configuration used by ./scripts/setup.sh.
├── README.md # This README.
├── scripts # Useful script
│   ├── clean.sh # Delete all databases (reset system to see changes).
│   ├── preview-clean.sh # See what files will be deleted by clean.sh.
│   └── setup.sh # Setup service parameters.
├── services # Implemented services.
│   ├── games # Only contains Roulette for now.
│   │   └── roulette # Services used by Roulette service.
│   │       ├── event-log # Event log for Saga.
│   │       │   ├── Dockerfile
│   │       │   ├── interfaces.ol
│   │       │   ├── lib
│   │       │   │   └── sqlite-jdbc-3.47.1.0.jar
│   │       │   ├── main.ol
│   │       │   ├── parameters.ol
│   │       │   ├── params.json
│   │       │   └── types.ol
│   │       ├── event-relay # Event relay to take rewards from EventLog to RewardHistory.
│   │       │   ├── Dockerfile
│   │       │   ├── lib
│   │       │   │   └── sqlite-jdbc-3.47.1.0.jar
│   │       │   ├── main.ol
│   │       │   ├── parameters.ol
│   │       │   ├── params
│   │       │   │   ├── 1.json
│   │       │   │   └── 2.json
│   │       │   └─── params.json
│   │       ├── lock # User lock.
│   │       │   ├── load-balancer
│   │       │   │   ├── Dockerfile
│   │       │   │   ├── main.ol
│   │       │   │   ├── parameters.ol
│   │       │   │   └── params.json
│   │       │   └── shard
│   │       │       ├── Dockerfile
│   │       │       ├── interfaces.ol
│   │       │       ├── lib
│   │       │       │   └── sqlite-jdbc-3.47.1.0.jar
│   │       │       ├── main.ol
│   │       │       ├── parameters.ol
│   │       │       └── params
│   │       │           ├── 1.json
│   │       │           └── 2.json
│   │       ├── roulette # Roulette orchestrator.
│   │       │   ├── Dockerfile
│   │       │   ├── interfaces.ol
│   │       │   ├── main.ol
│   │       │   ├── parameters.ol
│   │       │   └─── params.json
│   │       └── web # Roulette demo page + company portfolio.
│   │           ├── Dockerfile
│   │           ├── interfaces.ol
│   │           ├── lib
│   │           ├── main.ol
│   │           ├── parameters.ol
│   │           ├── params.json
│   │           ├── templates # Mustache templates.
│   │           │   ├── dev.html
│   │           │   ├── empty-page.html
│   │           │   ├── footer.html
│   │           │   ├── header.html
│   │           │   ├── login-dialog.html
│   │           │   ├── logout-button.html
│   │           │   ├── page.html
│   │           │   ├── roulette.html
│   │           │   └── user.html
│   │           └── web # Web files.
│   │               ├── assets
│   │               │   ├── favicon.svg
│   │               │   └── logo.svg
│   │               ├── catalogue
│   │               │   ├── index.html
│   │               │   └── roulette
│   │               │       └── index.html
│   │               ├── contact.html
│   │               └── index.html
│   ├── gateway # API Gateway.
│   │   ├── Dockerfile
│   │   ├── extenders.ol
│   │   ├── main.ol
│   │   ├── parameters.ol
│   │   ├── params.json
│   │   ├── surface.ol
│   │   └── surface.sh
│   ├── rewards # Reward services.
│   │   ├── history # Reward history.
│   │   │   ├── load-balancer
│   │   │   │   ├── Dockerfile
│   │   │   │   ├── main.ol
│   │   │   │   ├── parameters.ol
│   │   │   │   └── params.json
│   │   │   └── shard
│   │   │       ├── Dockerfile
│   │   │       ├── interfaces.ol
│   │   │       ├── lib
│   │   │       │   └── sqlite-jdbc-3.47.1.0.jar
│   │   │       ├── main.ol
│   │   │       ├── parameters.ol
│   │   │       ├── params
│   │   │       │   ├── 1.json
│   │   │       │   └── 2.json
│   │   │       └── types.ol
│   │   ├── load-balancer # Reward loadbalancer to reward shards.
│   │   │   ├── Dockerfile
│   │   │   ├── interfaces.ol
│   │   │   ├── main.ol
│   │   │   ├── parameters.ol
│   │   │   └── params.json
│   │   ├── rebalancer # Rebalancer. Is used in the prototype to add rewards to RewardShard's.
│   │   │   ├── Dockerfile
│   │   │   ├── interfaces.ol
│   │   │   ├── main.ol
│   │   │   ├── parameters.ol
│   │   │   └── params.json
│   │   └── shard # Reward shard.
│   │       ├── Dockerfile
│   │       ├── interfaces.ol
│   │       ├── lib
│   │       │   └── sqlite-jdbc-3.46.1.3.jar
│   │       ├── main.ol
│   │       ├── parameters.ol
│   │       ├── params
│   │       │   ├── 1.json
│   │       │   └── 2.json
│   │       └── types.ol
│   ├── users # User services.
│   │   ├── email-auth # Email authenticator.
│   │   │   ├── interfaces.ol
│   │   │   ├── main.ol
│   │   │   └── parameters.ol
│   │   ├── load-balancer # User load balancer.
│   │   │   ├── Dockerfile
│   │   │   ├── main.ol
│   │   │   ├── parameters.ol
│   │   │   └── params.json
│   │   └── shard # User shard.
│   │       ├── Dockerfile
│   │       ├── interfaces.ol
│   │       ├── lib
│   │       │   └── sqlite-jdbc-3.47.1.0.jar
│   │       ├── main.ol
│   │       ├── parameters.ol
│   │       ├── params
│   │       │   ├── 1.json
│   │       │   └── 2.json
│   │       └── types.ol
│   └── utilities # Utility services.
│       ├── event-utils # Service used to query sagas and events.
│       │   ├── interfaces.ol
│       │   └── main.ol
│       ├── hash-utils # Service used to hash strings.
│       │   ├── interfaces.ol
│       │   └── main.ol
│       ├── pretty-console # Service used to get better printing.
│       │   ├── interfaces.ol
│       │   └── main.ol
│       └── weighted-load-balancer # Interface for weighted load balancers. Used by RewardShard to get getWeight.
│           └── main.ol
└── tools # Service tools.
    ├── history-test # Fetch history for user.
    │   ├── main.ol
    │   ├── parameters.ol
    │   ├── params.json
    │   └── run.sh
    ├── roulette-test # Spin roulette wheel for user.
    │   ├── main.ol
    │   ├── parameters.ol
    │   ├── params.json
    │   └── run.sh
    └── seed # Seed databases.
        ├── main.ol
        ├── parameters.ol
        ├── params.json
        ├── run.sh
        └── seed.json

About

DM585: Distributed and Web Programming project.

Topics

Resources

Stars

Watchers

Forks