Voting Application using AWS Services
About the Project
The Serverless Voting Application is designed to provide a highly scalable, secure, and cost-effective online voting system using AWS serverless technologies. The architecture eliminates traditional server dependencies by utilizing AWS Lambda for backend logic, Amazon API Gateway for handling HTTP requests, and Amazon DynamoDB for efficient and reliable vote storage. Amazon Cognito is integrated for secure user authentication and access management, while AWS Step Functions orchestrate workflows for validating and processing votes.
This serverless approach ensures automatic scaling, high availability, and fault tolerance, allowing the system to efficiently handle varying voting loads. Additionally, the pay-as-you-go pricing model reduces operational costs by charging only for actual usage. The event-driven execution model enables real-time vote processing, making the application highly responsive and adaptable for large-scale elections, surveys, and polling events.
By leveraging AWS-managed services, the Serverless Voting
Application minimizes infrastructure overhead while ensuring a secure, reliable, and efficient voting process, making it an ideal solution for modern online voting requirements.
ARCHITECTURE
MODULES
1. User Authentication & Authorization:
2. Voting Management
3. Real-time Results Processing
4. Dashboard
SERVICES
Lambda: AWS Lambda is a serverless compute service that runs your code in response to events and automatically manages the underlying compute resources for you. These events may include changes in state or an update, such as a user placing an item in a shopping cart on an ecommerce website.
DynamoDB: Amazon DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability. You can use Amazon DynamoDB to create a database table that can store and retrieve any amount of data, and serve any level of request traffic.
Amazon Cognito: Amazon Cognito is a service provided by AWS that is used for user authentication, authorization, and user management in web and mobile applications.
API Gateway: API is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other.
AWS IAM (Identity & Access Management for Security): Controls permissions for Lambda, API Gateway, and DynamoDB. Ensures role based access for different user types.
Video Link: Video
Github Url: Url
MODULES IMPLEMENTATION
FIG 1-5 : To create the login and signup system using Amazon Cognito, we first logged into the AWS Management Console and navigated to the Cognito service. We created a new User Pool to manage user accounts, enabling email as the primary sign-in method and configuring password policies for security. In the user pool settings, we enabled the self-registration option, allowing users to sign up with a verification email. Then, we created an App Client without a client secret to connect our frontend to the user pool. We enabled Hosted UI in Cognito to auto-generate a login/signup page, which includes built-in forms and flows for user authentication. The generated Hosted UI URL was embedded into our HTML login page as a button or redirect link. After a successful login, Cognito returns a token that can be used to manage user sessions securely. This simplified the authentication process by eliminating the need to code the login logic manually and provided a fully managed, secure user authentication system.
FIG 6-9 : The first function, storeVote, accepts user votes through an API Gateway endpoint, processes the input, and stores the data in a DynamoDB table named Votes. Input validation and error handling were included to ensure data integrity. The second function, getResult, scans the DynamoDB table and aggregates vote counts in real-time. Both functions were written in Python (can be Java/Node.js) and tested using test events and API Gateway integrations. IAM roles were configured to allow secure access between Lambda and DynamoDB. We deployed both Lambda functions behind RESTful API endpoints using Amazon API Gateway, which were then called from the frontend using JavaScript. This setup enabled a fully serverless, scalable, and real-time voting system.
Recommended by LinkedIn
FIG 10-15 : created a REST API using Amazon API Gateway to expose backend Lambda functions to the frontend. Two primary resources were added: /vote and /results. The /vote endpoint uses the POST method to allow users to cast votes, and the /results endpoint uses the GET method to fetch vote results. These methods were integrated with the corresponding AWS Lambda functions (storeVote and getResult) by choosing the Lambda integration type during method creation. CORS was enabled using the OPTIONS method for cross-origin access from the frontend. To allow API Gateway to invoke Lambda, we granted execution permissions by attaching the AWS-managed policy AWSLambdaRole or a custom role with the lambda:InvokeFunction action. Additionally, the Lambda functions were granted read/write access to DynamoDB using the AmazonDynamoDBFullAccess or a scoped-down policy. Finally, the API was deployed to a stage and tested using the browser and frontend code.
FIG 16: We used Amazon DynamoDB as the backend database to store vote data in the Cognition application. A table named Votes was created with attributes option (university name) and vote_count (number of votes). The storeVote Lambda function updates this table when a vote is cast, and the getResult function reads the data to display results. This serverless NoSQL database ensures fast performance, scalability, and easy integration with AWS Lambda.
OUTPUT
Conclusion:
The voting application demonstrates the AWS serverless services in building a real-time, scalable, and cost-effective solution. By leveraging Lambda, API Gateway, DynamoDB, and S3, the app ensures seamless vote processing and live result updates, with minimal infrastructure management.
Excellent work niharika 👏