Skip to content

dalvarado86/brockeragefirm

Repository files navigation

brockeragefirm

A backend challenge (GBM Software Engineer Challenge)

Technologies

  • ASP.NET Core 5
  • Entity Framework Core 5
  • MediatR
  • AutoMapper
  • FluentValidation

Getting Started

  1. Install the latest .NET 5 SDK
  2. Add SQLite extension in VS Code or SQLite/SQL Server Compact Toolbox in Visual Studio 2019 Community, to explore the database if you want.
  3. Navigate to API and run dotnet run to launch the API (ASP .NET Core Web API)

Database Configuration

The solution is configured to use Sqlite by default. Verify the UseSQLiteConnection connection string within appsettings.json points to a valid Sqlite instance. Also you can use SQL Server changing UseSQLite variable to false.

Database Migration

To use dotnet-ef for your migrations add the following flags to your command (values assume you are executing from the root folder)

  • --project Infrastructure/
  • --startup-project API/
  • --output-dir Persistence/Migrations

For example, to add a new migration from the root folder:

dotnet ef migrations add "MyMigration" --project Infrastructure/ --startup-project API/ --output-dir Persistence/Migrations

Then, you need update de database from the startup project (API)

dotnet ef database update

Important! It needs to remove all migrations when changing a database service.

Also, when the application is run for the first time it builds an automatic migration populating 2 test users:

Overview

Domain

This contains all business entities to the domain layer.

Application

This layer contains the application logic. It's dependent on the domain layer but has no dependencies on any other layer or project. This layer defines interfaces that are implemented by outside layers. For example, if the application needs to access a notification service, a new interface would be added to the application and implementation would be created within the infrastructure.

Infrastructure

This layer contains classes for accessing external resources such as persistence and identity services. These classes should be based (in most of the cases) on interfaces defined within the application layer. You can add other external resources as web services, SMTP, file system, etc. It's dependant on the application layer and has no other dependencies on any other layer or project.

API

This layer is a Web API based on ASP.NET Core 5. This layer depends on both the Application and Infrastructure layers, however, the dependency on Infrastructure is only to support dependency injection. Therefore only Startup.cs should reference Infrastructure.

Settings

Within appsettings.json you can configure:

  • Token key and its expiration in hours, although probably is better to use Secret Manager when your application is important and it will be uploaded to Github or another repository.
  • Market hours, setting the time open and close.

Postman

I added a JSON file to import directly a collection of requests in Postman. You can test the API starting with the login of one or both users. Each login request sets a global variable to save the token generated jose_token or maria_token. Use those tokens to authorize every request.

About

Web API, Clean Architecture, CQRS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published