Giter Site home page Giter Site logo

iayti / cleanarchitecture Goto Github PK

View Code? Open in Web Editor NEW
660.0 660.0 120.0 426 KB

ASP.NET Core 6 Web API Clean Architecture Solution Template

License: MIT License

C# 99.51% Dockerfile 0.49%
clean-architecture csharp domain-driven-design dotnet-core dotnet6 template webapi

cleanarchitecture's Introduction

Hi there, I'm Δ°lker πŸ‘‹

Website

Website

I'm a Husband, Father and Developer

  • πŸ”­ I’m currently working on a ASP.Net Core 6 Clean Architecture Solution Template!

  • 🌱 I can put learning first among my interests. Because of my curiosity, I add new research topics before I finish. Therefore the list goes on and on.

    • πŸ“‘ I am eager to try dapr in production level.
      • πŸŒ• Service to Service Invocation (HTTP/gRPC)
      • πŸŒ– State Management (RDBMS / NOSQL)
      • πŸŒ— Publish and Subscribe(Azure Service Bus, AWS SQS/SNS - Kinesis, Apache Kafka, RabbitMQ, Redis)
      • 🌘 Input and Output Bindings triggering application and invoking external resources
      • πŸŒ‘ Actors : Virtual Actor Pattern implementation for concurrency and better scalability
      • πŸŒ’ Observability distributed tracing using Zipkin API and Open Telemetry Collector
      • πŸŒ“ Secrets Management Azure Key Vault/AWS Secret Manager or Dapr secrets API
    • πŸ† Scalable distributed applications, Event Sourcing , CQRS, Event Driven Architecture
    • ⚽ Kali Linux (I want to learn cyber security and try hack myself)
    • 🎯 Networking (Cisco CCNA maybe after CCNP I dont care the certificates, i just want to learn. πŸ˜ƒ)
  • πŸ₯… 2022 Goals: Contribute more to Open Source projects

Visitors since 08 Mar 2021

Connect with me:

ilkerayti.com ilkerayti | LinkedIn ilkerayti | LinkedIn ilkerayti | Medium ilkerayti | Nuget ilkerayti | Nuget


Languages and Tools:

.Net Platform CSharp Platform Visual Studio GraphQL SQL MongoDB Git GitHub Terminal AWS Azure Docker Kubernetes Linux Python RabbitMQ Redis Xamarin




Recent Github Activity

  1. πŸ—£ Commented on #44 in iayti/CleanArchitecture
  2. πŸ—£ Commented on #42 in iayti/CleanArchitecture
  3. πŸŽ‰ Merged PR #41 in iayti/CleanArchitecture
  4. πŸ’ͺ Opened PR #41 in iayti/CleanArchitecture
  5. πŸŽ‰ Merged PR #40 in iayti/CleanArchitecture

Github Stats

iayti's Github Stats

cleanarchitecture's People

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

cleanarchitecture's Issues

Adding Polly's Circuit Breaker

Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner

Duplication in mediator handlers

How to use duplicate code in handler?
Does the static method take up a lot of memory when a lot of data is exchanged?
Base on @ShreyasJejurkar
It's not recommended to send another request from request handlers. The purpose of using MeditR is just to convert HTTP requests to our application-specific requests and send them into the application layer without letting the controller knows about it or any other presentation layer.

What is the best solution to not occupy a lot of memory?
Static method or utility class or service or Application services or abstraction layers or domain layer?

What is the code you suggest?

How to have Navigation in User Model and Other Entities

Since Our Identity models are in the Infrastructure Layer and other Entities are in the Domain Layer, I was wonder to know how can we have navigation between an Entity and User Model?

For instance, I have two models, User and Content, Each user has 0 or many contents so there should be a List in User Model, and in Content there should be a foreign Key of User

Public class User{

 Public List<Content> Contents{get;set;}

}

Problem with identity server 4

Hello, I'm trying to setup identity server 4 for production, and the application keeps erroring out when it runs in production mode, any idea how I can solve this?

Occasionally receive 401 (Unauthorized)

I occasionally receive the error 401 (Unauthorized) after login. I am then required to restart the application pool and it will work fine again for a few days or sometimes weeks.

Not a big application or complicated app by any means (< 10 users and not much more complicated than the todo sample code). Memory usage is below 200 MB.

I am fairly new to Web API, Angular, and IdentiyServer programming so I assume the problem is something I am doing wrong.

Any ideas on where to look are highly appreciated.

Microservice Architecture Service Meshes, API Gateways, and Message Queues

API Gateways

  • Ocelot
  • Tyk
  • Kong
  • AWS API Gateway, Azure Api Management or Google Cloud Endpoints

Service Meshes

Message Queues

Technologies

I am really interested in using Dapr. We can use service mesh like Linkerd and message queues like RabbitMQ with Dapr.

We can use service meshes to manage the network between microservices. If we need message queues, it can be used with Dapr bindings RabbitMQ.

I'm waiting for suggestions. Thank you for your attention.

DenyAnonymousAuthorizationRequirement: Requires an authenticated user

This probably isn't a bug, just me not understanding .NET 5 + AspNetCore libraries, so I didn't click Bug Report just yet.

I followed the steps on the README but when trying it out through Swagger (the URL that pops up) it doesn't seem to authenticate. I tried using Super_Secret_Key as the token to authorize but got this...

image

and in console, the message that's in the subject of this issue.

Sorry, I'm still learning the AspNetCore libraries. Thanks for being patient with me. I have a lot of webapp experience and .NET Framework but haven't made my way into the .NET 5 API world until now.

I did get it working if I use Client.WorkerService... is it just the Swagger script that isn't working?

I tried through Postman with the same response. How would one authenticate through an API key?

Can you guide me to the right spot to add authorized tokens, or if it's just one token like Super_Secret_Key let me know what I'm doing wrong.

Thank you very much!

Authorize with Policy show 'The type or namespace could not be found'

Hi, I facing the issues with Authorize attribute when using policy

Since in your code using custom authorize class, so I unable to implement policy here.

If using Microsoft.AspNetCore.Authorization.AuthorizeAttribute, then the authorization is not working.

Example

//Need use this, or else show an error 'The type or namespace could not be found'
using AuthorizeAttribute = Microsoft.AspNetCore.Authorization.AuthorizeAttribute;


[HttpPost]
[Route("uom")]
[Authorize(Policy = "user.read.policy")] // Is not working
[ProducesResponseType(typeof(ServiceResult<ItemUomDto>), (int)HttpStatusCode.OK)]
public async Task<ActionResult<ServiceResult<ItemUomDto>>> Create([FromBody] CreateItemUomCommand command)
{
     return Ok(await Mediator.Send(command));
}

Any idea how we can solve?

Docker Container is not running on Windows 10

Describe the bug
failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c dotnet restore
"src/Apps/ProjName.Api/ProjName.Api.csproj"]: exit code: 1

To Reproduce
Steps to reproduce the behavior:

  1. Create the new template using dotnet new --install Matech.Clean.Architecture.Template
  2. Downloading the Docker desktop
  3. Going to the folder and running command docker-compose up

Expected behavior
The Docker images got up and running

Desktop (please complete the following information):

  • OS: [Windows 10]
  • Browser: NA
  • Version: 1.1.1.2

Return Task<ServiceResult> without <T>

Based on this code

 public async Task<ServiceResult<CityDto>> Handle(UpdateCityCommand request, CancellationToken cancellationToken)
        {
            var entity = await _context.Cities.FindAsync(request.Id);

            if (entity == null)
            {
                throw new NotFoundException(nameof(City), request.Id);
            }
            if (!string.IsNullOrEmpty(request.Name))
                entity.Name = request.Name;
            entity.Active = request.Active;

            await _context.SaveChangesAsync(cancellationToken);

            return ServiceResult.Success(_mapper.Map<CityDto>(entity));
        }

Any I idea how I can return ServiceResult without Dto? I just want to return public async Task<ServiceResult> Handle(UpdateCityCommand request, CancellationToken cancellationToken)

In some case, I just want to tell success only

Thanks in advance.

Clean architecture with EF Core DB First approach

Hi,

I am implementing clean architecture using the existing database, with scaffolding command I have generated the POCO entities in the Infrastructure layer and as well as manually created the entities in the domain layer to map them later.

in the Application layer, I have the generic interface repository with a few standard operations.

public interface IRepository<T> where T : class
 {
     Task<IReadOnlyList<T>> GetAllAsync();
     Task<T> GetByIdAsync(int id);
     Task<T> AddAsync(T entity);
     Task UpdateAsync(T entity);
     Task DeleteAsync(T entity);
 }

As per the principles of Clean-Architecture, I am implementing it in the Infrastructure layer.

public class Repository<T> : IRepository<T> where T : class
    {

        protected readonly MyDBContext _MyDBContext;
        public Repository( MyDBContext mydbContext)
        {
            _MyDBContext= mydbContext;
        }
        public async Task<T> AddAsync(T entity)
        {
            await _MyDBContext.Set<T>().AddAsync(entity);
            await _MyDBContext.SaveChangesAsync();
            return entity;
        }

-----
----

As per the template, I am using a Mediator pattern with CQRS, when I try to save the user from the API layer I will end up with the below exception.

System.InvalidOperationException: Cannot create a DbSet for 'ABC.Domain.Entities.User' because this type is not included in the model for the context. However, the model contains an entity type with the same name in a different namespace: 'ABC.Infrastructure.Models.User'.

It will be resolved if I can able to map the domain entity to the infrastructure entity in the above Repository implementation.
In the above implementation, the T is the ABC.Domain.Entities.User, not the ABC.Infrastructure.Models.User. I can't pass the ABC.Infrastructure.Models.User from the Application layer ( because I can't add a reference to the Infrastructure layer in Application layer) due to the rule Clean Architecture all dependencies flow inwards and Core has no dependency on any other layer.

Please help me to map the incoming domain entity with the infrastructure entity in the above repository implementation so that I can use these general methods for other entity operations as well.

@iayti .. Please do the needful.

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.