Giter Club home page Giter Club logo

akhmelevtsov / demorentalrepairswebapi Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 1.55 MB

Single repository for multiple technology examples incorporated into .NET Core apps with clean architecture and DDD

Home Page: https://demorentalrepairswebmvc.azurewebsites.net

C# 86.50% HTML 13.17% CSS 0.27% JavaScript 0.06%
clean-architecture onion-architecture clean-code domain-driven-design asp-net-core-web-api asp-net-core-mvc asp-net-core-identity swagger-ui fluent-validation ef-core mongo-db azure-sql-database azure-cosmos-db azure-storage-queue azure-storage-table azure-functions azure-ad-b2c azure-ad-graph-api azure-app-service csharp

demorentalrepairswebapi's Introduction

DemoRentalRepairs

Description

The repo was started to create a Domain Driven Design example for a simple business workflow and to build it with ASP .NET Core Web API and Clean Architecture (Onion Architecture). Initially the core service used in-memory repository, then few more were added: SQL Server and Mongo DB locally and Azure SQL database, Azure Storage Table and Cosmos DB.

To demonstrate how Clean Architecture helps extend the application, ASP.NET Core MVC project that reuses core services was added. As the domain model requires user roles, the security concern was addressed in the core service layer and ASP.NET Core Identity was added with local SQL server database .

The next task was to publish the application to Azure. The MVC App migrated to Azure App Service and the two SQL Server databases to Azure SQL Database. To demonstrate the scaling capabilities of the cloud environment, the Notification service was turned into a microservice on Azure with Azure Functions App, Storage Queue and SendGrid. In the process, just two new implementations of the Notification and Email Client service were added with no changes to the core service behaviour.

Initial migration to Azure revealed some drawbacks - the pricing model for SQL database is not suitable to run demo app even at the lowest pricing tear. So, a new database repository for Azure Storage Tables was created to replace the Azure SQL Database repository, and ASP.NET Core Identity was replaced with Azure AD B2C. The ability to dynamically register user claims was achieved with help of MS Graph API

The development was supported with automated testing, otherwise it would be much more difficult to apply all those modifications. The first unit test was written to simulate 'happy path' - a use case that covers all interactions between domain entities to complete the workflow. Later this test was lifted to integration tests. Few integration tests were also created for email messaging with help of Slurp remote API service and for Azure functions with local Azure Storage emulator

Fig 1. Project dependency diagram

alt text

Domain Model

The domain model contains DDD classes, domain-level enumerations and validations built with the Fluent Validation library. The domain logic supports a simple workflow scenario:

1 Property manager (superintendent) registers a rental property 2 Tenant registers himself with the rental property 3.Tenant submits a service request 4.Superintendent either declines the request or assignes a service worker and schedules the service date 5.Worker either completes the request or rejects the work order 6. If the request is rejected, superintendent re-schedules it 7. If the request is done, superintendent closes it

The participants are notified by emails on any service request status change

Fig 2. Use Case Diagram

Fig 3. Service Request State Diagram

Core Services

Provide application services abstracted from a specific service implementation:

  • repository service to store service request status and participants' data
  • notification service to notify participants on every service request status change
  • user identity service to abstract working with identity/authorization

Infrastructure

Provides implementations for core interfaces.

Repository services:

  • In memory (POCO classes)
  • SQL server with EF core
  • Mongo DB
  • Cosmos DB with Mongo DB API
  • Azure Table Storage with Table API

Identity services:

  • Asp.Net Core Identity
  • Azure AD B2C

Notification Services:

  • Dummy service for turning notifications off
  • Slurper Email service for debugging emails
  • Azure SendGrid

ASP.NET Core MVC application

Simple client that allows users to register, login and interact with core services through the UI. Current version is here: https://demorentalrepairswebmvc.azurewebsites.net/

ASP.NET Core Web API

Utilizes the same core services for mobile or any other client HTTP calls

Azure Functions

Provide micro-services for building and sending the workflow emails

demorentalrepairswebapi's People

Contributors

akhmelevtsov avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

yinchinan010

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.