Giter Club home page Giter Club logo

regis-pay's Introduction

Regis Pay is fictional payment processor created as an example of a event-driven microservice architecture project built with dotnet, making use of the Transactional Outbox pattern (with Azure Cosmos DB) and Event Sourcing pattern.




Architecture

This diagram depicts the architecture of this solution.

Architecture diagram

  • API: Represents the application programming interface that exposes endpoints for creating, updating, and deleting data.
  • Change Feed Processor: Monitors changes to data (e.g., database records) and publishes events when changes occur.
  • Event Consumer: Subscribes events and processes them (e.g., updating databases, sending notifications, etc.).

This sequence diagram shows how a payment would go travel through the system.

sequenceDiagram
actor Client
Client->> API: Create Payment
Note over API,Event Store: Persisting event to event store
API->>Event Store: Payment Initiated
Note over Event Store, Change Feed: Domain events
Event Store-->>Change Feed: Payment Initiated
Note over Change Feed, Message Broker: Publish integration events
Change Feed-->>Message Broker: Payment Initiated
Note over Message Broker, Consumer: Consume integration events
Message Broker-->>Consumer: Payment Initiated
activate Consumer
Note over Consumer, 3rd Party System: Handle integration event
Consumer->> 3rd Party System: Create Payment
Consumer->> Event Store: Payment Created
deactivate Consumer
Event Store-->>Change Feed: Payment Created
Change Feed-->>Message Broker: Payment Created
Message Broker-->>Consumer: Payment Created
activate Consumer
Consumer->> 3rd Party System: Settle Payment
Consumer->> Event Store: Payment Settled
deactivate Consumer
Event Store-->>Change Feed: Payment Settled
Change Feed-->>Message Broker: Payment Settled
Message Broker-->>Consumer: Payment Settled
activate Consumer
Consumer->> 3rd Party System: Send Notification
Consumer->> Event Store: Payment Completed
deactivate Consumer
Event Store-->>Change Feed: Payment Completed
Change Feed-->>Message Broker: Payment Completed

All components have been added to make the clear distinction how a payment flows through this architecture The same components from the previous diagram are included below and the new ones have been marked with asterisk(*).

  • API: Represents the application programming interface that exposes endpoints for creating, updating, and deleting data.
  • Event Store*: Where event data is persisted. In this example project Cosmos DB, other databases are available.
  • Change Feed Processor: Monitors changes to data (e.g., database records) and publishes events when changes occur.
  • Message Broker*: System used to forward on messages (integration events). Used the term Message Broker because RabbitMQ was used in this example, but this could easily be swapped out for servies like Azure Service Bus.
  • Event Consumer: Subscribes events and processes them (e.g., updating databases, sending notifications, etc.).
  • 3rd Party System*: Represents a thrid party system, either internally or externally.

Getting Started

There are two ways to get started and up and running.

Docker

Note

This option offers an all in one solution. No need to install/run CosmosDB or RabbitMQ individually.

Prerequisites

Steps

  1. cd into the local folder and run the localSetup.ps1 from your terminal. This is to setup the cert on API docker container for HTTPS support.
.\localSetup.ps1
  1. Then run docker compose
docker-compose up --build

This should run all the services as-well as all the required dependencies in a pre-configured working state.

Visual Studio

Prerequisites

The following prerequisites are required to build and run the solution. You can either install them individually or via docker:

Steps

  1. Run the services as mentioned in the prerequisites.

  2. Run the solution from Visual Studio, which should start the three programs, Api, ChangeFeed and EventConsumer.

Manually Testing

Once up and running you can test the solution by using the payment.http file to make a API request and observe the logs. As this solution uses CosmosDB and RabbitMQ, you can also inspect these systems to verify integration.

Here's an example gif showcasing the services running in docker and me manually submitting a payment request.

Manually Testing

Observe the logs emitted as the payment goes through the services.

Technologies

Core infrastructure technologies in this solution are:

  • Azure Cosmos DB - A NoSQL database for storing data.
  • RabbitMQ - A reliable and mature messaging and streaming broker.

Nuget Packages

Notable packages used in this solution are:

  • MassTransit - A framework that provides a abstraction on top of message transports, ie. in this example RabbitMQ. It can also be used with Azure Service Bus and Amazon SQS.
  • FastEndpoints - A developer friendly alternative to Minimal APIs & MVC.

regis-pay's People

Contributors

reggieray 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.