a1e95ec23e5f3b7a928042852bd3ce91cdef181f
Lambda-IoT Core
This repository contains a minimal Go REST service used as the backend for the Lambda-IoT project.
Repository: https://git.piskot.si/SeminarM2/lambdaiot-core
Features ✅
- HTTP API with health, greeting, auth, device CRUD, sensor creation, and MQTT ping
- JWT-based auth middleware with demo login (
admin/password) - MQTT client with startup publish and best-effort subscription
- Multi-stage
DockerfileandMakefilefor common tasks test/docker-compose.ymlspins up MySQL, Mosquitto, phpMyAdmin, and the server for local integration
Quickstart 🔧
Build and run locally:
make build
./bin/server
Run tests:
make test
Build Docker image:
make docker-build
Then run it:
docker run -p 8080:8080 lambdaiot-core:latest
Integration stack (MySQL + Mosquitto + server):
cd test
docker compose up -d --build
The compose file seeds the database from ai-improved.sql and exposes:
- API on http://localhost:8080
- MySQL on localhost:3306 (root/rootpass)
- Mosquitto on localhost:1883
- phpMyAdmin on http://localhost:8081
Endpoints
GET /health— returns{ "status": "ok" }GET /hello— greeting JSONPOST /login— demo login, body{ "username": "admin", "password": "password" }, returns{ "token": "..." }GET /protected— JWT requiredGET /devices— list devices (public) /POST /devices,GET/PUT/DELETE /devices/:id(JWT)- Sensors (JWT):
GET /sensors,GET /sensors/:id,POST /sensors,PUT /sensors/:id,DELETE /sensors/:id - Actors (JWT):
GET /actors,GET /actors/:id,POST /actors,PUT /actors/:id,DELETE /actors/:id - Sensor readings (JWT):
GET /sensor-readings,GET /sensor-readings/:id,POST /sensor-readings,PUT /sensor-readings/:id,DELETE /sensor-readings/:id(optionalsensor_idfilter and pagination vialimit,page) GET /mqttping— publish timestamp to MQTT default topic (JWT)
Environment
JWT_SECRET— (optional) secret used to sign tokens; defaults tosecretfor local/dev useMQTT_*— configure broker, client ID, topic, username/passwordDB_*— MySQL connection overrides; seeconfig.tomldefaults ininternal/config
Description
Languages
Go
78%
Python
10.3%
C++
9.5%
Shell
1.1%
Dockerfile
0.8%
Other
0.3%