Git Product home page Git Product logo

ykankaya / practical.cleanarchitecture Goto Github PK

View Code? Open in Web Editor NEW

This project forked from phongnguyend/practical.cleanarchitecture

0.0 1.0 0.0 7.35 MB

Sample Asp.Net Core 3.1 projects (+ Angular 9, React 16) which apply modern Clean Architecture, Domain-Driven Design, CQRS, Specification Pattern, Unit Testing, SOLID, Asp.Net Core Identity Custom Storage, Entity Framework Core, Identity Server 4, Blazor, Automated Testing With Selenium, Notification with SignalR, Tasks Scheduling with Hangfire, Health Checks, Security Headers, ...

C# 41.77% Dockerfile 2.10% Shell 0.16% HTML 24.29% CSS 1.59% PowerShell 0.08% JavaScript 26.38% TypeScript 3.63%

practical.cleanarchitecture's Introduction

Clean Architecture: Patterns, Practices, and Principles | Matthew Renze | Pluralsight

Database Centric vs Domain Centric Architecture

alt text

(open on draw.io)

Hexagonal Architecture

alt text

(open on draw.io)

Onion Architecture

alt text

(open on draw.io)

The Clean Architecture

alt text

(open on draw.io)

Classic Three-layer Architecture

alt text

(open on draw.io)

Modern Four-layer Architecture

alt text

(open on draw.io)

Layer Dependencies

alt text

(open on draw.io)

Layer Examples

alt text

(open on draw.io)

Solution Structure

alt text

How to Run:

Configure Database

  • Update Connection Strings:

    Project Configuration File Configuration Key
    ClassifiedAds.Migrator appsettings.json ConnectionStrings:ClassifiedAds
    ClassifiedAds.BackgroundServer appsettings.json ConnectionStrings:ClassifiedAds
    ClassifiedAds.GRPC appsettings.json ConnectionStrings:ClassifiedAds
    ClassifiedAds.IdentityServer appsettings.json ConnectionStrings:ClassifiedAds
    ClassifiedAds.NotificationServer appsettings.json
    ClassifiedAds.WebAPI appsettings.json ConnectionStrings:ClassifiedAds
    ClassifiedAds.WebMVC appsettings.json ConnectionStrings:ClassifiedAds
    ClassifiedAds.GraphQL appsettings.json ConnectionStrings:ClassifiedAds
    ClassifiedAds.Ocelot appsettings.json
  • Run Migration:

    • Option 1: Using dotnet cli:
      • Install dotnet-ef cli:
        dotnet tool install --global dotnet-ef --version="3.1"
        
      • Navigate to ClassifiedAds.Migrator and run these commands:
        dotnet ef migrations add Init --context AdsDbContext -o Migrations/AdsDb
        dotnet ef migrations add Init --context ConfigurationDbContext -o Migrations/ConfigurationDb
        dotnet ef migrations add Init --context PersistedGrantDbContext -o Migrations/PersistedGrantDb
        dotnet ef database update --context AdsDbContext
        dotnet ef database update --context ConfigurationDbContext
        dotnet ef database update --context PersistedGrantDbContext
        
    • Option 2: Using Package Manager Console:
      • Set ClassifiedAds.Migrator as StartUp Project
      • Open Package Manager Console, select ClassifiedAds.Migrator as Default Project
      • Run these commands:
        Add-Migration -Context AdsDbContext Init -OutputDir Migrations/AdsDb
        Add-Migration -Context ConfigurationDbContext Init -OutputDir Migrations/ConfigurationDb
        Add-Migration -Context PersistedGrantDbContext Init -OutputDir Migrations/PersistedGrantDb
        Update-Database -Context AdsDbContext
        Update-Database -Context ConfigurationDbContext
        Update-Database -Context PersistedGrantDbContext
        

Configure Storage

  • Open ClassifiedAds.WebMVC/appsettings.json and jump to Storage section.

    "Storage": {
      "Provider": "Local",
    },
  • Use Local Files:

    "Storage": {
      "Provider": "Local",
      "Local": {
        "Path": "E:\\files"
      },
    },
  • Use Azure Blob:

    "Storage": {
      "Provider": "Azure",
      "Azure": {
        "ConnectionString": "xxx",
        "Container": "classifiedadds"
      },
    },
  • Use Amazon S3:

    "Storage": {
      "Provider": "Amazon",
      "Amazon": {
        "AccessKeyID": "xxx",
        "SecretAccessKey": "xxx",
        "BucketName": "classifiedadds",
        "RegionEndpoint": "ap-southeast-1"
      }
    },

Configure Message Broker

  • Open ClassifiedAds.WebMVC/appsettings.json and jump to MessageBroker section.

    "MessageBroker": {
      "Provider": "RabbitMQ",
    }
  • Use RabbitMQ

    "MessageBroker": {
      "Provider": "RabbitMQ",
      "RabbitMQ": {
        "HostName": "localhost",
        "UserName": "guest",
        "Password": "guest",
        "ExchangeName": "amq.direct",
        "RoutingKey_FileUploaded": "classifiedadds_fileuploaded",
        "RoutingKey_FileDeleted": "classifiedadds_filedeleted",
        "QueueName_FileUploaded": "classifiedadds_fileuploaded",
        "QueueName_FileDeleted": "classifiedadds_filedeleted"
      },
    }
  • Use Kafka:

    "MessageBroker": {
      "Provider": "Kafka",
      "Kafka": {
        "BootstrapServers": "localhost:9092",
        "Topic_FileUploaded": "classifiedadds_fileuploaded",
        "Topic_FileDeleted": "classifiedadds_filedeleted"
      },
    }
  • Use Azure Queue Storage:

    "MessageBroker": {
      "Provider": "AzureQueue",
      "AzureQueue": {
        "ConnectionString": "xxx",
        "QueueName_FileUploaded": "classifiedadds-fileuploaded",
        "QueueName_FileDeleted": "classifiedadds-filedeleted"
      },
    }
  • Use Azure Service Bus:

    "MessageBroker": {
      "Provider": "AzureServiceBus",
      "AzureServiceBus": {
        "ConnectionString": "xxx",
        "QueueName_FileUploaded": "classifiedadds_fileuploaded",
        "QueueName_FileDeleted": "classifiedadds_filedeleted"
      }
    }

Set Startup Projects

alt text

Run or Debug the Solution

How to Run on Docker Containers:

Application URLs:

Project Launch URL Docker Container URL Docker Container URL
BackgroundServer https://localhost:44318 http://localhost:9004 http://host.docker.internal:9004
Blazor https://localhost:44331 http://localhost:9008 http://host.docker.internal:9008
GRPC https://localhost:5001 https://localhost:9005 https://host.docker.internal:9005
IdentityServer https://localhost:44367 http://localhost:9000 http://host.docker.internal:9000
NotificationServer https://localhost:44390 http://localhost:9001 http://host.docker.internal:9001
WebAPI https://localhost:44312 http://localhost:9002 http://host.docker.internal:9002
WebMVC https://localhost:44364 http://localhost:9003 http://host.docker.internal:9003
GraphQL https://localhost:44392 http://localhost:9006 http://host.docker.internal:9006
Ocelot https://localhost:44340 http://localhost:9007 http://host.docker.internal:9007

practical.cleanarchitecture's People

Contributors

phongnguyend avatar igor-toporet avatar qyperion 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.