An enterprise-grade IoT monitoring system for temperature and humidity control, built with Spring Boot and modern security practices.
SafeCap is a RESTful API platform designed to monitor and alert on environmental conditions through IoT devices. The system provides real-time tracking, automated alerting, and historical data analysis for temperature-sensitive and humidity-sensitive environments.
Key Features:
- Secure JWT-based authentication with BCrypt password encryption
- Real-time IoT device monitoring and management
- Automated alert generation based on configurable thresholds
- RESTful API with OpenAPI 3.0 documentation
- Horizontal scalability with stateless architecture
- Comprehensive audit logging
- Java 17 - LTS version with modern language features
- Spring Boot 3.1.0 - Application framework
- Spring Security 6.1.0 - Authentication and authorization
- Spring Data JPA - Data persistence layer
- JWT (jjwt 0.11.5) - Token-based authentication
- BCrypt - Password hashing algorithm
- Oracle Database - Primary production database
- H2 Database - In-memory database for testing
- SpringDoc OpenAPI 3 - API documentation and Swagger UI
- Maven 3.8+ - Dependency management and build automation
- JDK 17 or higher
- Maven 3.8+
- Oracle Database (or H2 for development/testing)
git clone https://github.com/SouzaEu/SafeCap.git
cd SafeCapCopy the example environment file and configure your database credentials:
cp .env.example .envEdit src/main/resources/application.properties with your database settings.
mvn clean installmvn spring-boot:runThe API will be available at http://localhost:8080
Navigate to http://localhost:8080/swagger-ui.html for interactive API documentation.
SafeCap/
├── src/
│ ├── main/
│ │ ├── java/com/safecap/
│ │ │ ├── config/ # Security, CORS, JWT configuration
│ │ │ ├── controller/ # REST API endpoints
│ │ │ ├── dto/ # Data Transfer Objects
│ │ │ ├── exception/ # Custom exception handling
│ │ │ ├── model/ # JPA entities
│ │ │ ├── repository/ # Data access layer
│ │ │ └── service/ # Business logic
│ │ └── resources/
│ │ └── application.properties
│ └── test/ # Unit and integration tests
├── pom.xml # Maven dependencies
├── Dockerfile # Container configuration
└── docker-compose.yml # Multi-container setup
POST /api/auth/register- Register new userPOST /api/auth/login- Authenticate and receive JWT token
GET /api/dispositivos- List all devicesPOST /api/dispositivos- Create new deviceGET /api/dispositivos/{id}- Get device detailsPUT /api/dispositivos/{id}- Update deviceDELETE /api/dispositivos/{id}- Remove device
GET /api/alertas- List all alertsPOST /api/alertas- Create alertGET /api/alertas/{id}- Get alert detailsGET /api/alertas/dispositivo/{id}- Get alerts by device
For complete API documentation, visit the Swagger UI endpoint when running the application.
# Database Configuration
DB_URL=jdbc:oracle:thin:@localhost:1521:xe
DB_USERNAME=your_username
DB_PASSWORD=your_password
# JWT Configuration
JWT_SECRET=your-secret-key-here
JWT_EXPIRATION=86400000
# Application Configuration
SERVER_PORT=8080- Temperature Range: -10°C to 80°C
- Humidity Range: 0% to 100%
- Password: Minimum 6 characters
- Email: Valid RFC 5322 format
This application implements multiple security layers:
- Authentication: JWT-based stateless authentication
- Authorization: Role-based access control (RBAC)
- Password Security: BCrypt hashing with salt
- SQL Injection Prevention: Parameterized queries via JPA
- CORS Configuration: Configurable cross-origin resource sharing
- Input Validation: Bean Validation (JSR 380)
Run the test suite:
mvn testRun with coverage report:
mvn clean test jacoco:reportdocker build -t safecap:latest .
docker run -p 8080:8080 safecap:latestdocker-compose up -dThis project follows standard Java conventions and Spring Boot best practices.
main- Production-ready codedevelop- Integration branchfeature/*- New featuresbugfix/*- Bug fixeshotfix/*- Production hotfixes
Follow Conventional Commits:
feat: add device batch import
fix: resolve JWT expiration issue
docs: update API documentation
test: add integration tests for alerts
- Stateless architecture enables horizontal scaling
- Database connection pooling with HikariCP
- Lazy loading and query optimization with JPA
- Caching strategies for frequently accessed data
The application uses SLF4J with Logback for structured logging:
- Application logs:
logs/application.log - Error logs:
logs/error.log
We welcome contributions! Please see CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
For detailed architecture documentation, see ARCHITECTURE.md.
For questions and support, please open an issue in the GitHub repository.
Built with enterprise standards for production environments