AWS Builder Center
Building a Smart Invoice & Receipt Scanner on AWS: Turning Business Documents into Intelligent Financial Workflows

Building a Smart Invoice & Receipt Scanner on AWS: Turning Business Documents into Intelligent Financial Workflows

What if a business could upload an invoice or receipt and automatically turn it into structured financial information, detect potential issues, and prepare it for approval — without manually entering every detail?

Cloud Data Engineer


Every business handles invoices and receipts.
A small business receives supplier invoices. An accounting team processes employee expenses. A retail company collects hundreds of receipts. A finance department needs to verify totals, track taxes, identify duplicate invoices, and maintain accurate records.
Although these documents contain valuable business information, much of it is still processed manually.
Employees download files, read vendor names, enter invoice numbers, copy totals into spreadsheets, and forward documents for approval.
This process takes time and creates opportunities for mistakes.
Now imagine a smarter workflow.
A user uploads an invoice or receipt. The system extracts its information, identifies the vendor, captures line items, calculates relevant financial summaries, checks for possible duplicates, and prepares a structured record for review.
That is the idea behind a Smart Invoice & Receipt Scanner on AWS.
By combining Amazon S3, Amazon Textract, AWS Lambda, Amazon EventBridge, Amazon DynamoDB, AWS Step Functions, and Amazon Bedrock, we can design an intelligent document-processing solution that helps businesses reduce repetitive work and make better use of their financial data.
But there is one important engineering challenge that we must solve before building this system: duplicate and out-of-order S3 events.
This is the central lesson from the AWS Storage Blog, Manage event ordering and duplicate events with Amazon S3 Event Notifications. We'll apply that lesson to a real-world invoice and receipt processing workflow.

1. The Business Problem: Why Invoice Processing Needs Intelligence

Consider a company that receives 500 invoices and receipts every month.
Its employees need to identify information such as:
  • Vendor or supplier name.
  • Invoice or receipt number.
  • Invoice date and due date.
  • Purchase order number.
  • Subtotal and tax.
  • Total amount.
  • Currency.
  • Individual purchased items.
  • Payment terms.
This information is often spread across documents with different layouts.
One supplier may put the invoice number at the top right. Another may use a different label. A receipt may contain the total at the bottom, while an invoice may have separate subtotal, tax, and amount-due fields.
Traditional manual processing creates several problems.
Time-consuming data entry: Employees repeatedly enter the same types of information.
Human errors: Incorrect invoice numbers, totals, or dates can affect accounting records.
Duplicate documents: The same invoice may be uploaded multiple times or submitted by different employees.
Limited visibility: Financial information remains trapped in PDFs, photographs, and scanned documents.
Delayed approvals: Documents can remain in email inboxes while employees wait for someone to review them.
A smart scanner can help address these challenges by turning unstructured documents into structured, searchable business records.

2. Understanding the Proposed AWS Architecture



Let's design an event-driven solution that starts when a user uploads an invoice or receipt.
The architecture uses Amazon S3 as the document storage layer, Amazon Textract for expense extraction, DynamoDB for processing state and duplicate protection, and Amazon Bedrock for optional intelligent business assistance.
Here is the proposed architecture:
Business User
|
v
Web Application
|
v
Amazon S3 Input Bucket
(Invoices and Receipts)
|
v
Amazon EventBridge
|
v
AWS Lambda
Event Validation and
Idempotency Coordination
|
v
Amazon DynamoDB
Event State and Sequencer
|
v
AWS Step Functions
Processing Workflow
|
v
Amazon Textract
AnalyzeExpense
|
v
Extracted Expense Data
|
v
AWS Lambda
Validation and Mapping
|
v
Amazon Bedrock
Optional AI Assistance
|
v
Amazon DynamoDB
Structured Records
|
+-----+------+
| |
v v
Amazon S3 Amazon SNS
Processed Data Notifications
| |
v v
Business Finance Team
Dashboard / Approvers
This is a proposed architecture, not a claim that every component is automatically connected by default. EventBridge rules, Lambda functions, workflow permissions, and service integrations must be configured during implementation.
The architecture has several important layers.
Document ingestion: Amazon S3 receives invoices and receipts.
Event coordination: Amazon EventBridge and Lambda initiate processing, while DynamoDB tracks event state.
Document intelligence: Amazon Textract extracts financial information.
Business intelligence: Amazon Bedrock can help summarize extracted information and generate useful explanations.
Data management: DynamoDB stores structured business records, while S3 retains original documents and processing artifacts.
Notifications: Amazon SNS helps notify users and finance teams about processing results and required reviews.
Let's explore these components in detail.

3. Uploading Invoices and Receipts to Amazon S3

The first step is allowing users to upload documents.
A web application could provide a simple interface where employees upload:
  • PDF invoices.
  • Scanned supplier documents.
  • Receipt photographs.
  • Expense statements.
  • Supporting financial documents.
Amazon S3 provides durable object storage for these files.
A possible bucket structure is:
smart-invoice-input/
uploads/
company-001/
2026/
11/
invoice-1001.pdf
receipt-1002.jpg
invoice-1003.pdf
For processed documents, a separate output bucket or a carefully filtered prefix can be used.
For example:
smart-invoice-processed/
company-001/
2026/
11/
invoice-1001.json
receipt-1002.json
Keeping original documents separate from processing outputs makes the workflow easier to manage.
It also helps prevent accidental recursive event processing.
Important: If you configure S3 events to trigger processing, do not allow the function's output uploads to trigger the same processing rule unintentionally. Use separate buckets or configure EventBridge prefix filters, such as processing only objects under  uploads/ .

4. Triggering the Workflow with Amazon S3 Event Notifications and EventBridge

Once a document is uploaded, the application needs to know that a new file is available.
Amazon S3 Event Notifications can publish events for supported object operations.
Amazon EventBridge can receive S3 events and route them to the appropriate target.
For example, an object creation event can initiate a Lambda function.
The basic flow is:
User Uploads Invoice
|
v
Amazon S3
|
v
S3 ObjectCreated Event
|
v
Amazon EventBridge
|
v
AWS Lambda
|
v
Event Coordination
This approach makes the application event-driven.
The upload operation and document-processing workflow are separate. The user does not need to wait for the entire invoice analysis process to finish before the upload is accepted.
However, there is a subtle but important problem.
An S3 event notification should not be treated as a guaranteed exactly-once, ordered message.
According to AWS documentation, S3 Event Notifications are designed for at-least-once delivery and are not guaranteed to arrive in the same order as the underlying operations. Duplicate notifications can also occur.
For an ordinary image-processing application, this may produce unnecessary work.
For a financial application, it can create more serious problems.
Imagine that an invoice is uploaded twice, or a newer version of a document is uploaded while the previous version is still being processed.
Without proper coordination, the application could create duplicate financial records or overwrite a newer result with an older one.
This is why the event-ordering strategy from the AWS Storage Blog is so valuable.

5. The Critical Challenge: Duplicate and Out-of-Order Events

Let's understand the problem with a real business example.
An employee uploads an invoice named:
invoice-1001.pdf
The application starts processing it.
A few seconds later, the employee uploads a corrected version using the same S3 object key.
Now the system has two object events:
Event A: The original invoice.
Event B: The corrected invoice.
Suppose Event B arrives first and finishes processing quickly.
Event A is still running because document analysis takes longer.
If Event A finishes after Event B and writes its result to the same database record, the old invoice information could overwrite the corrected invoice information.
This is an out-of-order processing problem.
There is another possibility: S3 may deliver the same event more than once.
If the application processes every notification independently, it could create duplicate invoice records or repeat downstream actions.
For financial applications, we need to control both situations.

Understanding the S3 sequencer

S3 event notification records can contain a field called  sequencer .
The sequencer helps identify the relative order of supported object creation and deletion events for the same object key.
For the same object key:
  • Duplicate event notifications for the same object operation have the same relevant object identity and sequencer.
  • A greater hexadecimal sequencer value represents a later event.
  • Sequencer values from different object keys cannot be compared.
There is also an important implementation detail: sequencer strings can have different lengths. The shorter value must be left-padded with zeros before lexicographical comparison.
For example:
Sequencer A: A1F
Sequencer B: B20
The second sequencer is greater, so it represents the later event for the same object key.
The application should never compare sequencers from unrelated object keys.
AWS explains this behavior in its event message documentation.

6. Using DynamoDB to Coordinate Invoice Processing

This is where Amazon DynamoDB becomes an important part of the architecture.
Instead of allowing every incoming event to start processing immediately, the application first checks the current state of the object.
DynamoDB stores information about the latest accepted event and the processing status.
A possible record structure is:
{
"document_key": "uploads/company-001/invoice-1001.pdf",
"bucket": "smart-invoice-input",
"sequencer": "B20",
"version_id": "example-version-id",
"event_type": "ObjectCreated:Put",
"status": "PROCESSING",
"processing_id": "process-1001",
"updated_at": "2026-11-10T08:00:00Z"
}
This is an illustrative application record, not the exact schema used in the AWS blog.
The processing coordinator can use DynamoDB conditional writes to protect the current state.
The general logic is:
Step 1: Receive an event.
Lambda receives the S3 event through EventBridge.
Step 2: Identify the object.
Extract the bucket name, object key, event type, version ID when available, and sequencer.
Step 3: Check the current state.
Read the DynamoDB record for the relevant object.
Step 4: Identify duplicates.
If the same object operation and sequencer have already been accepted, do not start another processing workflow.
Step 5: Reject older events.
If a newer sequencer has already been accepted for the same object key, do not allow an older event to overwrite its state.
Step 6: Coordinate processing.
Use conditional updates or a lease-based processing record to prevent conflicting workers from taking ownership of the same processing state.
Step 7: Continue processing.
Only an event that passes the coordination checks should proceed.
A production implementation must make these checks atomic. A simple read followed by an unconditional write is not sufficient because two Lambda invocations could perform the check simultaneously.
DynamoDB conditional writes help enforce the required state transitions.

A useful distinction: object events versus business duplicates

The S3 sequencer solves an event-ordering problem for a particular object key.
It does not identify the same invoice uploaded under two different filenames.
For example:
uploads/invoice-1001.pdf
uploads/invoice-1001-copy.pdf
These are different S3 object keys, so their sequencers cannot be compared.
To detect business-level duplicate invoices, the application needs a separate check using extracted information such as:
  • Vendor identity.
  • Invoice number.
  • Invoice date.
  • Currency.
  • Total amount.
A composite business key can help identify possible duplicates, but it should not automatically reject every matching document. Some suppliers may issue legitimate revised documents or repeated invoices with similar values.
The system should flag possible duplicates for review.
This distinction is essential when building financial workflows.

7. Extracting Invoice and Receipt Information with Amazon Textract

After an event passes coordination, the workflow can begin document analysis.
Amazon Textract provides an API called  AnalyzeExpense , specifically designed to analyze invoices and receipts.
It can extract information without requiring a predefined template for every document layout.
For example, it can identify:
  • Vendor name.
  • Invoice or receipt number.
  • Invoice date.
  • Due date.
  • Purchase order number.
  • Subtotal.
  • Tax.
  • Total.
  • Amount paid.
  • Payment terms.
  • Individual line items.
  • Item quantities and prices.
Textract organizes expense information into two important groups.
SummaryFields: These contain header-level and other summary information, such as vendor names, dates, and totals.
LineItemGroups: These contain individual purchased items and their associated information.
This is useful because a business needs more than just the total amount. It may also need to understand what was purchased.

Example: Calling Amazon Textract

For a supported document stored in S3, a Python application using Boto3 can call  AnalyzeExpense .
import boto3

textract = boto3.client("textract")

response = textract.analyze_expense(
Document={
"S3Object": {
"Bucket": "smart-invoice-input",
"Name": "uploads/invoice-1001.pdf"
}
}
)

for expense_document in response.get("ExpenseDocuments", []):

print("Summary Fields:")

for field in expense_document.get("SummaryFields", []):
field_type = field.get("Type", {}).get("Text")
value = field.get("ValueDetection", {}).get("Text")

print(field_type, ":", value)

print("Line Items:")

for group in expense_document.get("LineItemGroups", []):
for item in group.get("LineItems", []):
for field in item.get("LineItemExpenseFields", []):
field_type = field.get("Type", {}).get("Text")
value = field.get("ValueDetection", {}).get("Text")

print(field_type, ":", value)
This example demonstrates the extraction flow. A production implementation should also handle API errors, document limits, missing fields, multiple expense documents, and confidence scores.
For larger documents or asynchronous processing, Amazon Textract also provides  StartExpenseAnalysis  and  GetExpenseAnalysis .
The asynchronous approach is useful when processing larger workloads without holding a synchronous request open.

8. Making the Scanner Intelligent with Amazon Bedrock

Extracting information is valuable, but we can make the application more useful by adding an intelligence layer.
This is where Amazon Bedrock can help.
Amazon Textract extracts structured information from financial documents.
Amazon Bedrock can use that extracted information to generate explanations, summaries, and recommendations for human review.
For example, imagine the following extracted invoice data:
{
"vendor": "ABC Industrial Supplies",
"invoice_number": "INV-2026-1045",
"invoice_date": "2026-11-08",
"due_date": "2026-11-30",
"subtotal": 1000.00,
"tax": 180.00,
"total": 1180.00,
"currency": "USD"
}
An AI-powered assistant could produce a business-friendly summary:
Invoice Summary

Vendor: ABC Industrial Supplies
Invoice: INV-2026-1045
Invoice Date: November 8, 2026
Due Date: November 30, 2026

Subtotal: $1,000.00
Tax: $180.00
Total: $1,180.00

Review Suggestions:
- Confirm the vendor is registered.
- Check whether the invoice number already exists.
- Verify the tax amount against company policy.
- Confirm that the purchase order matches.
These suggestions are examples of possible application behavior. They are not automatically verified facts.

What intelligent features can we build?

1. Invoice summarization
Generate a short explanation of the invoice for an accounting employee.
2. Possible duplicate detection
Compare extracted invoice details against existing business records and flag potential matches.
3. Missing information detection
Identify required fields that are absent or have low extraction confidence.
4. Expense categorization
Suggest categories such as travel, office supplies, equipment, utilities, or software.
5. Payment prioritization support
Highlight invoices approaching their due dates so finance teams can review them.
6. Business question answering
Allow authorized employees to ask questions such as:
"How much did we spend with this supplier last month?"
"Which invoices are waiting for approval?"
"Show me receipts categorized as travel expenses."
These features can turn a document scanner into a useful business support system.

Keep financial decisions under control

AI-generated suggestions should not be treated as authoritative financial records.
Use deterministic application logic for calculations, totals, currency handling, tax validation, and business rules.
Use Bedrock for explanations and recommendations, and require human approval for payment authorization, accounting changes, and other high-impact decisions.
Where supported, Bedrock structured outputs can help constrain model responses to a defined JSON schema. The application should still validate all returned data before saving or using it.

9. Designing the Structured Financial Record

After extraction and validation, the application needs to save the result in a consistent format.
Amazon DynamoDB can store document metadata, processing status, and normalized invoice records.
For example:
{
"document_id": "doc-1001",
"company_id": "company-001",
"vendor_name": "ABC Industrial Supplies",
"invoice_number": "INV-2026-1045",
"invoice_date": "2026-11-08",
"due_date": "2026-11-30",
"currency": "USD",
"subtotal": 1000.00,
"tax": 180.00,
"total": 1180.00,
"processing_status": "REVIEW_REQUIRED",
"review_reason": "Purchase order verification pending"
}
The example illustrates a normalized business record. A production schema should also preserve the source document location, S3 version information, extraction confidence, processing history, and audit metadata.
The original invoice should remain available in Amazon S3.
The structured record makes it possible to search, filter, and report on financial information without repeatedly reading the original document.

10. Building a Reliable Workflow with AWS Step Functions

Invoice processing involves several stages.
If every stage is implemented inside one large Lambda function, the application can become difficult to maintain and troubleshoot.
AWS Step Functions can coordinate the workflow.
A possible workflow looks like this:
Document Event Accepted
|
v
Start Processing
|
v
Read S3 Document
|
v
Amazon Textract
|
v
Validate Extracted Data
|
v
Check Business Duplicates
|
v
Optional Bedrock Analysis
|
v
Save Structured Record
|
v
Review Required?
/ \
Yes No
| |
v v
Notify Reviewer Mark Ready
| |
+-----+-----+
|
v
Complete Workflow
The workflow can use retries for appropriate transient failures and catch paths for permanent failures.
For asynchronous Textract processing, the workflow can wait for completion notifications or poll for results according to the chosen integration design.
The important point is that each processing stage has a defined responsibility and a visible status.

11. Notifications and Human Approval with Amazon SNS

Not every invoice should be automatically accepted.
Some documents may have missing fields, low-confidence extraction results, unexpected totals, or possible duplicate matches.
Amazon SNS can help notify the relevant team when action is required.
For example:
New Invoice Requires Review
Vendor: ABC Industrial Supplies
Invoice Number: INV-2026-1045
Total: $1,180.00
Status: Review Required
Reason: Purchase order verification pending.
The finance employee can open the original document, review the extracted information, and approve or correct the record through the business application.
A useful design separates document processing from payment approval.
The scanner can prepare and validate information, but payment authorization should remain under the organization's financial controls.

12. Preventing Common Production Problems

A real business system must consider more than successful document extraction.
It also needs to handle failures, duplicate events, retries, and unexpected input.
Here are some important design considerations.

Duplicate event delivery

Use event identity and DynamoDB conditional state transitions to prevent the same S3 event from initiating duplicate work.

Out-of-order processing

Compare sequencer values only for events affecting the same object key. Ensure an older event cannot overwrite a newer accepted state.

Different filenames for the same invoice

Use extracted business fields to identify possible duplicate invoices across different object keys.

Concurrent Lambda executions

Use atomic conditional updates and processing leases rather than relying on ordinary read-then-write logic.

Document version changes

Enable S3 Versioning when version-level traceability is required. Where appropriate, process the exact object version associated with the event instead of simply reading the latest version by key.

Failed document analysis

Record failure status, preserve error details, and provide a controlled retry or manual-review process.

Recursive event triggers

Keep input and output processing paths separate, or use carefully configured EventBridge filters.

Sensitive financial information

Apply encryption, least-privilege IAM permissions, access logging, appropriate retention policies, and tenant-level access controls.
These controls help make the solution reliable enough for real business workflows.

13. A Practical Implementation Roadmap

You do not need to build the entire platform at once.
A useful starting point is a small working prototype.

Phase 1: Document Upload

Create an S3 input bucket and a simple upload interface.
Start with PDF invoices and receipt images.

Phase 2: Event-Driven Processing

Configure S3 events through EventBridge and invoke a Lambda event handler.

Phase 3: Duplicate and Ordering Protection

Create a DynamoDB coordination table and implement sequencer-aware conditional state updates.
Test repeated uploads, corrected documents, and out-of-order event delivery.

Phase 4: Financial Data Extraction

Integrate Amazon Textract  AnalyzeExpense  to extract invoice and receipt information.

Phase 5: Business Validation

Implement deterministic checks for required fields, totals, currency, invoice numbers, and possible duplicate records.

Phase 6: AI Assistance

Integrate Amazon Bedrock to generate summaries, suggest expense categories, and explain possible issues.

Phase 7: Workflow and Notifications

Use AWS Step Functions to coordinate processing and Amazon SNS to notify employees about completed or review-required documents.

Phase 8: Business Dashboard

Build a dashboard that displays document status, vendor information, invoice totals, review queues, and processing history.
Start with a small number of users and documents. Validate the extraction quality and business rules before increasing the workload.

14. What Business Value Can This Create?

A Smart Invoice & Receipt Scanner can help organizations improve several business processes.
Less manual data entry: Employees spend less time copying information from documents into spreadsheets and accounting systems.
Better visibility: Financial documents become structured records that can be searched and analyzed.
Faster review: Finance teams receive organized information and can focus on exceptions instead of reading every document from scratch.
Improved duplicate awareness: The system can detect repeated S3 events and flag possible duplicate business invoices.
More consistent workflows: Document processing, validation, review, and notification follow a defined process.
Better decision support: AI-generated summaries and explanations help employees understand financial documents more quickly.
Actual time savings and financial benefits will depend on document quality, extraction accuracy, workflow design, and the organization's approval processes.

Conclusion: From Scanned Documents to Intelligent Business Support

Invoices and receipts contain valuable information, but manually extracting and organizing that information can slow down business operations.
By combining Amazon S3, Amazon EventBridge, AWS Lambda, Amazon DynamoDB, Amazon Textract, AWS Step Functions, Amazon Bedrock, and Amazon SNS, we can design a smart document-processing system that transforms uploaded files into useful financial information.
The most important lesson from the AWS Storage Blog is that event-driven applications must manage duplicate and out-of-order events carefully.
In a financial workflow, this is not just an optimization. It is a reliability requirement.
Using S3 sequencers, DynamoDB conditional updates, and controlled processing states helps prevent older or duplicate events from corrupting the application's processing state.
Amazon Textract provides the document extraction foundation. Amazon Bedrock can add an intelligent assistance layer. Business rules and human approval keep financial decisions controlled.
The real opportunity is not simply scanning invoices. It is turning everyday business documents into structured information that helps people work smarter and make better decisions.
A receipt should not remain just an image. An invoice should not remain just a PDF.
With the right architecture, both can become useful inputs to an intelligent business workflow.

References and Further Reading



What would you add first to this solution: automatic duplicate invoice detection, AI-powered expense categorization, or an intelligent finance assistant?
I'd love to hear how you would use this architecture in a real business environment.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article