The Blog is co-authored by Shweta Jain(shweta.jain@in.ibm.com)
Background and Context with Industry Use case
Across industries, clients are transforming legacy applications and re-imagining business processes. One of the limitations and pain point of legacy applications was the inability to effectively address real time notifications to business users resulting in inconsistencies and delays. Most of the processes used to be nightly batch jobs.
As client’s are now embarking on re-imagine journeys of existing business processes by building cloud native applications on hybrid cloud - one of the patterns which is predominant is the need for real time notifications (either for system triggered flows or for user triggered actions) to business users for enterprise applications.
This blog describes a use case for Automotive industry majors on their journey to transform Vehicle Supply chain and building cloud native digital products on AWS cloud.
This specific use case is one example (of many possible scenarios) where demand and supply analysts’ who perform the setup of Vehicle configurations need to have real-time notifications from the backend services. The business application is a web application which will be accessed by multiple users concurrently across multiple regions across the globe. This application is critical to support digital transformational efforts through a system capable of establishing near-real time validation of vehicle configurations. The overall architecture is a cloud native Microservices and event-based architecture.
This blog will focus specifically on the pattern to implement real-time notifications to business users. AWS AppSync offers robust capabilities to build real-time functionality using WebSockets and GraphQL subscriptions for Enterprise applications.
Current State Solution and Problem Statement:
The current legacy application requires users to gather multiple documents from SharePoint sites, which can be time-consuming. Data is manually interpreted and entered an excel to send to manufacturing plants, increasing the risk of errors. The changes are processed in a nightly batch.
With the target re-imagined application, How can we efficiently and securely deliver real-time notifications to demand and supply users ?
Challenges:
- Delivering real-time updates to multiple users concurrently.
- Ensuring secure access to notifications through custom authentication.
- Minimizing infrastructure complexity and cost by avoiding persistent storage.
Solution Approach:
This blog describes how to build a real-time notification system to the UI application using AWS AppSync WebSockets, and at the same time keeping it lightweight and simple to meet performance and scalability requirements.
This blog also demonstrates the use of Amazon Q developer to generate the code for this use case.
Use Case Scenario:
Use Case Name: Real-Time Event Updates
Primary Actor: Client Application (Web/Mobile)
Secondary Actor: AWS Services (AppSync, Lambda)
Preconditions:
- The client application has valid authentication credentials.
- AWS AppSync and Lambda functions are correctly configured.
Architecture Overview

Architecture Diagram Description:
- Client (Web/Mobile App) - Connects to the AppSync to receive real-time notifications.
- AWS AppSync - Manages GraphQL API with WebSocket subscriptions for real-time updates.
- AWS Lambda (Auth Function): Verifies client credentials to control access.
- AWS Lambda - Publishes notifications directly to AppSync without using any database.
Workflow:
- The client attempts to connect to the WebSocket endpoint, providing authentication details.
- AWS AppSync invokes the Lambda Authorization function to validate the user.
- Once authorized, the client subscribes to the notifications channel.
- A notification event is triggered via the mutation.
- The notification is published through AppSync, and subscribed clients receive it in real time.
Create sample app using AmazonQ with below prompt
`Create Real-Time Notifications for the Automotive Industry Using AWS AppSync WebSocket and Lambda Authorization Without a Database`
This prompt will generate all required resources to deploy it in AWS as Below.
- schema.graphql: Defines the GraphQL schema with:
- Notification type with fields for automotive notifications
- Enums for notification types and priority levels
- Subscription for real-time updates
- Mutation to publish notifications
- Query to get available notification types
- appsync-stack.js: CDK stack that:
- Creates a Lambda authorizer with inline code
- Sets up AppSync API with the schema and Lambda authorization
- Creates a resolver Lambda with inline code for handling queries and mutations
- Configures resolvers for the GraphQL operations
- Outputs the GraphQL and WebSocket URLs
- app.js: Entry point for the CDK application that creates and synthesizes the stack
- client-example.js: Example client code showing:
- How to connect to the AppSync API
- How to subscribe to real-time notifications
- How to publish notifications
- README.md: Documentation with setup instructions and testing examples
How to Deploy and Test
- Install dependencies:
`npm install aws-cdk-lib constructs aws-appsync graphql-tag`
- Deploy the stack:
`cdk deploy`
3. After deployment, update the client example with your API endpoint from the CloudFormation outputs
4. Test the API using the AWS AppSync Console or the client example
Security Considerations:
- Replace the hard-coded token with a more secure approach, like fetching a token from AWS Cognito or an authentication server.
- Store tokens securely on the client side.
- Implement token rotation and expiration checks in the Lambda authorization logic.
Business Benefits of This Approach:
- Streamlines Business Process and Journeys: Greater alignment and communication across business groups and teams to further improve configuration and production preparedness speed. ~ 70% response time improvement with real time notifications.
- Automated Data and Real Time management: Unified demand and supply data allows for changes and management. ~ 90% labor reduction due to automation of Vehicle configurations set up.
- Faster Response Times: ~ 30-50 ms average response time for validation and recommendations for Spec adjustments
- Scalable: AWS handles the WebSocket infrastructure, allowing for thousands of simultaneous connections.
Conclusion:
By combining AWS AppSync WebSocket and Lambda Authorization, you can build secure, real-time notification channels.
This approach provides a quick and straightforward way to implement real-time notifications without database storage. It’s ideal for scenarios where temporary or ephemeral messages are sufficient, such as alerts or transient updates.
If you need persistent storage or complex querying, consider integrating DynamoDB. But for lightweight, real-time communication, this method works exceptionally well.