This solution is comprised of REST APIs that enable users to manage ships and find the closest port to a given ship with estimated arrival time based on the ship's geolocation and velocity.
- C#
- .NET 6
- Entity Framework Core with Fluent API
- MediatR for CQRS pattern
- FluentValidation for request validation
- Swagger for API documentation
To set up and run the project, please follow these steps:
- Clone the repository from GitHub
- Open the solution file (ShipManagement.sln) in Visual Studio or your preferred IDE.
- Build the solution to restore the NuGet packages.
- Update the
database connection string
in theappsettings.json
file to point to a local or remote MySQL Server instance. - Run the following commands in the Package Manager Console to apply the database migrations and seed the initial port data: Update-Database
- Run the application using IIS Express or your preferred web server.
- Access the API documentation using the Swagger UI, which can be found at /swagger/index.html.
The solution includes the following API endpoints:
GET /api/ships
: Retrieves a list of all ships.POST /api/ships
: Creates a new ship.PUT /api/ships/{id}
: Updates an existing ship by ID.
GET /api/ports/closest
: Retrieves the closest port to a given ship with estimated arrival time based on the ship's geolocation and velocity.
The velocity is calculated in kilometers per hour (km/h) and the distance between ship and port is also in kilometers (km). Port data is initially seeded using a pre-defined list of ports. No REST API is required for creating ports. Port data can only be seeded via database migrations. The API does not handle authentication and authorization. These can be added as per requirements.
- Add Docker support for easier deployment
- Add unit tests and integration tests to improve code quality and reliability
- Create a CI/CD workflow to automatically build, test, and deploy the application.