Skip to content

sashamarfuttech/super-note-api

Repository files navigation

.NET 8 REST API Project That Implements Clean Architecture and Domain-Driven Design.

Give a Star! ⭐

If the project has been useful to you, please give it a star. Thank you!

Description

SuperNote is the initial version of a note-taking app (such as OneNote or Notion). There is no front-end at this time. The project contains a few REST API endpoints:

image

Technologies & Libraries:

  1. ASP.NET Core 8.0
  2. Entity Framework Core 8
  3. FastEndpoints 5.22.0
  4. MediatR 12.2.0
  5. FluentResults 3.15
  6. Optional 4.0

Databases:

  1. PostgreSQL
  2. Entity Framework Core 8 In-Memory Database

How do I run the application?

  1. Check out source code from the repository.
  2. Run SuperNote.WebApi project.

You'll see Swagger.

By default, the project is configured to use the Entity Framework In Memory database. So the above two steps will be enough if you want to have a quick play around with the app.

If you want to use a real database, then

  1. Create empty database.
  2. Go to the appsettings.json file and set the connection string in the Sql:ConnectionString section.
  3. Run the migrations defined in the SuperNote.DataAccess project.
  4. Run SuperNote.WebApi project.

The application uses a PostgreSQL database, but it can be easily changed it in the DataAccessServices.cs file if needed.

Project Structure

The project implements a clean architecture. Here's its structure:

Screenshot 2024-02-06 193709

Now let's talk about each project separately.

SuperNote.Domain

The domain layer contains domain entities, domain events, repository interfaces, domain errors, and other core application logic.

SuperNote.Application (Use cases)

The application layer implements the SuperNote application use cases using Commands and Queries. It also implements event handlers for domain events.

In addition, the application layer is where abstractions for caching, messaging, authentication, email notifications, and so on are placed.

SuperNote.Infrastructure

Currently, the infrastructure layer contains a single project, which is DataAccess. This project implements repositories, migrations, and other things related to data access.

In addition, the infrastructure layer must implement the caching, messaging, authentication, email notification abstractions that are defined in the application layer.

SuperNote.WebApi (Presentation)

This is the entry point to the application. It implements a set of REST APIs that clients can use to interact with the application.

Key Patterns

REPR Design Pattern

REPR stands for Request, an Endpoint, and a Response. The pattern enforces the Single Responsibility Principle for your endpoints. The basic idea is that each request is handled by a separate class.

Result Pattern

There are two fundamental ways for handling invalid input in your domain: throw an exception or return an object indicating the error. The SuperNote application uses the second approach, returning a Result object from the domain and application layers. You can read about the reasons for choosing one or the other here, here or here.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages