This guide will help you set up the NexusHome IoT platform for local development.
- .NET 8.0 SDK or later
- Docker and Docker Compose
- SQL Server (or use Docker)
- Redis (or use Docker)
- MQTT Broker (or use Docker)
- Git
- Visual Studio 2022 or VS Code
- Azure Data Studio or SQL Server Management Studio
- Redis CLI
- MQTT Explorer
git clone https://github.com/aaron-seq/NexusHome_IoT.git
cd NexusHome_IoT# Copy the example environment file
cp .env.example .env
# Edit .env and update the following REQUIRED values:
# - SQLSERVER_SA_PASSWORD (strong password for SQL Server)
# - REDIS_PASSWORD (password for Redis)
# - JwtAuthentication__SecretKey (generate with: openssl rand -base64 32)
# - MqttBroker__Password (password for MQTT broker)Important Security Note: Never commit the .env file. It's already in .gitignore.
# Start all services using Docker Compose
make docker-up
# Or manually:
docker-compose up -d
# Check service health
docker-compose psWait for all services to show "healthy" status (may take 30-60 seconds).
# Install EF Core tools (first time only)
make install-tools
# Run migrations
make migrate
# The database will be automatically seeded with demo data# Development mode with hot reload
make dev
# Or standard run:
dotnet runThe application will start at http://localhost:5000
Open your browser and navigate to:
- Swagger UI: http://localhost:5000/swagger
- Health Check: http://localhost:5000/health/ready
- API Status: http://localhost:5000/api/v2/system/status
WARNING: These credentials are for DEVELOPMENT ONLY and must be changed in production.
- Username:
admin - Password:
Admin123!
# Run all tests
make test
# Run tests in watch mode
make watch-test
# Run tests with coverage
dotnet test --collect:"XPlat Code Coverage"# Format code
make format
# Check formatting (CI uses this)
make lint# Create a new migration
dotnet ef migrations add MigrationName
# Update database
make migrate
# Reset database (WARNING: deletes all data)
make migrate-reset
# Seed database manually
make db-seed# Start services
make docker-up
# Stop services
make docker-down
# View logs
make docker-logs
# Rebuild and restart
docker-compose up -d --buildAll configuration is managed through environment variables. See .env.example for the complete list.
ConnectionStrings__DefaultConnection- Database connection stringSQLSERVER_SA_PASSWORD- SQL Server SA passwordREDIS_PASSWORD- Redis passwordJwtAuthentication__SecretKey- JWT signing key (256-bit)MqttBroker__Password- MQTT broker password
WEATHER_API_KEY- OpenWeatherMap API keySeq__ApiKey- Seq logging API keyCORS__AllowedOrigins- Allowed CORS origins
appsettings.json- Base configurationappsettings.Development.json- Development overrides.env- Environment-specific secrets (not committed)Configuration/mosquitto.conf- MQTT broker settings
GET /api/device- List all devicesGET /api/device/{deviceId}- Get device detailsPOST /api/device/{deviceId}/toggle- Toggle device statePOST /api/device/telemetry- Submit telemetry dataGET /api/device/{deviceId}/energy- Get energy consumption
GET /api/energy/consumption- Total consumption summaryGET /api/energy/cost- Cost analysis and breakdownGET /api/energy/forecast- Energy usage predictions
GET /api/automation/rules- List automation rulesPOST /api/automation/rules- Create new ruleGET /api/automation/rules/{id}- Get rule detailsPUT /api/automation/rules/{id}- Update ruleDELETE /api/automation/rules/{id}- Delete rule
GET /health/live- Liveness probeGET /health/ready- Readiness probeGET /api/v2/system/status- System status
All API endpoints (except health checks) require JWT authentication.
# Example: Get JWT token (dev only)
curl -X POST http://localhost:5000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"Admin123!"}'
# Use token in subsequent requests
curl -X GET http://localhost:5000/api/device \
-H "Authorization: Bearer YOUR_TOKEN_HERE"# Check SQL Server is running
docker ps | grep sqlserver
# Check SQL Server logs
docker logs nexushome-sqlserver
# Test connection
docker exec -it nexushome-sqlserver /opt/mssql-tools/bin/sqlcmd \
-S localhost -U sa -P "$SQLSERVER_SA_PASSWORD" -Q "SELECT 1"# Check Redis is running
docker ps | grep redis
# Test Redis connection
docker exec -it nexushome-redis redis-cli -a "$REDIS_PASSWORD" ping# Check MQTT broker is running
docker ps | grep mqtt
# Test MQTT connectivity
mosquitto_pub -h localhost -t "nexushome/test" -m "Hello" -u nexususer -P "$MQTT_PASSWORD"
mosquitto_sub -h localhost -t "nexushome/#" -v -u nexususer -P "$MQTT_PASSWORD"- Check all required environment variables are set
- Verify database migrations are up to date:
dotnet ef migrations list - Check logs:
docker logs nexushome-app - Verify port 5000 is not in use:
lsof -i :5000
# Remove all containers and volumes (WARNING: deletes data)
docker-compose down -v
# Rebuild images from scratch
docker-compose build --no-cache
# Check disk space
docker system df
# Prune unused resources
docker system prune -a# Subscribe to all topics
mosquitto_sub -h localhost -t "nexushome/#" -v
# Publish a test message
mosquitto_pub -h localhost -t "nexushome/devices/test-01/state" -m '{"power":"on"}'- Download from: http://mqtt-explorer.com/
- Connect to
localhost:1883 - Username:
nexususer(or as configured) - Password: From your
.envfile
See CONTRIBUTING.md for guidelines.
- Run tests:
make test - Format code:
make format - Check linting:
make lint - Update documentation if needed
- Add/update tests for new features
- API Documentation (when running)
- Architecture Documentation
- Security Guidelines
- Contributing Guidelines
- Code of Conduct
- Issues: https://github.com/aaron-seq/NexusHome_IoT/issues
- Discussions: https://github.com/aaron-seq/NexusHome_IoT/discussions
- Email: support@nexushome.tech
See LICENSE for details.