Giter VIP home page Giter VIP logo

tdc-vertical-slice-architecture's Introduction

TDC Innovation 2023 - .NET Architecture

Our implementation of Vertical Slice Architecture in .NET

Coverage Maintainability Rating Quality Gate Status

Lecture co-hosts: @lgcmotta and @ffernandolima.

Vertical Slices Architecture 🍰

Banking App was designed to act as a simplistic implementation of a bank backend using the Vertical Slice Architecture.

architecture-diagram-overview

The microservices are organized into components (use cases), and each feature is an independent part of the system. A feature can never import code from some other component. This is designed to prevent side effects when the feature code changes. However, features can import general-purpose code.

Features can be either a Command or a Query, but never both. Although the output from a Query can be a Command.

The feature entrypoint is responsible to send the Command or request the Query data.

command-query-flow

Running Banking App 🏦

Requirements

  • .NET 7 SDK
  • Docker

Environment Setup 🐋

Start container dependencies with:

docker compose up -d

To have the Banking App full picture up and running you need to start the following projects:

  • ./src/Geteway/BankingApp.Gateway
  • ./src/Accounts/BankingApp.Accounts.API
  • ./src/Transactions/BankingApp.Transactions.API
  • ./src/Fees/BankingApp.Fees.API

You can use your IDE to launch these projects, or the dotnet run command.

Contribute 👋

Feel free to open an issue or a pull request.

tdc-vertical-slice-architecture's People

Contributors

ffernandolima avatar lgcmotta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tdc-vertical-slice-architecture's Issues

Domain Enhancement

Domain Enhancement

The transactions domain should be enhanced before VSA can be applied.

Some concepts can be added to enhance the Domain Drive Design experience, such as:

  • Create Money as a Value Object.
  • Use Currency to convert Money to and from USD
  • Allow accounts to withdraw values that will make the balance negative (possible overdraft feature can be implemented)
  • Produce balance changed domain event for Deposit/Withdraw/Transfer but not for earnings
  • Put domain abstractions in another project to be used by another service domain
  • Better encapsulation of domain, you must use the aggregate to access any entity

Remove old projects from solution

The old application served its purpose. It was a good starting point to create Transactions API and Transactions Domain. I think we can move on and delete these projects from the repository.

Add Accounts Domain

We're going to add the simplest domain possible, basic CRUD operations on top of the Account, to notify the other domains that we have an account on the app!

Transactions: Add VSA Approach

Transactions Domain: Add VSA Approach to WebAPI

  • Add Commands/Queries
  • Add Behaviors
  • Configure EF Core and create migrations
  • Add EF SecondeLevelCache
  • Add integration events/handlers
  • Configure events dispatching strategy
  • Add endpoints

Refactor Transfer Flow to Add In & Out

The Transfer flow should receive another account to perform the In and Out status.

We also need to know the sender and the receiver for all transactions to have a more comprehensive statement.

Add Logging

We need to add logging.

Use OTEL collector to export logs to...?
Use Serilog?
Add Logging Behavior

Add Repository Documentation

We need to provide documentation about:

  • Vertical Slice Architecture implementation
  • Architecture overview of the implementation
  • Instructions for running the Banking App
  • Microservices Business Rules

Create presentation slides

TODO

  • Criar template de slides
  • Criar um detalhamento do summary da palestra, pensando no tempo total da palestra (35min)
  • Trazer o código para os slides

Summary

  • Apresentação dos palestrantes (Breve introdução sobre nós)
  • Introdução ao assunto
    • Contexto (trabalhar em cima do texto de apresentação da palestra)
    • Motivação da palestra (experiência em diversos sistemas utilizando .NET com problemas arquiteturais similares a medida que evoluem)
  • Apresentação do problema arquitetural com n-layers
    • Alto acoplamento entre as camadas
    • Classes com mais de uma responsabilidade
    • Dificil manutenabilidade e legibilidade
    • Alta complexibilidade
  • Apresentação da solução com vertical slices
    • Conceito
    • Combinação com outras tecnologias de mercado
    • Possível utilização sem as tecnologias de mercado
    • Combinação com outros patterns: CQRS, Event Sourcing, DDD, Transaction Script
    • Prós e Contras
  • Tempo reservado para dúvidas

Remove frontend client

We aren't going to use the react frontend for this presentation. It should be removed.

Create Slices for Fee Service

We need to create a service to handle the fee processing.

Feature/Slice Entrypoint CQRS Type
CreateAccount RabbitMQ Command
OverdraftFee BackgroundService Command
ProfitFee BackgroundService Command
UpdateAccount RabbitMQ Command
UpdateBalance RabbitMQ Command

Create Taxes Domain

We need to create the Taxes domain.
This domain is responsible for applying fees or incomes to the account balance.

It will store:

  • AccountId (Guid)
  • CurrentBalance (Money)
  • LastBalanceChange (DateTime)

Domain Rules:

  • Given a configurable time span, if the balance is positive and hasn't changed an income is applied to the account balance.
  • Given a configurable time span, if the balance is negative, a fee will be applied to the account for overdraft usage.
  • Given a configurable time span, if the balance is zero, nothing happens.

This domain should be notified every time a transaction changes the account balance, except when the balance changes for fees or incomes.

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.