Design Billify - a serverless invoice processor.
Github repo: https://github.com/anmol111pal/billify-Invoice-Processor/
Requirements
The user will upload his/her invoices to the application throughout the month.
As soon as, the invoice is uploaded, the user gets notified about the expense via an email.
At the start of the next month (1st of the next month), the consolidated report is emailed to the user with all the expenses he has done in the past month.
Techical Requirements
Provide an endpoint to the user to upload an invoice & his details (such as name and email). Create lambda functions that puts the invoice file into an S3 bucket & sends a message to a queue so that another function can process it & write the extracted information into ddb table.
Glossary
API Gateway: acts as a single entry point for API calls, routing client requests to the appropriate backend services while also handling tasks like authentication, authorization, and rate limiting.
Lambda: is a serverless, event-driven compute service that allows you to run code without provisioning or managing servers, focusing on code execution and scaling based on events, rather than infrastructure.
Dynamo DB: is a fully managed, serverless NoSQL database service provided by AWS that supports key-value and document data models, designed for high-performance and scalable applications.
SQS: is a fully managed message queuing service by AWS that enables developers to send, store, and retrieve messages between software components.
Textract: is a machine learning service that automatically extracts text, handwriting, and data from scanned documents, images, and PDFs.
Proposed Architecture Architecture
Implementation Plan
- Implement a REST endpoint in API Gateway for
POST /upload-invoice
.
The user will upload the invoice along with his/her details such as name & email address.
- Implement the following Lambda functions -
uploadInvoice
- This will receive the invoice file (.png or .jpg) and user details. It will then upload the invoice to an S3 bucket, and write the user details & the S3 key (of the invoice) to an SQS queue for the `` function process & extract further information (from the invoice).
extractBillInfo
- This will receive SQS message that contains user details & invoice's S3 key and
monthlyBillAggregator
- This function is triggered by an EventBridge rule that is executed on the 1st of every month. It fetches the items from the Dynamo DB table, aggregates them for each user & sends out an email via SES notifying the users of their last month's expenses/spends.
We will also have an SQS queue, and an EventBridge rule as described above.
Dynamo DB Schema
Also, we'll have a Dynamo DB table, with the following schema:
{
id: string -> Partition Key
timestamp: string (DateTime as ISO String) -> Sort Key
name: string
email: string
total: number
}
Follow me on my socials
Linkedin: https://www.linkedin.com/in/anmol-pal/
Github: https://github.com/anmol111pal/
X/Twitter: https://x.com/anmol111pal/
Top comments (2)
Insightful
Great work 👏