Code Monkey home page Code Monkey logo

minimalapiarchitecture's Introduction

Minimal API Vertical Slice Architecture

This project is an experiment trying to create a solution template with Minimal APIs and Carter.

Technologies and patterns used

Common design principles

  • Separation of concerns
  • Encapsulation
  • Explicit dependencies
  • Single responsibility
  • Persistence ignorance*

Getting started

The easiest way to get started is using Visual Studio 2022 or installing the .NET 6 SDK with dotnet run.

Database Migrations

To create a new migration with dotnet-ef you first need to locate your API folder and then write the following:

dotnet ef migrations add <MigrationName> --project ..\Application\ -o Infrastructure\Persistence\Migrations

Aldo, you need to update the database:

dotnet ef database update

Overview

This project is an experiment trying to create a solution for Minimal APIs using Vertical Slice Architecture.

If you think this is highly coupled, the important thing is to minimize coupling between slices, and maximize coupling in a slice; if you need to change something (e.g. switching Entity Framework for Dapper), you only need to change the affected slices and not a big file with all of the data access.

If you want to learn more, the project is based on these resources:

API

Minimal API that only hosts the application and wires up all the dependencies

Application

This project contains all the core and infrastructure of the application. The intention is to separate the application by functionality instead of technical concerns.

Domain

This will contain all entities, enums, exceptions, interfaces, types, and logic specific to the domain layer (this layer is shared between all features).

We can have domain events, enterprise logic, value objects, etc. This layer (or folder in this project) has the same purpose according with DDD.

Infrastructure

This layer contains classes for accessing external resources. These classes should be based on interfaces only if we need them for testing. For example, Entity Framework is testable, and repositories are not needed. But if external services are called, we should abstract these classes for easy testing.

Features

This folder contains all the "slices" of functionality, and each slice does not overlap with other slices. If you need to change something, you only change a portion of a slice or, if new features are needed, you add code in new files which saves you from modifying large files (like repositories or services).

Credits

Inspired by:

minimalapiarchitecture's People

Contributors

isaacojeda 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.