aws-serverless-airline-booking
Airline Booking is a sample web application that provides Flight Search, Flight Payment, Flight Booking and Loyalty points including end-to-end testing, GraphQL and CI/CD. This web application was the theme of Build on Serverless Season 2 on AWS Twitch running from April 24th until end of August in 2019.
Top Related Projects
Code and walkthrough labs to set up serverless applications for Wild Rydes workshops
Serverless Ecommerce Platform is a sample implementation of a serverless backend for an e-commerce website. This sample is not meant to be used as an e-commerce platform as-is, but as an inspiration on how to build event-driven serverless microservices on AWS.
Quick Overview
The aws-samples/aws-serverless-airline-booking
repository is a sample application that demonstrates how to build a serverless airline booking system using AWS services. The application includes features such as user authentication, flight search, booking, and payment processing.
Pros
- Serverless Architecture: The application is built using AWS serverless services, which reduces the need for infrastructure management and scaling.
- Modular Design: The application is designed in a modular way, making it easier to maintain and extend.
- Security: The application uses AWS Identity and Access Management (IAM) and AWS Cognito for user authentication and authorization.
- Scalability: The serverless architecture of the application allows it to scale automatically to handle increased traffic.
Cons
- Vendor Lock-in: The application is heavily dependent on AWS services, which may make it difficult to migrate to other cloud providers.
- Complexity: The application is relatively complex, with multiple AWS services and components, which may make it challenging for beginners to understand and deploy.
- Cost: While serverless architectures can be cost-effective, the ongoing costs of running the application on AWS may be higher than a traditional, self-hosted solution.
- Limited Customization: The application is designed as a sample and may not include all the features or customizations that a production-ready application would require.
Code Examples
The aws-samples/aws-serverless-airline-booking
repository contains several AWS Lambda functions written in Python. Here are a few examples:
- Flight Search:
def lambda_handler(event, context):
"""
Handles the flight search request.
"""
# Extract the search parameters from the event
origin = event['origin']
destination = event['destination']
departure_date = event['departure_date']
# Call the flight search service to get the available flights
flights = search_flights(origin, destination, departure_date)
# Return the search results
return {
'statusCode': 200,
'body': json.dumps(flights)
}
- Booking Creation:
def lambda_handler(event, context):
"""
Handles the flight booking request.
"""
# Extract the booking details from the event
user_id = event['user_id']
flight_id = event['flight_id']
payment_method = event['payment_method']
# Create the booking in the database
booking_id = create_booking(user_id, flight_id, payment_method)
# Return the booking details
return {
'statusCode': 200,
'body': json.dumps({
'booking_id': booking_id
})
}
- Payment Processing:
def lambda_handler(event, context):
"""
Handles the payment processing request.
"""
# Extract the payment details from the event
booking_id = event['booking_id']
payment_method = event['payment_method']
amount = event['amount']
# Process the payment using a payment gateway
payment_status = process_payment(booking_id, payment_method, amount)
# Update the booking status in the database
update_booking_status(booking_id, payment_status)
# Return the payment status
return {
'statusCode': 200,
'body': json.dumps({
'payment_status': payment_status
})
}
Getting Started
To get started with the aws-samples/aws-serverless-airline-booking
project, follow these steps:
- Clone the repository:
git clone https://github.com/aws-samples/aws-serverless-airline-booking.git
- Navigate to the project directory:
cd aws-serverless-airline-booking
- Deploy the application using the AWS Serverless Application Model (SAM) CLI:
sam build
sam deploy --guided
-
Follow the prompts to configure the deployment, including the AWS region, stack name, and other parameters.
-
Once the deployment is complete, you can access the application using the provided URL.
Competitor Comparisons
Code and walkthrough labs to set up serverless applications for Wild Rydes workshops
Pros of aws-serverless-workshops
- Covers a broader range of serverless topics and services
- Provides multiple hands-on workshops for different skill levels
- Includes detailed step-by-step instructions and explanations
Cons of aws-serverless-workshops
- Less focused on a specific real-world application scenario
- May not provide as deep an insight into a complete serverless architecture
- Could be overwhelming for beginners due to the variety of topics covered
Code Comparison
aws-serverless-workshops:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: RESTful API for a simple Wild Rydes rider management system
Resources:
GetRidersFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.get
Runtime: nodejs14.x
Events:
GetRiders:
Type: Api
Properties:
Path: /riders
Method: get
aws-serverless-airline-booking:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Serverless Airline Booking API
Resources:
FlightTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: flightId
AttributeType: S
KeySchema:
- AttributeName: flightId
KeyType: HASH
BillingMode: PAY_PER_REQUEST
The code snippets show that aws-serverless-workshops focuses on individual serverless functions and API Gateway, while aws-serverless-airline-booking demonstrates a more complex architecture with additional AWS services like DynamoDB.
Serverless Ecommerce Platform is a sample implementation of a serverless backend for an e-commerce website. This sample is not meant to be used as an e-commerce platform as-is, but as an inspiration on how to build event-driven serverless microservices on AWS.
Pros of aws-serverless-ecommerce-platform
- More comprehensive e-commerce functionality, including product catalog, shopping cart, and order processing
- Includes CI/CD pipeline setup with AWS CodePipeline and CodeBuild
- Demonstrates integration with external services like payment gateways
Cons of aws-serverless-ecommerce-platform
- More complex architecture, potentially harder to understand for beginners
- Less focus on specific industry use cases compared to the airline booking example
- May require more resources to deploy and maintain due to its broader scope
Code Comparison
aws-serverless-airline-booking:
def get_flight(flight_id):
response = table.get_item(Key={'pk': flight_id, 'sk': 'FLIGHT#DETAILS'})
return response.get('Item', {})
aws-serverless-ecommerce-platform:
def get_product(product_id):
response = table.get_item(Key={'PK': f'PRODUCT#{product_id}', 'SK': 'METADATA'})
return response.get('Item', {})
Both examples use DynamoDB for data storage, but the ecommerce platform uses a more generic key structure, potentially allowing for greater flexibility in data modeling.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
AWS Serverless Airline Booking
Serverless Airline Booking is a complete web application that provides Flight Search, Payment, Booking and Loyalty points including end-to-end testing, GraphQL and CI/CD. This web application was the theme of Build on Serverless Season 2 on AWS Twitch running from April 24th until August 7th - Check out Twitch branch for the list of 14 episodes.
For more up-to-date information on what's being implemented, take a look at our current Boards.
Note
This project is no longer being worked on. This branch repo only serves to give inspiration to others as a point in time reference, you can see the former code by viewing the
archive
branch
Deployment
To get started with the Serverless Airline application, you can deploy into your AWS Account by following our Get Started instructions
Stack
Summary of what the stack looks like now including a picture with the core tech:
- Front-end - Vue.js as the core framework, Quasar for UI, Amplify for Auth UI component and AWS integration, and Stripe JS with Stripe Elements for card tokenization, validation, etc.
- Data - All data is modeled after GraphQL types and stored in DynamoDB. Python being the core language for all services except Loyalty that's written in Typescript, and JavaScript for front-end.
- API - GraphQL is managed by AppSync and also acts as an API Hub to interact with other services. Loyalty implements a REST API to demonstrate how to secure service-to-service communication while maintaining a public endpoint. Payment API is also based on REST to demonstrate an external payment provider.
- Auth - Cognito provides JSON Web Tokens (JWT) and along with AppSync fine-grained authorization on what data types users can access.
- Messaging - Booking workflow is managed by Step Functions while SNS provides service-to-service communication through messaging between Booking and Loyalty.
Back-end
Back-end services that makes up the Serverless Airline functionalities as of now:
Service | Language | Description |
---|---|---|
Catalog | Apache VTL | Provides Flight search. CRUD operations including custom indexes are auto-generated by Amplify |
Booking | Python and Apache VTL | Provides new and list Bookings. CRUD operations including custom indexes are auto-generated by Amplify. Business workflow is implemented in Python. |
Payment | YAML and Python | Provides payment authorization, collection and refund. Bulk of Payment integration with Stripe is done via a Serverless Application Repository App. Payment collection and refund operations within Booking business workflow are in Python |
Loyalty | Typescript | Provides Loyalty points for customers including tiers. Fetching and ingesting Loyalty points are implemented in Typescript. |
Front-end
See more information about our Front-end, components, routing and convention
High level infrastructure architecture
License Summary
This sample code is made available under the MIT-0 license. See the LICENSE file.
Top Related Projects
Code and walkthrough labs to set up serverless applications for Wild Rydes workshops
Serverless Ecommerce Platform is a sample implementation of a serverless backend for an e-commerce website. This sample is not meant to be used as an e-commerce platform as-is, but as an inspiration on how to build event-driven serverless microservices on AWS.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot