Created By: Pablo Christian Pereira Nazareth Description: A Star Wars API integration application using C# dotnet.
Overview
Using the Backends for Frontends pattern and the StarWars API (https://swapi.dev) create a simple web API to support the following end-user functionality:
- A user should be able to view a list of Starships, the user should be able to select a Starship
manufacturer
from a dropdown to filter the list of Starships to the selectedmanufacturer
. If nomanufacturer
is selected display all starships in the list.
Notes and Technical Requirements
- ✔ The web API should require Authentication
- ✔ The web API should respond with JSON data
- ✔ Client libraries exist for the StarWars API. We request that you do not use these libraries to interact with the StarWars API
- ✔ Open-source packages other than the StarWars client libraries can be used but are not required to complete this assignment.
Swagger documentation showing the API routes:
These are all the technologies and patterns used to develop this application
- C# .NET 6.0 Web API
- MediatR
- FluentValidation
- AutoMapper
- Xunit
- FluentAssertions
- Moq
- ASP.NET Core Authentication JwtBearer
- Refit
Patterns and Techniques
- TDD (Test Driven Development)
- DDD (Domain Driven Design)
- CQRS (Command Query Responsibility Segregation)
- Middlewares: Error, Request and Response
- Dependency Injection
- Domain Notification
- Domain Message
- Domain Exception
- Domain Helper
The project solution was based on DDD (Domain Driven Design) concept.
I recommend following the option 01, so you won't need to install and run all the other tools needed for the project to work.
Option 01: Run in Containers To run the local application in containers, you will need to download and install the following:
Option 02: Outside Containers If you want to run the project outside containers, you must also have the following:
To execute the project, follow the steps below:
Option 01: Run in Containers
- Run Docker Desktop.
- Open the command prompt (cmd), navigate inside the project "\src" folder, and type: "docker-compose build" to build the containers (this is only necessary the first time).
- Type "docker-compose up -d" to start the application containers.
- Now you can view the application:
- To view the Web Api Swagger documentation, navigate to http://localhost:8082/swagger
to stop the execution of the containers, type "docker-compose down"
Option 02: Outside Containers
- Run SQLServer(port 1435).
- Open the command prompt (cmd), navigate inside the project "\src" folder, and type: "run.bat"
- This script will run the projects and open the browsers.
Note: just in case for some reason the database doesn't create, in Visual Studio Navigate to Tools -> Nuget Package Manager -> Package Manage Console, and run the command "Add-Migration InitialCreate"
Follow the steps below to retrieve data from the API:
-
After you open the swagger page, you must first register using the Identity Register Route (api/identity/register), to receive a valid token.
-
With this token, you can use the "Authorize" button from swagger, and insert the token.
-
After being authorized, you can call the starships route(api/starships) to retrieve the data.
Note: in case you have already registered before, you can use the Identity Login Route (api/identity/login)
This section is used to self-critique to reflect and write what would be good to improve over time:
- Performance
- Cache service to store the lattest and common requests for better performance.
- Scalability
- Use of AWS ECS (Elastic Container Service) or EKS (Elastic Kubernetes Service) to manage the Docker Containers.
- Use of AWS Auto Scaling to manage scalability of instances by CPU usage. (Above 70% CPU usage would create new instance).
- Load Balancing
- Use of AWS Load Balancer to balance the requests between the containers (active instances).
- Tests
- Implement remaining tests left for the other classes.
- Implement integration tests to test end-to-end requests.
- Implement K6 to execute load tests so we can monitor our application to see if its going to be able to handle the expected number of users and requests per second.