Code Monkey home page Code Monkey logo

ssw.verticalslicearchitecture's Introduction

SSW Banner

๐Ÿค” What is it?

An enterprise ready solution template for Vertical Slice Architecture. This template is just one way to apply the Vertical Slice Architecture.

Read more on SSW Rules to Better Vertical Slice Architecture

Learn

Vertical Slice Architecture: How Does it Compare to Clean Architecture | .NET Conf 2023

๐ŸŽ‰ Getting Started

To install the template from NuGet.org run the following command:

dotnet new install SSW.VerticalSliceArchitecture.Template

Then create a new solution:

mkdir Sprout
cd Sprout

dotnet new ssw-vsa

Finally, to update the template to the latest version run:

dotnet new update

๐Ÿ“š Faster Development

To speed up development there is a dotnet new template to create a full Vertical Slice.

dotnet new ssw-vsa-slice -f Student

-f or --feature where the feature name is the singular name of the feature.

Of course, there are always exceptions where appending an 's' is not enough. For example, Person becomes People and Child becomes Children.

For this, use the optional parameter:

dotnet new ssw-vsa-slice -f Person -fp People

optional: -fp or --feature-plural where the feature name is the plural name of the feature.

This creates everything you need to get started with a new feature.

  • Full CRUD endpoints
  • CQRS
    • missing EventHandlers/ folder as this is more uncommon
    • provides Events/ as a folder to demonstrate how to trigger side effects
  • Basic REPR pattern (i.e., Request, an Endpoint, and a Response)
  • Adds a new Entity
  • Basic DDD pattern - the 'Complete' method on the entity shows adding Domain events and using Result objects instead of exceptions for validation
  • Adds a DbSet to the DbContext
  • Adds EF Core Entity Type Configuration
  • Adds a Repository

While there is a small amount of code to remove, it is better to push you towards the pit of success, than allow inconsistency.

๐Ÿ“ Architecture

graph TD;
    subgraph ASP.NET Core Web App
        subgraph Slices
            A[Feature A]
            B[Feature B]
        end
        Slices --> |depends on| Common
        Host --> |depends on| Common
        Host --> |depends on| Slices
        ASPNETCore[ASP.NET Core] --> |uses| Host
    end

    Common[Common]
Loading

โœจ Features

  • C# 12
  • .NET 8
  • ASP.NET Core
  • Minimal APIs
  • EF Core
  • Swagger UI

ssw.verticalslicearchitecture's People

Contributors

danielmackay avatar dependabot[bot] avatar hhko avatar hona avatar mattparkerdev 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

ssw.verticalslicearchitecture's Issues

Apply model config from assembly

Change code to

namespace TempusHub.API.Common;

public partial class AppDbContext : DbContext
{
    public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }

    // ๐Ÿ‘‡ New code
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.ApplyConfigurationsFromAssembly(typeof(AppDbContext).Assembly);
    }
    // ๐Ÿ‘† New code
}

Fast command for Tests Core.Unit

Maybe something like dotnet new ssw-vsa-slice -t (test) Student

And this add
Features

  • Student
    • Models

Its only an idea maybe something else :=)

๐Ÿงช Architecture Tests to Enforce Constraints

ACs

  1. Add architecture tests that will detect if classes are not referencing the correct things.
  2. The tests will be enforced by namespaces
  3. Restrict that
    a. Application Cannot reference Infrastructure
    b. Domain cannot Reference Infrastructure
    c. Domain cannot Reference Application

Swagger UI Fails to Load on Startup

With a fresh project template, after a clean build and launch of the API, the Swagger UI fails to launch properly due to an extra forward slash in the URL (see screenshot):

image

It appears that the "launchUrl" property in the launchSettings should be edited to have the forward slash removed.

image

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.