The Equipment Status API is a simple, yet functional backend application that demonstrates how to keep track of equipment status updates and provide a RESTful API to interact with this data. The API is documented using Swagger and uses a lightweight SQLite database.
- Receive and store equipment status updates
- Retrieve the current status of any equipment
- API documentation and testing using Swagger UI
- .NET Core SDK 8.0 or later
- SQLite (included in the project)
- Entity Framework core
-
Clone the Repository
Clone the repository and navigate to the solution directory.
git clone https://github.com/p-koskey/EquipmentStatusAPI.git cd EquipmentStatusAPI
-
Restore dependencies
Restore the necessary NuGet packages.
dotnet restore
-
Build the project
Build the project to ensure all dependencies and configurations are correct.
dotnet build
Make sure you install dotnet-ef tool, if you don't have it installed, use the following command :
dotnet tool install --global dotnet-ef --version 8.*
-
Change the directory into the API directory
Navigate to the project directory.
cd EquipmentStatusAPI
-
Add the Initial Migration
Add the initial migration to set up your database schema.
dotnet-ef migrations add InitialCreate
-
Update the database
Apply the migration to update your database.
dotnet-ef database update
-
Run the application
Run the application using the following command:
dotnet run
Open your browser and navigate to http://localhost:5147/swagger/index.html to view and test the endpoints
The application uses SQLite as a lightweight, file-based database. SQLite is suitable for this project due to its simplicity and it's quite easy to setup.
Since it is a small project, a traditional layered architecture was used. This architecture has the following layers:
- Controllers: Handle HTTP requests and responses.
- Services: Contain business logic.
- Repositories: Interact with the database.
- DTOs (Data Transfer Objects): Transfer data between layers and to/from the client.
This pattern promotes separation of concerns, making the application easier to maintain and extend.
Unit tests are included to ensure the reliability of the API endpoints.
-
Change the directory into the EquipmentStatusAPI.Tests directory
Navigate to the test project
cd EquipmentStatusAPI.Tests
-
Run the Tests
Run the tests using the following command:
dotnet test