All Projects → aws-samples → Aws Iot Chat Example

aws-samples / Aws Iot Chat Example

Licence: apache-2.0
💬 Chat application using AWS IoT platform via MQTT over the WebSocket protocol

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Aws Iot Chat Example

Serverless Chat
A serverless web chat built using AWS Lambda, AWS IoT (for WebSockets) and Amazon DynamoDB
Stars: ✭ 99 (-79.11%)
Mutual labels:  aws-lambda, aws-iot, mqtt, websockets
Aws Iot Certificate Vending Machine
The CVM allows a device to apply for its own certificate and installation.
Stars: ✭ 64 (-86.5%)
Mutual labels:  aws-iot, dynamodb, mqtt
Aws Cognito Apigw Angular Auth
A simple/sample AngularV4-based web app that demonstrates different API authentication options using Amazon Cognito and API Gateway with an AWS Lambda and Amazon DynamoDB backend that stores user details in a complete end to end Serverless fashion.
Stars: ✭ 278 (-41.35%)
Mutual labels:  aws-lambda, dynamodb, amazon-cognito
Graphql Serverless
Sample project to guide the use of GraphQL and Serverless Architecture.
Stars: ✭ 28 (-94.09%)
Mutual labels:  aws-lambda, serverless-framework, dynamodb
hyper-kube-config
H Y P E R K U B E - A Serverless API and kubectl plugin providing a storage and retrieval Kubernetes cluster credentials. Hyperkube leverages AWS Secrets Manager for storing credential information.
Stars: ✭ 27 (-94.3%)
Mutual labels:  aws-lambda, dynamodb, serverless-framework
Serverless Express
Run Node.js web applications and APIs using existing application frameworks on AWS #serverless technologies such as Lambda, API Gateway, Lambda@Edge, and ALB.
Stars: ✭ 4,265 (+799.79%)
Mutual labels:  aws-lambda, dynamodb, serverless-framework
Aws Mqtt Client
AWS Websocket Pub/Sub client
Stars: ✭ 147 (-68.99%)
Mutual labels:  aws-iot, mqtt, websockets
Serverless
Serverless 架构应用开发指南 - Serverless Architecture Application Development Guide with Serverless Framework.
Stars: ✭ 1,616 (+240.93%)
Mutual labels:  aws-lambda, serverless-framework, dynamodb
amazon-ivs-simple-chat-web-demo
⚠️ IMPORTANT ⚠️ This repository is no longer actively maintained and will be archived at the end of 2022. A basic live chat implementation built with WebSockets, that can be used in conjunction with Amazon IVS to build compelling customer experiences for live video streams with chat use cases.
Stars: ✭ 53 (-88.82%)
Mutual labels:  aws-lambda, websockets, serverless-framework
twitter
A serverless social network that's under development with some cool stuff, such as Serverless Framework, AppSync, GraphQL, Lambda, DynamoDB, Cognito, Kinesis Firehose, and Algolia ☁️
Stars: ✭ 29 (-93.88%)
Mutual labels:  aws-lambda, dynamodb, serverless-framework
aws-appsync-iot-core-realtime-dashboard
This sample application demonstrates a React based web dashboard receiving real-time updates from IoT sensors. The solution is built with AWS AppSync, AWS Amplify, Amazon Location Service, and AWS IoT Core technologies.
Stars: ✭ 75 (-84.18%)
Mutual labels:  aws-lambda, dynamodb, aws-iot
Guide
Serverless Guide - An open-source definitive guide to serverless architectures.
Stars: ✭ 421 (-11.18%)
Mutual labels:  aws-lambda, serverless-framework
Serverless Plugin Canary Deployments
Canary deployments for your Serverless application
Stars: ✭ 283 (-40.3%)
Mutual labels:  aws-lambda, serverless-framework
Aws Auto Cleanup
Open-source application to programmatically clean your AWS resources based on a whitelist and time to live (TTL) settings
Stars: ✭ 276 (-41.77%)
Mutual labels:  aws-lambda, serverless-framework
Serverless Golang
AWS Lambda Go functions using Serverless Framework and Python shim
Stars: ✭ 292 (-38.4%)
Mutual labels:  aws-lambda, serverless-framework
Hands On Serverless Guide
A hands-on guide for building Serverless applications
Stars: ✭ 288 (-39.24%)
Mutual labels:  aws-lambda, serverless-framework
Lambdaguard
AWS Serverless Security
Stars: ✭ 300 (-36.71%)
Mutual labels:  aws-lambda, dynamodb
Mqtt Panel
A web interface for MQTT
Stars: ✭ 315 (-33.54%)
Mutual labels:  mqtt, websockets
Saea
SAEA.Socket is a high-performance IOCP framework TCP based on dotnet standard 2.0; Src contains its application test scenarios, such as websocket,rpc, redis driver, MVC WebAPI, lightweight message server, ultra large file transmission, etc. SAEA.Socket是一个高性能IOCP框架的 TCP,基于dotnet standard 2.0;Src中含有其应用测试场景,例如websocket、rpc、redis驱动、MVC WebAPI、轻量级消息服务器、超大文件传输等
Stars: ✭ 318 (-32.91%)
Mutual labels:  mqtt, websockets
Zappa
Serverless Python
Stars: ✭ 224 (-52.74%)
Mutual labels:  aws-lambda, serverless-framework

AWS IoT Chat Application

tested with jest GitHub stars GitHub license Demo Online

This is a React application demonstrating how to use the AWS IoT platform via MQTT over the WebSocket protocol to build a live chat application. The sample application serves as a starting point for users to build serverless projects with Amazon Cognito, AWS Lambda and Amazon DynamoDB. The project showcases the solution to common user questions such as how to authenticate IoT devices with Amazon Cognito.

Table of Contents

Features

  • Register user
  • Login / Logout
  • Create room
  • Join room
  • Real-time chat
  • Unread message indicators

AWS Services Showcased

Architecture

Installation

Prerequisites:

Please note that this project has only been tested on macOS. Windows users may need to update some of the scripts. Pull requests are welcome to add Windows support.

  • Install and configure the AWS Command Line Interface
    • Ensure that the aws cli region is the same as what you define in api/config.yml
    • Please configure your output format to be json. Instructions
  • jq to process command-line JSON.
  • npm the node package manager
  1. Clone the repository
$ git clone https://github.com/aws-samples/aws-iot-chat-example.git
  1. Deploy the backend

If you would like to enable login with Facebook and/or Google, please follow the Social Logins guide.

$ cd api
$ sudo npm install -g serverless
$ npm install
$ serverless deploy

The Serverless Framework is a tool for deploying serverless architectures. The stack including Lambda functions and CloudFormation resources are defined in api/serverless.yml.

After deploying the serverless application, two scripts are invoked by means of a lifecycle hook. The first, api/scripts/attachConfirmUserTrigger.sh is used to attach a Lambda function to the PreSignUp trigger on the Cognito User Pool.

The second script in client/scripts/setup.sh uses the AWS CLI to query the Cloudformation template output variables and stores them in the file client/src/config/config.json. This auto-generated file is then imported by client/src/config/index.js and used within the client side application.

  1. Run the frontend client
$ cd ../client
$ npm install
$ npm start

It is important to run the setup script so that the client knows the destination of the AWS IoT endpoint, API Gateway endpoint and other coniguration variables generated by serverless deploy.

  1. Open http://localhost:3000 and try it out!

Teardown

To tear down the stack, use the command serverless remove.

Application Walkthrough

Try the app on the Demo website

  1. Register Page /register

Register a user using Amazon Cognito User Pools. You can use user pools to add user registration and sign-in features to your apps.

Register

  1. Login page /login

Login a user using Amazon Cognito User Pools.

Alternatively, you can use Amazon Cognito Federated Identities to create unique identities for your users and federate them with identity providers such as Facebook and Google.

Login

  1. Rooms List /app/rooms

Displays the list of available rooms to join. If you are subscribed to a room, there will be an icon indication. The number of unread messages to subscribed rooms is also displayed. Lastly, on this screen you can create a room. The application will generate an appropriate topic name to publish on if your room name contains illegal characters.

All HTTP API endpoints are AWS Lambda functions invoked through Amazon API Gateway.

Rooms list

  1. Room /app/room/public/bad-programming-jokes

This is the main chat page where the real-time messaging is displayed. You will still be subscribed to other rooms as indicated by the unread message counters that increment when a message is received. Sending a message will dispatch a message to AWS IoT which in turn is responsible for fanning out the messages to all the subscribers of the room.

Architecture Walkthrough

Frontend

Redux Flows

Auth Flow Messaging Flow Rooms Screen Flow

Backend

To deploy the backend, this project uses the Serverless Framework which is backed by AWS CloudFormation. In the api/serverless.yml file, functions, events, resources and services are defined which Serverless uses to deploy the appropriate Lambda functions, API Gateway services and additional CloudFormation resources.

IoT Topics

MQTT (Message Queue Telemetry Transport) protocol uses a hierarchical structure to describe the topic space. Multi-level # wildcards and single-level + wildcards can be used in addition to topic level separators /.

In this application, topics are subscribed to using the form:

room/public/:roomName/+

This matches topics such as:

room/public/room/abc
room/public/another-room/123
room/public/another-room/us-west-2:7f86d9a8-b9f4-439e-bcf3-9756e4d2bbdf

Note the last example topic because this is the topic that users will publish to.

room/public/:roomName/:cognitoIdentityId

Based on the MQTT specification, a receiving client does not know who published the message without either including the message author in the message payload itself or by encoding the message author in the message topic.

This application opted for the second option by appending the cognito identity id to the end of the publishing topic. To prevent users from publishing to other user's topics, the AWS Lambda function AttachPublicPublish creates a dynamic IoT policy that allows only that one identity to publish messages to their unique topic.

Other guides

Testing

In both the api and client directories, npm run test can be used to run unit tests using jest

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].