The OvenSimulator WebAPI is a .NET-based application designed to simulate oven operations. It leverages various libraries and frameworks such as FastEndpoints, Serilog, and OpenTelemetry for logging and monitoring, and integrates with AWS SQS for messaging.
The project is organized into several key components:
- Dotnetstore.OvenSimulator.WebAPI: The main WebAPI project.
- Dotnetstore.OvenSimulator.SharedKernel: Contains shared models, services, and constants.
- Dotnetstore.OvenSimulator.SDK: SDK for interacting with the WebAPI.
- Dotnetstore.OvenSimulator.WebAPI.Tests.Integration: Integration tests for the WebAPI.
- FastEndpoints: For creating fast and efficient API endpoints.
- Serilog: For structured logging.
- OpenTelemetry: For distributed tracing and monitoring.
- AWS SDK for .NET: For interacting with AWS services like SQS.
- HealthChecks: For monitoring the health of the application.
The application is configured using appsettings.json and environment variables. Key configurations include logging, health checks, and AWS settings.
Logging is set up using Serilog with console and OpenTelemetry sinks. The logging configuration is defined in the SetupLogging method in StartupApplicationExtensions.
Health checks are configured to provide insights into the application's health. The health check endpoint is /health, and it uses the HealthChecks.UI.Client for response formatting.
The temperature evolution is calculated using the following equation:
dT/dt = (P * (10000/C))/100 - K * (T - 25)
Where:
- T is the current temperature.
- P is the heater power percentage.
- C is the heat capacity.
- K is the heat loss coefficient.
- 25 represents ambient room temperature.
The Runge-Kutta method is used to solve this differential equation.
Error states alter the normal operation of the oven:
- Heater Failure: Sets the heater power to 0, simulating a complete malfunction.
- Gradual Heater Failure: Slowly decreases heater power over time.
- Intermittent Sensor Failure: Randomly alters temperature readings to simulate faulty sensors.
- Thermostat Issue: Temporarily alters the target temperature, creating erroneous readings.
This class contains extension methods for setting up the application.
- StartupApplication: Configures logging, adds services, and sets up the application pipeline.
- SetupLogging: Configures Serilog for logging.
- BuildApplication: Builds the WebApplication.
The entry point of the application, which calls StartupApplication to configure and run the application.
The project includes unit and integration tests to ensure the application behaves as expected.
Unit tests are written using xUnit and FluentAssertions. Example test classes include:
- AmazonSettingsTests
- BaseAuditableEntityTests
- DataSchemeConstantsTests
- StartupApplicationExtensionsTests
Integration tests are located in the Dotnetstore.OvenSimulator.WebAPI.Tests.Integration project and ensure that the application components work together correctly.
To run the application, use the following command:
dotnet run --project src/Dotnetstore.OvenSimulator.WebAPI
To build the project, use:
dotnet build
To run the tests, use:
dotnet test
The application can be deployed to any environment that supports .NET. Ensure that the necessary environment variables and configurations are set up before deployment.
This documentation provides an overview of the OvenSimulator WebAPI, including its structure, key components, and how to configure, run, and test the application. For more detailed information, refer to the source code and comments within the project.