Does your app need to handle orders at scale
and show the delivery status of those orders?
Stick around.
I'll show you the services that you need to get started.
Today's episode comes from Tamunowari
who is a recent College graduate in Nigeria.
During his time in College,
he realized there was no efficient way to order meals, especially at night.
Now he wants to build an app that serves the Nigerian market,
allowing Nigerians to have food delivered to them from restaurants.
Let's hear from Tamunowari.
Hello, I'm Tamunowari and I'm innovating the food delivery market in Nigeria.
Food delivery in Nigeria is very inefficient. It takes hours to get your order.
I've provided a solution to that.
I'm creating a marketplace consisting of vendors, users, and delivery guys.
Users place orders to vendors and delivery guys pick them up.
Vendors don't have direct interaction with the users, just the delivery guy.
The users don't have direct contact with anybody,
any of the individuals on the marketplace.
They just see the order on the app and delivery guys
deliver it to the users.
Tamunowari's application will be in charge of displaying the menus,
communicating the orders to the restaurants,
and ensuring that food gets delivered to hungry customers as soon as possible.
Along the way,
I'll show you the services you should use to build an ecommerce app
and that allow users to see the status of their orders in real time.
I recommend using a serverless microservices architecture for this application.
In a microservices architecture,
the application is composed of independent services that communicate over well-defined APIs.
This agile approach will help you improve maintainability and scalability.
A typical serverless microservices infrastructure is composed of Amazon API Gateway
and AWS Lambda Functions.
API Gateway makes it easy to create, maintain and secure REST APIs at any scale.
You can think of API Gateway as the front door to access your backend.
Lambda lets you run code without having to think about servers or clusters.
Lambda will take care of everything required to run
and scale the execution to meet the actual traffic demand
with high availability.
You'll create Lambda Functions for each business process.
API Gateway will synchronously trigger the right Lambda Function
depending on the service you need to reach.
For Tamunowari,
that means creating a Lambda Function for the user service,
order service, payment service, menu service, and delivery service.
I just listed five microservices and your MVP might have as many or more.
So to speed up your development, make sure you check out
the API Gateway with Lambda Solutions Construct.
I've dropped a link to it at the bottom of the video.
This is an out of the box solution that deploys an edge optimized API Gateway endpoint
that is connected to a Lambda Function.
The users need to authenticate themselves
to be able to access the application and order their food.
Amazon Cognito lets you add user sign up, sign in,
and access control to your apps quickly.
Cognito has a concept called user pools which you can think of as a user directory.
You can use a Cognito User Pool to control who can access your API in API Gateway.
This is useful when you have different personas using your app.
In Tamunowari's app,
the user that wants to order food should have access to different APIs
than the restaurant owner and the person delivering the food.
Choosing the right database takes some research, but it's worth your time.
I've dropped a link to a video below
that can help you think through how to select a database.
Since Tamunowari is building a food delivery app,
a relational database would work well.
Relational databases are a solid choice
when you're building a transactional system and want data accuracy and consistency.
Amazon Aurora is a MySQL and Postgres compatible relational database built for the cloud.
He'll use Aurora to perform CRUD operations on food orders.
You'll want to build search functionality to help your users discover the right product to buy.
Amazon Elasticsearch provides a fast and personalized search experience for your app.
Elasticsearch achieves fast responses
because it searches an index instead of the text directly.
This is like retrieving pages in a book related to a keyword by scanning the index
as opposed to searching every word of every page.
I'll walk through how you could build this functionality using Tamunowari's app as an example.
When a user logs into Tamunowari's app,
the user will search for their favorite restaurants or for a specific food.
This functionality is built on API Gateway,
calling a Lambda Function and the Lambda Function requesting the search item in Elasticsearch.
To process payments,
you can build your own payment processor or use a third party.
My suggestion is to use a third party
so you can get your app to market as soon as possible.
You would use Lambda to trigger the third party payment processor.
Once the payment has been processed,
you'll use a Lambda Function to trigger Amazon's Simple Notification Service.
Simple Notification Service is a pub sub messaging service
that can be used to send messages to millions of users.
Lambda triggering Simple Notification Service
is a common architecture pattern for event driven apps.
You can use Lambda with the Simple Notification Service Solutions Construct
to pre-configure these services together with security best practices built in.
I've left a link to this at the bottom of the video.
When the order is confirmed,
it is sent to a central message queue managed by Amazon Simple Queue Service.
Simple Queue Service is a message queuing service
that enables you to decouple and scale microservices.
It is really important that the purchases are kept in order
so that there are no delays for the users.
A first in first out queue will ensure that the order
in which the messages are sent and received is strictly preserved.
It will also ensure that the message is only delivered once
and that no duplicates are introduced into the queue.
Now I'll go over how to verify the status of the order in real time
based on the location of the order.
Amazon Location Service makes it easy for developers
to add location functionality to their app.
Location Geofences gives your application the ability to detect and act
when a tracked device enters or exits a geographical boundary you define as a geofence.
When a location update crosses the boundaries of one or more geofences,
Amazon EventBridge receives the Geofence Event.
EventBridge is a serverless event bus
that makes it easier to build event driven applications at scale.
EventBridge will route the data from the Geofence to a Lambda Function,
which will then publish a message to SNS
and trigger a notification to your users.
This architecture pattern of using location service for map and geofence data
and passing that data to EventBridge to react in real time
can be used for almost every app that needs to manage deliveries.
Now it's time for a recap.
Add user sign in with Amazon Cognito.
Use API Gateway with AWS Lambda to build each microservice.
All of your order data is stored in Amazon Aurora.
Use Amazon Elasticsearch to provide a quick search experience in your app.
Notify users of their order with Amazon's Simple Notification Service.
Use a FIFO queue with Amazon's Simple Queue Service to process orders.
Send real time notifications based on the location of the delivery worker
using Amazon's Location Service.
That's what you need to build an ecommerce app with location based notifications.
It doesn't matter when you start as long as you just get started!
Thanks for hanging out with me. See you soon.