Giter Club home page Giter Club logo

ivanpaulovich / clean-architecture-manga Goto Github PK

View Code? Open in Web Editor NEW
3.9K 220.0 674.0 21.38 MB

:cyclone: Clean Architecture with .NET6, C#10 and React+Redux. Use cases as central organizing structure, completely testable, decoupled from frameworks

Home Page: http://paulovich.net/

License: Apache License 2.0

Shell 0.36% C# 46.61% Dockerfile 0.42% HTML 4.60% CSS 0.27% PowerShell 2.09% JavaScript 10.33% SCSS 35.31%
solid-principles ddd-architecture clean-architecture clean-code dotnet-core evolutionary-architecture microservice design-patterns docker tdd

clean-architecture-manga's Introduction

Clean Architecture with .NET Core & React+Redux 🌀

All Contributors Build Status

Sample implementation of the Clean Architecture Principles with .NET Core. Use cases as central organizing structure, decoupled from frameworks and technology details. Built by small components that are developed and tested in isolation.

We support two versions:

Hit the WATCH button to get the latest Clean Architecture updates.

Manga is a Virtual Wallet Solution in which the customer register an account then manage the balance by Deposit, Withdraw and Transfer operations.

We also support the React client:

React+Redux Demo

Build & Run

To startup the whole solution, execute the following command:

Windows:

PS cd .docker && ./setup.ps1

MacOS:

$ cd .docker && ./setup.sh

Then the following containers should be running on docker ps:

Application URL
NGINX https://wallet.local:8081
Wallet SPA https://wallet.local:8081
Accounts API https://wallet.local:8081/accounts-api
Identity Server https://wallet.local:8081/identity-server
SQL Server Server=localhost;User Id=sa;Password=<YourStrong!Passw0rd>;Database=Accounts;

Browse to https://wallet.local:8081 then click on Log In. If asked trust the self-signed certificate.

Motivation

Learn how to design modular applications.

Explore the .NET Core features.

Learn how to design modular applications

Learning how to design modular applications will help you become a better engineer. Designing modular applications is the holy grail of software architecture, it is hard to find engineers experienced on designing applications which allows adding new features in a steady speed.

Explore the .NET Core features

.NET Core brings a sweet development environment, an extensible and cross-platform framework. We will explore the benefits of it in the infrastructure layer and we will reduce its importance in the application and domain layers. The same rule is applied for modern C# language syntax.

Learn from the open source community

This is continually updated, open source project.

Contributions are welcome!

Contributing

Learn from the community.

Feel free to submit pull requests to help:

  • Fix errors.
  • Refactoring.
  • Build the Front End.
  • Submit issues and bugs.

The Discussão em Português is pinned for the large community of brazillian developers.

Index of Clean Architecture Manga

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Ivan Paulovich

🎨 ⚠️ 💻

Petr Sedláček

⚠️ 💻

Gus

🎨 ⚠️

arulconsultant

⚠️

Guilherme Silva

🎨 ⚠️ 💻

Ondřej Štorc

🎨 ⚠️

Marlon Miranda da Silva

🎨 ⚠️

NicoCG

⚠️

Filipe Augusto Lima de Souza

🎨 ⚠️ 💻

sshaw-sml

⚠️ 💻

Matheus Neder

⚠️

димитрий матиенко

🎨 ⚠️

morphlogic

⚠️ 💻

Felipe Lambert

⚠️ 💻

Philippe Matray

🎨 💻

Leandro Fagundes

💬

Bart van Ommen

🤔 💻

qpippop

🤔

Cesar Pereira

💻

Edvaldo Farias

💻

Sergio Broccardi

💻

cuno92

💻

Vinícius Mamoré

💻

dyavolick

💻

felipetofoli

🎨 💻

Charith De Silva

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Hit the FORK button and show Clean Architecture on your profile.

clean-architecture-manga's People

Contributors

allcontributors[bot] avatar bommen avatar cesinhaugusto avatar charithdesilva avatar cuno92 avatar dependabot[bot] avatar dyavolick avatar edvaldofarias avatar fals avatar felipetofoli avatar felpasl avatar guibranco avatar guilhermeps avatar ivanpaulovich avatar ostorc avatar petrspelos avatar phmatray avatar roxas0zero avatar sbroccardi avatar sshaw-sml avatar stavares843 avatar vmamore 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clean-architecture-manga's Issues

Using structs or classes as base for Value Objects?

Hey,

I've found a slight issue which I'm not entirely sure can be addressed in .NET, but essentially, structs can be initialized as default(...), regardless of what constructors exist.

Thus, I can easily create a SSN and (all other value objects) by using

SSN ssn = default;

While this may work fine if you're relying on everyone initializing these value objects using their constructor, would it not be better to make SSN, Name, etc. classes?

You could, in theory, also use SSN ssn = new SSN(), but that is a stylecop error and not a .NET error.

Add support to Multiple Currencies

I would like to see support for multiple currencies.

The challenge is that the current implementation uses a Value Object to describe Money in which there is no information regarding the Currency so it is not possible to deposit Euros and Dollars to the same account history.

In the real world the customers deal seamlessly with multiple currencies and the bank is responsible for the exchange service.

How can we do the same in a DDD approach?

My first thought is to change the Money Value Object to include info regarding the Original Currency and the Value in Euro then design a Factory object that is initialized with an Exchange Service.

After that we need to change the controllers to use the Factory instead of instantiating the Money directly.

Thoughts?

Please fix RuleSet

We added the .ruleset files on each project and I had to disable lots of rules so we can move forward.
I think it is time to enable those rules and update the code base accordingly.

Account Transfering

hello ivan, congrats for the nice job you ve done.
btw I ve read the code, and I miss an example of account transfering among two diffrents accounts.
how would it be done within that architectural approach?
May it be something related with Unit of Work?

I want to know better about it

Hi Ivan

I ve found something really interesting in your project Mango

image

I would like to talk detailed about it to future

Question regarding the usecases

Hi Ivan,

Great repo, really usefull stuff!

I have one question though, while researching the ports and adapters pattern / hex arch I stumble upon the following issue:

Should each driver interface (port/usecase in your case) only do one thing? Or is it allow to have, lets say, a customer interface which allows for more than one action a customer.

My concern is that a project will become very big if I were to add an interface for each usecase.

Kind regards,

Bob

Refactor Equality members

Hello,

I have been discovering this great project for a few days now and I already wanted to thank you. :)

Would it be interesting to refactor the implementation of the IEquatable interface of value objects?

Here is a more concise implementation possibility used in ReSharper and Rider.

What do you think of that?

namespace Domain.ValueObjects
{
    using System;
    
    public struct Name : IEquatable<Name>
    {
        private readonly string _text;

        public Name(string text)
        {
            if (string.IsNullOrWhiteSpace(text))
                throw new NameShouldNotBeEmptyException("The 'Name' field is required");
            
            _text = text;
        }

        public override string ToString()
            => _text;

        public bool Equals(Name other)
            => _text == other._text;

        public override bool Equals(object obj)
            => obj is Name other && Equals(other);

        public override int GetHashCode()
            => _text != null ? _text.GetHashCode() : 0;
    }
}

Add Localization feature

Hi Ivan, first of all, great job.

Based on this architectural proposal, how would you suggest adding localization capability to this project? I'm asking it because APS.NET core provides great support for localization, but when I thinking about Domain Layer, Application Layer it is not so clear to me. My questions are:
1 - Where the resource files should be?
2 - How we can resolve the domain model and value objects?
3 - How would you solve it thinking in tests, business rules?

Thank you.

Interfaces on entities

Hello,

First of all great repository! Good basis to get started with a clean arch service. I am wondering why you recently added interfaces on the entities? I've been told it is an an anti pattern. What exactly is the advantage of adding them (or removing) them?

Thanks!

Web Ui Depend on Manga.Infrastructure

Hello and thank you for your great project.
i have a question why we have Infrastructure reference in Web Ui ?
base on diagrams we should not depend on Infrastructure ?
so if we have to add the reference because of registering DI classes is there any best practice for loos that dependency?

Manga.IntegrationTests.CustomerRegistration.Register_Deposit_Withdraw_Close test fails lacking dependencies

Running Manga.IntegrationTests.CustomerRegistration.Register_Deposit_Withdraw_Closefails with the following stack trace:

System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.AspNetCore.Mvc, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Stack Trace:
at Manga.WebApi.Startup.ConfigureServices(IServiceCollection services)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at Microsoft.AspNetCore.TestHost.TestServer..ctor(IWebHostBuilder builder, IFeatureCollection featureCollection)
at Manga.IntegrationTests.CustomerRegistration..ctor() in C:\dev\code\clean-architecture-manga\manga\test\Manga.WebApi.Tests\CustomerRegistration.cs:line 33

Add GraphQL layer

Hi,

First of all thank you very much for this awesome work @ivanpaulovich and contributors.

I would love to see a GraphQL API co-existing with the current API.

Actually there are 2 big libraries in the .NET Core GraphQL community:

I have tested both of them and personally I do prefer HotChocolate, and even having a smaller comunnity I think they are releasing new features faster and documentation is (at least for me) much clearer.

I would love to collaborate on this trying to integrate GraphQL following the clean architecture approach.

Just let me know if you think it would be ok :)

Thanks in advance!

Question about mediator for executing use cases

Hello Ivan,

Another question, I see that you've recently added the mediator pattern to execute use cases from controllers. By using the mediator, the controller does not directly call the execute method of the use case, so it does not "know" that the use case exists. On the other hand, what is the downside of the controller "knowing" the use case interface? I see the benefits of the mediator pattern, I just wonder what the benefits are in this case.

What is the benefit of using the mediator pattern for executing use cases?

Thanks!

c# Interfaces without properties

Hi,

May be i'm missing something, but interfaces (in the C# sense of word) in this project don't have any property definitions. Could you explain the rational behind that ?

Thanks.

Shouldn't entities be Abstract?

As I noticed, entities shouldn't be created anytime, only by the factory. The only part of an entity that should be created is the entities of the infrastructure layers.

Based on this, why entities aren't abstract?

Output port as argument in execute method

Hello Ivan,

First of all, thank you very much this repository. Your project perfectly resembles the components that are described in the presentation of Robert C. Martin about clean architecture (https://youtu.be/Nsjsiz2A9mg).

We've set up our first application using this architecture (the version before the mediator was introduced). One of the things we're having discussions about is that it feels a bit magic that the controller executes the use case and then gets the response from the presenter. There is no coupling between the use case interface and the output port interface, which is probably by design, but makes it a bit vague to use. You have to assume that the result of the use case is written to the presenter.

Another approach that we've discussed here is to pass the output port as an argument to the execute method of the use case (considering that we don't use the mediator pattern for executing use cases). This makes explicit that the use case uses the output port to write the results, but of course, couples the use case interface to the output port interface.

What are your thoughts on this?

Use Cases and MediatR

First off really cool repo! I was poking around in it and noticed your UseCases are quite similar to the pattern we use which revolves around MediatR. Have you considered using MediatR instead of your custom use case abstractions? Just curious if this library would play into the Clean Architecture you are trying to achieve or if it would cause any issues. Thanks!

ValueObjects and DomainExceptions - centralized or decentralized

I noticed that the ValueObjects and DomainExceptions are placed in a cental folder ValueObjects. In another issue (#115) a statement was made that ValueObjects should be tied to one specific entity. Is there a case to be made to place ValueObejcts in the same namespace as their respective Entity?
When a project grows I could imagine this would make them easier to find.

Understanding more about patterns, please?

I'm trying to figure out how the following problem should be solved:

I have a Bank entity.
Users of the system could be customer, manager, director or just a bank operator.
All of them will be a customer too, because to work on a bank, you should have an account.

So, should all of them implements ICustomer?
Should I have IManager which implements ICustomer? (always expanding my class, never changing it as OCP said).

Thanks guys

CQRS / Event Sourcing support

In order to fully harness the benefits of Domain Driven Design a CQRS / Event Sourcing implementation would be awesome. How would you approach this?

Move documentation to the Wiki

The documentation should be moved to the Wiki and we could add comments linking the source code to the wiki topics.

For instance the design patterns found in the project (Aggregates, Entity, Repository, UseCase) could be linked to existing wiki pages.

Revisiting the Domain and Bounded Contexts

Hey all,

I recognise that the aggregate names are obscure, we have Users, Accounts and Customers and if we talk about them separately they seems to be the same thing.

User is the ExternalUser connected to the Authentication Credentials (Security).
Customer is the person details (Support).
Account is the the SavingsAccount or CheckingsAccount from the transactions perspective (Core).

I'd suggest we break the Domain in three Bounded Contexts:

  • Core (for Accounts)
  • Customers (for Customers)
  • Security (for Users)

My intent is to show a real case of a modular system.

The second suggestion is to bring the Boundaries interfaces into the Bounded Contexts.

Is that a good idea?

Withdrawal and Deposits issue

A user should not be able to withdraw a negative amount and deposit a negative amount example:

Current balance: 1200
‘Withdraw -1100 makes current balance 2300’
Same with deposit.

Password value object

Hello Ivan,

How should we store a password in a value object? Ideally I think the field should contain a hashed password value?

However, how to hash a password without depending on the .NET framework in order not to break the domain's responsibilities?

Also, what are the rules to be implemented as part of this implementation? For a secure password, here are some rules that could be applied.

  • 12 characters minimum
  • 30 characters maximum
  • one number minimum
  • one capital letter minimum
  • A punctuation mark OR a special character (dollar, hash,...) minimum

Redundant classes question

Hi!
I've really love how this project is organized, and i've been working with this structure for a while now. But there is something that i personally don't like muc: repeat a controller for multiples usecases.
In your sample, in most of use cases we have AccountsController again. or IOutputPort. It's more organized, but i still think it's redundant.

Do you have any particular reason for this, or can help me clarifying this?

Thanks in advance!

Please design Domain Services

When I see the RegisterUseCase and it depends on 3 repositories from 3 different Bounded Contexts it is unnecessary hard to understand the Register Use Case.

I would like to see the RegisterUseCase as a composition of:

  • Verify User Already Registered / Register.
  • Opens Savings Account and Deposit Initial Amount.
  • Creates User Credentials.

Using ValueObjects for different entities should be avoid?

If we add a Bank Entity where Bank should have a Name property, should it be the same Name of Customer?

But if the rules of Customer or Bank should have an additional implementation like: Bank Name should have only 10 characters, should we build UserName VO and BankName VO?

.NET Core version conflict

Although it is described on the project's main page that we're using .NET Core 3.1, the global.json file makes reference to 3.0 version. Should the version be upgraded to 3.1?

I'm bringing this issue up because support to 3.0 will end on 2020-03-03, according to Microsoft. I also believe it doesn't impact on the codebase, resulting in only updating the global.json file.

A use case to request a list of items

Hi guys,

we can see here how to implement must of the time a one-to-one needed.
If you need a customer, you got it. If you need a account, you got it.
But if I want to do a report with all my customers, showing the total balance for each one, how it should work?

I'm afraid about how the relation between each customer will be with his many accounts.

ps: Sorry if I'm making this wrong, it's my first time participating on github.

Design Value Objects Factory

It would be nice to instantiate ValueObjects the same way we instantiate Entities. I suggest we include methods into EntityFactory to instantiate ValueObjects.

CustomerReadOnlyRepository

Hi,

I observed that the class CustomerRepository is with wrong name on implementation ( "CustomerReadOnlyRepository")

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.