Giter VIP home page Giter VIP logo

desenvolvedor-io / dev-store Goto Github PK

View Code? Open in Web Editor NEW
1.0K 46.0 185.0 7.27 MB

A microservices e-commerce reference application built with ASP.NET 6

Home Page: https://devstore.academy

License: MIT License

Dockerfile 1.28% C# 81.75% HTML 15.19% CSS 0.21% JavaScript 1.57%
asp-net clean-architecture clean-code cqrs design-patterns domain-driven-design hexagonal-architecture microservices solid dotnet-6 kubernetes grpc rabbitmq

dev-store's Introduction

logo logo

DevStore - A microservices e-commerce reference application built with ASP.NET 6

A real-world reference application powered by desenvolvedor.io Brasil implementing the most common and used technologies to share with the technical community the best way to develop full and complex applications with .NET


This project was inspired by EShopOnContainers, however the real motivation was to build it by "our way".
The EShopOnContainers is an awesome project, however the code has some "bad smells". We found it difficult to start learning/using EShopOnContainers compared to DevStore. We like to think of the DevStore as a simplified (but no less complex) version and written with more care in code and small details. We also focused only on the Web architecture with ASP.NET.

Give a Star! โญ

If you liked the project or if DevStore is helping you, please give us a star ;)

DevStore

Want to learn everything to build an app like this? ๐ŸŽ“

Check this online courses at desenvolvedor.io (only in portuguese)

Technologies / Components implemented

  • .NET 6

    • ASP.NET MVC Core
    • ASP.NET WebApi
    • ASP.NET Minimal API
    • ASP.NET Identity Core
    • Refresh Token
    • JWT with rotactive public / private key
    • GRPC
    • Background Services
    • Entity Framework Core 6
  • Components / Services

    • RabbitMQ
    • EasyNetQ
    • Refit
    • Polly
    • Bogus
    • Dapper
    • FluentValidator
    • MediatR
    • Swagger UI with JWT support
    • NetDevPack
    • NetDevPack.Identity
    • NetDevPack.Security.JWT
  • Hosting

    • IIS
    • NGINX
    • Docker (with compose)

Architecture:

Complete architecture implementing the most important and used concerns as:

  • Hexagonal Architecture
  • Clean Code
  • Clean Architecture
  • DDD - Domain Driven Design (Layers and Domain Model Pattern)
  • Domain Events
  • Domain Notification
  • Domain Validations
  • CQRS (Imediate Consistency)
  • Retry Pattern
  • Circuit Breaker
  • Unit of Work
  • Repository
  • Specification Pattern
  • API Gateway / BFF

Architecture Overview

The entire application is based in an unique solution with 7 API's and one web application (MVC)

read before


This is a reference application, each microservice has its own database and represents a bounded context (DDD concept). There is a BFF / API Gateway to manage the Basket / Order / Payment requests and data structure from responses.

read before


Getting Started

You can run the DevStore project on any operating system. Make sure you have installed docker in your environment. (Get Docker Installation)

Clone DevStore repository and navigate to the /Docker folder and then:

If you just want run the DevStore application in your Docker enviroment:

docker-compose up

If you want to build the local images and run the DevStore application in your Docker enviroment:

This compose will provide one database container each API service.

docker-compose -f docker-compose-local.yml up --build

If you prefer save machine resources use the light local compose:

This compose will provide just one database container for all API services.

docker-compose -f docker-compose-local-light.yml up --build

If you want run locally with VS/VS Code:

You will need:

  • Docker
  • SQL instance (or container)
  • RabbitMQ

So you can edit the Docker compose to just run the database and queue dependencies and save your time.

If you want Visual Studio with F5 and debug experience:

  • You will need at least Visual Studio 2022 and .NET 6.
  • The latest SDK and tools can be downloaded from https://dot.net/core
  • Setup the solution to start multiple projects and hit F5

image


If you want Visual Studio Code experience:

  • Open the VS Code on root directory (solution file)
  • Create a new launch.json at VS Code debug section and use the configuration below to setup the option "Start all projects"
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "DevStore MVC WebApp",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/src/web/DevStore.WebApp.MVC/bin/Debug/net6.0/DevStore.WebApp.MVC.dll",
            "args": [],
            "cwd": "${workspaceFolder}/src/web/DevStore.WebApp.MVC",
            "console": "internalConsole",
            "stopAtEntry": false
        },
        {
            "name": "DevStore Billing API",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/src/services/DevStore.Billing.API/bin/Debug/net6.0/DevStore.Billing.API.dll",
            "args": [],
            "cwd": "${workspaceFolder}/src/services/DevStore.Billing.API",
            "console": "internalConsole",
            "stopAtEntry": false
        },
        {
            "name": "DevStore Catalog API",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/src/services/DevStore.Catalog.API/bin/Debug/net6.0/DevStore.Catalog.API.dll",
            "args": [],
            "cwd": "${workspaceFolder}/src/services/DevStore.Catalog.API",
            "console": "internalConsole",
            "stopAtEntry": false
        },
        {
            "name": "DevStore Customers API",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/src/services/DevStore.Customers.API/bin/Debug/net6.0/DevStore.Customers.API.dll",
            "args": [],
            "cwd": "${workspaceFolder}/src/services/DevStore.Customers.API",
            "console": "internalConsole",
            "stopAtEntry": false
        },
        {
            "name": "DevStore Identity API",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/src/services/DevStore.Identity.API/bin/Debug/net6.0/DevStore.Identity.API.dll",
            "args": [],
            "cwd": "${workspaceFolder}/src/services/DevStore.Identity.API",
            "console": "internalConsole",
            "stopAtEntry": false
        },
        {
            "name": "DevStore Orders API",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/src/services/DevStore.Orders.API/bin/Debug/net6.0/DevStore.Orders.API.dll",
            "args": [],
            "cwd": "${workspaceFolder}/src/services/DevStore.Orders.API",
            "console": "internalConsole",
            "stopAtEntry": false
        },
        {
            "name": "DevStore ShoppingCart API",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/src/services/DevStore.ShoppingCart.API/bin/Debug/net6.0/DevStore.ShoppingCart.API.dll",
            "args": [],
            "cwd": "${workspaceFolder}/src/services/DevStore.ShoppingCart.API",
            "console": "internalConsole",
            "stopAtEntry": false
        },
        {
            "name": "DevStore BFF Checkout",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/src/api-gateways/DevStore.Bff.Checkout/bin/Debug/net6.0/DevStore.Bff.Checkout.dll",
            "args": [],
            "cwd": "${workspaceFolder}/src/api-gateways/DevStore.Bff.Checkout",
            "console": "internalConsole",
            "stopAtEntry": false
        }
    ],
    "compounds": [
        {
            "name": "Start all projects",
            "configurations": [
                "DevStore MVC WebApp",
                "DevStore Billing API",
                "DevStore Catalog API",
                "DevStore Customers API",
                "DevStore Identity API",
                "DevStore Orders API",
                "DevStore ShoppingCart API",
                "DevStore BFF Checkout"
            ],
            "stopAll": true
        }
    ]
}   

Disclaimer

  • This is not an architectural template or bootstrap model for new apps
  • All implementations were made for the real world, but the goal is to share knowledge
  • Maybe you don't need many implementations included, try to avoid over-engineering

Pull-Requests

Open an issue and let's discuss! Do not submit PRs for undiscussed or unapproved features.

If you want to help us, choose an approved issue and implement it.

We are Online

See the project running on DevStore official instance

About

DevStore was proudly developed by desenvolvedor.ioโคBrasil team under the MIT license.

dev-store's People

Contributors

brunobritodev avatar eduardopires avatar jmoldyvan avatar lucasbk123 avatar ralmsdeveloper avatar semantic-release-bot 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

dev-store's Issues

Problem with generate-pfx

When generate-pfx tries to delete a file that does not exist in the certs folder, the certificate creation process is aborted.

[FEAT] Banner to show it's a demo project

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
A banner to show visitors the site is just a demo and not a real store. The banner must have a link to this repository.

Notifications Microservice

General Description

Create a Notifications Microservice responsible to manage all notifications (such as email, WhatsApp, SMS etc.) for order status changes, password changes etc.

Some Details

  • The others Microservices would communicate with this Microservice via Message Broker.
  • The WebApp would not access this Microservice.
  • It could use either a simple SMTP class or Send Grid.
  • The email templates could be in a Resource

Error 404 when adding product to the cart

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'home page'
  2. Select an product
  3. Click on 'Add to cart'
  4. See 404 error page

Expected behavior
When user click on add to cart the product should be added.

Screenshots
image

[BUG] Cannot use Add-Migrations

Describe the bug
When I try to use Add-Migration DbInit -context OrdersContext in project DevStore.Orders.Infra I got this error bellow:
image

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Package Manage Console'
  2. Select the project 'DevStore.Orders.Infra'
  3. Run the command 'Add-Migration DbInit -context OrdersContext'
  4. See error

Expected behavior
Generate migrations files

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 11
  • Visual Studio Community 2022

Additional context
Add any other context about the problem here.

SQL Server Timezone

When running from local machine at Sql Server on Docker some queries get broken because the TimeZone.

At PedidoAPI:
image

But there are items at Database:
image

So, sending the "DateTime.Now" from API Backend it works:

      public async Task<PedidoDTO> ObterUltimoPedido(Guid clienteId)
        {
            const string sql = @"SELECT
                                P.ID AS 'ProdutoId', P.CODIGO, P.VOUCHERUTILIZADO, P.DESCONTO, P.VALORTOTAL,P.PEDIDOSTATUS,
                                P.LOGRADOURO,P.NUMERO, P.BAIRRO, P.CEP, P.COMPLEMENTO, P.CIDADE, P.ESTADO,
                                PIT.ID AS 'ProdutoItemId',PIT.PRODUTONOME, PIT.QUANTIDADE, PIT.PRODUTOIMAGEM, PIT.VALORUNITARIO 
                                FROM PEDIDOS P 
                                INNER JOIN PEDIDOITEMS PIT ON P.ID = PIT.PEDIDOID 
                                WHERE P.CLIENTEID = @clienteId 
                                AND P.DATACADASTRO between DATEADD(minute, -30,  @Now) and @Now
                                ORDER BY P.DATACADASTRO DESC";

            var pedido = await _pedidoRepository.ObterConexao()
                .QueryAsync<dynamic>(sql, new { clienteId, Now = DateTime.Now });

            if (!pedido.Any())
                return null;

            return MapearPedido(pedido);
        }

Cart error when anonymous

When some anonymous user try to put some item into shopping cart receives an error.

The expected behaviour was redirect to login page.

[BUG] Error while trying to run the project with Docker

Describe the bug
I used to run this project without any issues for a while, to understand and learn some things. However, lately it has started to throw this error related to the encryption part. It seems like the project is not recognizing the location of the certificate, is there a way to bypass this or completely mitigate this error?

To Reproduce
Steps to reproduce the behavior:

  1. Update project to latest version in main branch
  2. Go to docker path
  3. With cmd/terminal execute docker-compose up
  4. Wait until all containers are up and running.
  5. See error Interop+Crypto+OpenSslCryptographicException: error:2006D080:BIO routines:BIO_new_file:no such file

Stacktrace
devstore-web-mvc-ecommerce | Unhandled exception. Interop+Crypto+OpenSslCryptographicException: error:2006D080:BIO routines:BIO_new_file:no such file devstore-web-mvc-ecommerce | at Interop.Crypto.CheckValidOpenSslHandle(SafeHandle handle) devstore-web-mvc-ecommerce | at Internal.Cryptography.Pal.OpenSslX509CertificateReader.FromFile(String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags) devstore-web-mvc-ecommerce | at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags) devstore-web-mvc-ecommerce | at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password) devstore-web-mvc-ecommerce | at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Certificates.CertificateConfigLoader.LoadCertificate(CertificateConfig certInfo, String endpointName) devstore-web-mvc-ecommerce | at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.LoadDefaultCert() devstore-web-mvc-ecommerce | at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Reload() devstore-web-mvc-ecommerce | at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Load() devstore-web-mvc-ecommerce | at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken) devstore-web-mvc-ecommerce | at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication1 application, CancellationToken cancellationToken) devstore-web-mvc-ecommerce | at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken) devstore-web-mvc-ecommerce | at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken) devstore-web-mvc-ecommerce | at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) devstore-web-mvc-ecommerce | at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) devstore-web-mvc-ecommerce | at Program.<Main>$(String[] args) in /src/web/DevStore.WebApp.MVC/Program.cs:line 22 devstore-web-mvc-ecommerce | at Program.<Main>(String[] args) devstore-web-mvc-ecommerce exited with code 139

Expected behavior
Run all services correctly and have no issues with openssl.

Screenshots
print1
print2

Desktop (please complete the following information):

  • OS: [Win 10, Zorin OS, Win 11]

Aditional Info
I tried on several different computers and different OS's believing that it was only in my environment or if it was some wrong configuration of my docker, but on these 4 computers it gave the same error.

Remove Dapper

There are some projects that are using Dapper. E.g ProductRepository.

We are seeking to replace with EF Core. To be a database agnostic.

Wrong syntax in light compose file

There is a problem in docker-compose-local-light.yml compose file, that causes unable to run the app. As the image below shows the ports is the main problem.

image

Just remove it and it will run perfectly.

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.