- Knexjs schema and migrations (models for user and device).
- CRUD actions on the device table with aws Lambda
- nextjs app with pages to view, and create devices.
- authentication with cognito- iot simulation service
- realtime data for the device in nextjs app.
- lambda functions for: authorization, creating a device, getting a device by specified user, and a function that showcases getting data from IoT but doesn't do anything with it.
This doc assumes you have node(npm, npx) installed.
Clone the repository and do the following:
cd nextjs
npm i
npm run dev
go to localhost:3000
to view the app.
Node service in iotmock/
simulates a device and realtime values can be seen on the device page in webapp. Steps to demo:
- run webapp
cd nextjs
npm i
npm run dev
-
go to
localhost:3000/
-
click on
Devices
orlogin
in navbar -
login or create an account
-
create a new device and note down its name
-
unzip the provided ceritificates folder in
iotmock
directory such that the directory structure looks as following:
iotmock
├── certs
│ ├── private.pem.key
│ ├── public.pem.key
│ ├── root-ca.pem
│ └── thing-certificate.pem.crt
├── index.js
├── package.json
- run node service with specific name of your device as argument
cd iotmock
npm run start --name <device-name>
-
while this process is running, go to the dashboard and click on device with the given name.
-
the device values should be updating realtime and will stop once the iotmock service is ended.
-
iotmock service uses
device1
as default device name and its values are also recieved by the dashboard. if dashboard device's name does not match the name of the iotmock device, real time values don't show up but can still be viewed in the browser console.
Each section of the project is divided in apt directories:
Contains a node service that mocks an iot device. Steps to do so include:
cd iotmock
npm i
npm run start
You can specify the name of the device that you want to mock with --name
option:
npm run start --name <device-name>
Consists of the frontend code for the web application. To run:
cd nextjs
npm i
npm run dev
It runs on local host 3000
port. If that port is occupied you can use npx next dev -p 8080
to run on a different port.
Contains all the migrations to the database. The migrations can be recreated by:
cd knexjs
npm i
change knexfile.js
database credentials to your database's endpoints. and then:
npx knex migrate:latest --knexfile db/knexfile.js
Migrations won't work on the default database since the RDS's network rule have been set such that they only allows certain ip address to run the migrations from.
Contains all the lambda functions deployed with serverless framework. To deploy functions to personal AWS
npm i
npm i -g serverless
serverless login
serverless deploy