This project is a decision-making aid application, using a control tower to visualize data from IoT devices in real-time. The application allows the registration and management of IoT devices through a collaborative platform.
The project follows an architecture based on Clean Architecture and DDD (Domain-Driven Design), promoting clear separation of responsibilities between different layers of the application. The project structure is divided into five main layers:
- API (Presentation Layer): This layer is responsible for handling HTTP requests, receiving and sending data to the client. Controllers, DTO (Data Transfer Objects) models, and mappings between entities and DTOs are defined here.
- Application Layer: This layer contains the business logic of the application. It implements the use cases of the application, orchestrating operations between entities and services.
- Domain Layer: This layer represents the core of the application, containing domain entities, repository interfaces, and service contract definitions. The business rules of the application are established here. Currently, we are using DDD specifically in the
Device
andUser
entities. - Infrastructure Layer: This layer is responsible for the concrete implementation of the interfaces defined in the domain. Data repositories, external services, and any infrastructure necessary for the application to function are implemented here.
- Infrastructure IoC (Inversion of Control): This layer is responsible for the configuration and dependency injection of the application. Dependencies are registered and the services to be used are configured here.
- ASP.NET Core 8: Web framework used to build the application's API.
- Entity Framework Core: ORM (Object-Relational Mapper) used to map domain objects to the relational database.
- Swagger: Tool used to document and test the application's API.
- JWT (JSON Web Tokens): Authentication system used to secure the API endpoints.
- Identity: Framework used for identity management and user authentication.
- AutoMapper: Library used to map objects between different layers of the application automatically.
- Serilog: Library used for logging and event auditing in the application.
- SQL Server: Relational database used to store application data.
- FluentValidation: Library used to validate complex objects, ensuring data consistency before processing.
- NETCore.MailKit: Library used to send emails via SMTP with support for Google SMTP servers.
- CQRS (Command Query Responsibility Segregation): Architecture pattern used to separate command and query operations, improving scalability and flexibility.
- MediatR: Library for implementing the mediator pattern, used to decouple communication between application components.
- Dapper: Micro ORM used for data access, providing faster execution and lower overhead compared to full ORM frameworks.
- Redis: In-memory data structure store used to cache frequently accessed data for improved performance.
- RabbitMQ: Messaging broker used for asynchronous communication and message queuing.
- IoT Device Registration and Management: Allows the registration and control of devices connected to the platform.
- Real-Time Data Visualization: Provides an interface to monitor data collected by devices.
- Authentication and Authorization: Uses JWT and Identity to manage secure access to application resources.
- Logging and Auditing: Implemented with Serilog for efficient system operation monitoring.
- Data Validation: Using FluentValidation to ensure the integrity and validity of input data.
- Email Notifications: Utilizes NETCore.MailKit for sending email notifications via Google SMTP.
- Command Query Responsibility Segregation (CQRS): Architecture pattern used to separate command and query operations, improving scalability and flexibility. Implemented using ASP.NET Core 8, MediatR, and Dapper for efficient command and query handling.
- Messaging with RabbitMQ: Integrates RabbitMQ for asynchronous message queuing and communication between application components.
Device
- Description: Description of the device.
- Manufacturer: Manufacturer of the device.
- Url: Device URL.
- IsActive: Indicates whether the device is active.
- LastCommunication: Last communication of the device.
- IpAddress: Device IP address.
- Location: Location of the device.
- FirmwareVersion: Firmware version of the device.
- ManufactureDate: Manufacture date of the device.
- SerialNumber: Serial number of the device.
- ConnectionType: Connection type of the device.
- HealthStatus: Health status of the device.
- LastKnownStatus: Last known status of the device.
- Owner: Owner of the device.
- InstallationDate: Date of installation of the device.
- LastMaintenanceDate: Last maintenance date of the device.
- SensorType: Type of sensor in the device.
- AlarmSettings: Settings for device alarms.
- LastHealthCheckDate: Date of the last health check of the device.
- MaintenanceHistory: History of maintenance operations on the device.
User
- FullName: Full name of the user.
- DateOfBirth: Date of birth of the user.
- Gender: Gender of the user.
- Address: Address of the user.
- City: City of the user.
- State: State of the user.
- Country: Country of the user.
- PostalCode: Postal code of the user.
- Role: Role of the user.
- LastLogin: Last login date of the user.
- UpdateDate: Date of the last update of user information.
- RegistrationDate: Registration date of the user.
- LastPasswordChangeDate: Date of the last password change of the user.
- Device - User: Each device belongs to a user. The
UserId
property in theDevice
entity establishes this relationship as a foreign key referencing theId
property of theUser
entity.
To run the project locally, follow the instructions below:
- Ensure you have the .NET 8 SDK installed on your machine. You can download it here.
- Have Git installed on your machine to clone the repository. You can download it here.
- Have Docker installed on your machine. You can download it here.
- To install Redis here, you can run the following command:
docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:latest
- To install RabbitMQ here, you can run the following command:
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.13-management
- Open the terminal or command prompt.
- Clone this repository to your local machine using the command:
-
git clone https://github.com/Pedrolustosa/IoTControlTower.git
- Navigate to the cloned directory:
cd IoTControlTower
- Open Visual Studio 2022.
- Select "Open a Project or Solution" and navigate to the cloned directory.
- Select the solution file (.sln) and click "Open".
- Wait for Visual Studio to automatically restore NuGet packages.
- Press F5 to build and run the project.
- Open Visual Studio Code.
- Install the "C#" extension if not already installed.
- Open the project folder in Visual Studio Code.
- Visual Studio Code will automatically detect the .NET environment and offer to install necessary dependencies. Accept the installation.
- Open a terminal in Visual Studio Code and run the command:
dotnet run
- The project will be compiled and started.
The project folder structure is organized as follows:
- IoTControlTower.API: Contains the presentation layer with controllers, DTO models, and Swagger configuration.
- IoTControlTower.Application: Contains the application layer with services, mappings, and use cases.
- IoTControlTower.Domain: Contains the domain layer with entities, repository interfaces, and service contract definitions.
- IoTControlTower.Infrastructure: Contains the infrastructure layer with concrete implementations of repository interfaces and external services.
- IoTControlTower.Infrastructure.IoC: Contains the configuration and dependency injection of the application.
Please click the star (★) at the top of the repository page to favorite the project and follow its updates. This helps us know that you're interested in the project and motivates us to continue improving it for you and the community.