Giter Site home page Giter Site logo

authorizer's Introduction

Authorizer App

The Authorizer application authorizes a transaction for a specific account following a set of predefined rules.

The application aggregates all transactions within 2 minutes interval, once the aggregation interval completes, the transactions will be executed according to the time defined in transaction.

The application:

Appication is written in Scala and based on Akka actors .

running the Application

java -jar $PATH_TO_JAR/authorizer-assembly-1.0.jar

For graceful stop use the command stop as input or simply CTL+C

Building executable

Use sbt build tool https://www.scala-sbt.org/

run the command: sbt clean assembly or sbt assembly

Project structure

Domain Driven Design is the main design approach hence using a ubiquitous language trough the spec document given by Nubank and naming the application entities

Tests

All rules defined in the spec are covered in AthorizerSpec.scala

domain entities:

Authorizer

Aggregate the Account life states, and simulates state machine of the account life cycle and executes the operations according to the logic

Authorizer states :

  • waitForInit - the initial state, waits for Init account command , once the account is initilize with active-card true it fires timer accourding to transaction interval (2 minutes,can be configured) and change the state to run or to inactiveAccount (depends on the active-card argument)
  • run - accepts transactions and checks validation of the operation
  • inactiveAccount - in case the active-card:false, this state will respond with violation "card-not-active" in case of transaction

violations

contains the value objects that represents the different violations

Operations

contains the value objects that represents the different operations and responses

protocol

This package contains the json conventions protocol The application accepts the input and emits the output as json

utils

package that contains helpers for handling the configuration and datetime conventions gracefully

Publisher - simple actor that simply receives a message and emits it to the stdout as a json

Remarks

  • Akka actors are low resource and enables to achieve async and scalable operations easily.
  • Each actor is minimized to maintain single responsibility althogh it might be a little overhead or over engineering I do believe that it is correct in a real life apps.
  • In order to keep it simple I didn't use persisted actor or other persistence storage and maintained a single account with in memory state as requested.

authorizer's People

Contributors

123avi 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.