📜 ⬆️ ⬇️

Antifraud. Service Architecture (Part 3)

This is the third part of the experiment to create a system of recognition of fraudulent payments ( antifraud-system ). The goal is to create an affordable (in terms of development and ownership) antifraud service that will allow several participants to make online payments - merchants, aggregators, payment systems, banks - to reduce the risks of fraudulent payments ( fraud ) through their sites.

In the last part, we focused on the functional and non-functional requirements for antifraud service. In this part of the article we will consider the software architecture of the service, its modular structure and key details of the implementation of such a service .

Antifraud in azure
')

Infrastructure


The service consists of several applications running in Microsoft Azure. Placing using a cloud platform instead of on-premise placement will not only allow, at a minor time, to develop a service that meets all the requirements listed in the second part in the section “Non-functional requirements -> Quality attributes ”, but also significantly reduces the initial financial costs of hardware and software. security.

Antifraud service consists of the following systems:

In addition, the service has numerous software clients ( Clients ), which are merchant web applications, or js widgets that call the Antifraud API Service REST services.

The schematic diagram of the interaction of these systems is illustrated above.

Used architectural patterns


Infrastructure, along with the subject area and legislation, potentially carries with it a large number of restrictions that must be taken into account at the architectural level. And if we have already discussed the domain and legal restrictions in the previous parts of the article, then we will discuss the advantages and limitations associated with the choice of the Microsoft Azure cloud platform below.

Azure anti-fraud-system services used - Cloud service for web- / worker-roles, Azure Table, Azure Queue, Azure ML, etc. - in addition to the almost zero initial financial costs for infrastructure, the following advantages are out of the box:

As a bonus, I consider:

But to take advantage of all these advantages came about only thanks to the “sharpening” of the anti-fraud service architecture under the cloud, like this:

In addition, antifraud service is a near real-time system, so when implementing antifraud service:

You must also keep in mind that all cloud services have limitations:

Interaction between service components


For a merchant, a service is a REST service with which you can communicate using the https protocol - Antifraud API Service. The Antifraud API Service runs in a cluster consisting of several stateless web roles (a web role in Azure — the application layer that performs the role of the web application).

The following sequence diagram describes the merchant's possible interactions with all subsystems of the antifraud service.

Antifraud sequence diagram


Consider each of the steps in more detail.

The request from the merchant goes to the controller (in terms of MVC) (Step 1). After that, the resulting model (in terms of MVC) passes:
  1. transformation from a controller model to a domain object;
  2. request to external geolocation services (Azure Marketplace), in order to find out the country by the payer index and the country by the IP of the host from which the request to withdraw funds from the card came;
  3. global filtering phase;
  4. verification phase for validity of billing data;
  5. preliminary analysis of the received transaction - we consider heuristics for timeframes 5 seconds, 1 minute, 24 hours;
  6. Concealment of personal data of the buyer and payment data - hashed the name of the cardholder, the name of the owner of the account on the merchant's website, the address of the payer, telephone, email.
  7. we delete unnecessary data - for example, data on the card’s validity period after step 4 will not be needed.

Heuristics, global filters, and validity of payment information were discussed in detail in the previous part of the article.

In step 2, the domain object is transformed into a DTO object, which:
  1. transferred to the service Fraud Predictor ML (step 3);
  2. after receiving a response from Fraud Predictor ML (step 4) information about the transaction and its result is saved to the transaction log (step 5) (about it just below);
  3. We return to the client the answer about the predicted result of the payment (fraudulent or not).

To improve the quality of the prediction algorithm, the client is available API clarify the results of the transaction. So, if the actual result of the payment was different from the value returned by our antifraud service, the merchant can report this by sending a request for clarification of the transaction results (step 9). Such requests:

Requests are taken from the queue by one of the robots that represent a stateless worker-role (the worker-role — in Azure, this is the application layer that serves as the processor).

Transaction Store


Both information about transactions and additional information on them (mainly statistics) are stored in the transaction log - long-term storage based on the Azure Table (service, which is a fail-safe NoSQL-storage (key-value)).

The transaction log consists of 2 tables:

At steps 7, 8, the model is retrained. A training set is data from a transaction log, since The log store contains the latest information on payments and their results. Overtraining can occur on a schedule, upon the appearance of a fixed value of new entries in the transaction log, on overcoming a certain threshold of incorrect predictions.

Details of the issue of learning the model of detection of fraudulent payments will touch on in the next final part.

Conclusion of the 3rd part


In this part, we discussed the antifraud service architecture, identified functional parts in it - Antifraud API Service, Fraud Predictor ML, Transactions Log, defined their areas of responsibility, as well as ways of interaction between them.

With the right approach to the architecture, deploying antifraud service in the Microsoft Azure cloud will significantly reduce the initial financial costs of the infrastructure, as well as reduce the time spent on issues related to system scalability, reliable data storage and high availability of services.

In the next final part, we will continue to create an antifraud service that is much cheaper in terms of development and ownership costs than its counterparts — we will develop the Fraud Predictor ML service, which is based on the Azure Machine Learning service and is the analytical core of the antifraud service.

Useful sources


[1] Cloud Design Patterns: Prescriptive Architecture Guidance for Cloud Applications , MSDN.

Source: https://habr.com/ru/post/254037/


All Articles