AI Document Processing with AWS Textract, Lambda and Alfresco: Complete Architecture
AI document processing with AWS Textract, Lambda and Alfresco turns scanned PDFs, invoices and business forms into structured, searchable enterprise records. This hands-on architecture guide explains how to build an asynchronous pipeline, connect it to Alfresco Content Services (ACS), validate extracted fields and prepare the integration for production.
Quick answer: Keep Alfresco as the system of record. Send a securely staged document to Amazon S3, start Amazon Textract from AWS Lambda, process the completion notification through SNS and SQS, validate the extracted data, and update Alfresco metadata using its REST API. Route uncertain fields to human review rather than writing them automatically.
1. What is AI document processing?
Intelligent document processing (IDP) combines OCR, document structure analysis and business rules to convert unstructured files into structured information. Amazon Textract can extract text, forms, tables, signatures and layout information, depending on the API and selected features. Alfresco supplies content governance, version control, permission management and searchable metadata.
This combination is useful when organizations already run Alfresco and want document intelligence without replacing the repository. Examples include invoice ingestion, purchase orders, onboarding forms, customer applications and contract intake.
2. AWS Textract, Lambda and Alfresco architecture
For production-scale workflows, separate ingestion from extraction and repository updates. The pipeline uses these components:
| Component | Responsibility |
|---|---|
| Alfresco Content Services | Stores original document, permissions and approved metadata |
| Amazon S3 | Private staging area for files sent to Textract |
| Starter Lambda | Creates Textract job and persists correlation IDs |
| Amazon Textract | Detects text and analyzes forms/tables |
| Amazon SNS + SQS | Delivers job completion reliably to consumers |
| Result Lambda | Gets all pages of results, validates fields and updates Alfresco |
| DynamoDB / equivalent | Tracks node ID, document version, job ID and processing state |
| CloudWatch + DLQ | Supports monitoring, retries and failure investigation |
The integration service must fetch Alfresco content through an approved API or event-driven process; simply storing an original file in Alfresco does not automatically send it to Textract.
3. Step-by-step document processing lifecycle
- Ingest: A user or business service uploads a document into Alfresco.
- Stage securely: A trusted integration retrieves the document and places a temporary copy in a private S3 bucket.
- Start extraction: Lambda invokes with the S3 location and enabled feature types.
StartDocumentAnalysis - Track: Persist the Textract job ID and its matching Alfresco node ID and version in durable storage.
- Receive completion: Textract publishes status to SNS; SQS buffers it for the result Lambda.
- Read results: On , Lambda calls , following every pagination token.
SUCCEEDEDGetDocumentAnalysis - Validate: Map keys to business fields and check confidence, mandatory values and formatting.
- Commit or review: Update Alfresco metadata for approved values; send uncertain results to a reviewer.

4. Choose the correct Textract API
Do not use a single extraction API for every document. is suited to asynchronous OCR, handles forms and tables, and is designed for invoices and receipts. For this tutorial, we use asynchronous with and . The AWS service supports PDF, TIFF, JPEG and PNG inputs for this operation.StartDocumentTextDetectionStartDocumentAnalysisStartExpenseAnalysisStartDocumentAnalysisFORMSTABLES
5. AWS prerequisites and security baseline
- An AWS account and a supported Region for Textract.
- A private input S3 bucket with public access blocked, TLS and suitable server-side encryption.
- Two Lambdas with independent least-privilege IAM roles.
- An SNS topic and an SQS subscription for completion notifications.
- An IAM role allowing Textract to publish to the SNS topic, passed by the starter Lambda.
- A DynamoDB table or comparable database for job correlation and idempotency.
- A securely reachable Alfresco REST endpoint and a secret stored in AWS Secrets Manager, not in code.
- SQS redrive settings, a dead-letter queue and CloudWatch alarms.
Use private connectivity or an approved secured integration route from Lambda to Alfresco. Never open an internal Alfresco repository endpoint to the internet just for this integration.
6. Python Lambda: start asynchronous AWS Textract analysis
This example assumes that an upstream integration has already placed the document in S3. Configure the SNS topic and Textract notification role before running it.
import os
import boto3
textract = boto3.client("textract")
def lambda_handler(event, context):
bucket = event["bucket"]
key = event["key"]
response = textract.start_document_analysis(
DocumentLocation={
"S3Object": {"Bucket": bucket, "Name": key}
},
FeatureTypes=["FORMS", "TABLES"],
NotificationChannel={
"SNSTopicArn": os.environ["SNS_TOPIC_ARN"],
"RoleArn": os.environ["TEXTRACT_ROLE_ARN"]
}
)
job_id = response["JobId"]
# Persist job_id -> Alfresco node ID/version in your
# durable job store before processing the result.
return {"jobId": job_id, "status": "STARTED"}Important: This is the extraction starter, not a complete event-ingestion or idempotency implementation. A real deployment should validate the input event, apply an idempotency key, persist correlation state and recover safely from a partial failure between starting the job and saving its ID.
7. Python Lambda: read all Textract result pages
When a successful SNS completion message arrives through SQS, extract its , look up the matching Alfresco node and call the following helper. The caller must parse the SNS envelope in the SQS body and handle redeliveries.JobId
import boto3
textract = boto3.client("textract")
def get_blocks(job_id):
blocks = []
token = None
while True:
args = {"JobId": job_id, "MaxResults": 1000}
if token:
args["NextToken"] = token
result = textract.get_document_analysis(**args)
if result["JobStatus"] != "SUCCEEDED":
raise RuntimeError(result["JobStatus"])
blocks.extend(result.get("Blocks", []))
token = result.get("NextToken")
if not token:
return blocks
Do not repeatedly poll Textract for every running job. AWS recommends using job-completion notifications for asynchronous operations. In production, also handle and statuses according to business rules.FAILEDPARTIAL_SUCCESS
8. Convert Textract blocks into usable metadata
Textract returns structured blocks and relationships rather than one ready-made business object. The mapper must resolve relationships and normalize values. For a basic first pass, you can inspect detected text lines:KEY_VALUE_SET
def extract_lines(blocks):
return [
{"text": b.get("Text", ""),
"confidence": b.get("Confidence", 0),
"page": b.get("Page")}
for b in blocks
if b.get("BlockType") == "LINE"
]
This helper is for OCR inspection, not an invoice field parser. A production mapper should follow block relationships, apply document-specific rules, and normalize dates, currency and numeric values. For invoice-focused extraction, consider instead.StartExpenseAnalysis
9. Alfresco REST API: update custom properties
Define and deploy a custom Alfresco content model first; assume an aspect with properties such as , , and . Apply the aspect to the document and then update the node:idp:documentidp:invoiceNumberidp:supplierNameidp:confidenceidp:processingStatus
curl -X PUT \
"https://alfresco.example.com/alfresco/api/-default-/public/alfresco/versions/1/nodes/NODE_ID" \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"properties": {
"idp:invoiceNumber": "INV-2026-0451",
"idp:supplierName": "Example Supplier",
"idp:confidence": 98.2,
"idp:processingStatus": "COMPLETED"
}
}'The bearer-token example works only where the configured authentication integration accepts such a token. Other Alfresco environments use different authentication mechanisms. Updating metadata does not necessarily make the entire OCR body searchable: full-text OCR indexing needs a separate, version-compatible design.
10. Human validation and confidence thresholds
A confidence score is a model signal, not proof that a business field is correct. For example, a 95% extraction score does not prove that an invoice total matches the purchase order. A realistic validation policy checks required fields, vendor master data, duplicate invoice IDs, date formats, tax totals and page completeness.
An illustrative review policy might send fields below a locally tested threshold to human review, but no single confidence cutoff is universally correct. Build thresholds using labeled documents and measure precision for each field type. Approved corrections can become audit events and feedback for future improvements.
11. Production reliability: retries, duplicate events and indexing
- Idempotency: Correlate source node ID, content version, S3 object version and extraction job. Guard transitions to avoid reprocessing the same document.
- Retries: Use exponential backoff for throttling and temporary network errors. Make Alfresco updates safe to repeat.
- Dead-letter queue: Preserve failed messages for controlled replay and investigation.
- Concurrency: Limit starter and consumer Lambda concurrency according to Textract quotas and Alfresco throughput.
- Retention: Apply lifecycle rules to temporary S3 copies and configure output retention according to policy.
- Search validation: Verify that your Alfresco search stack indexes custom metadata and that permissions remain enforced.
- Observability: Log correlation IDs, duration, document counts and errors, but never entire confidential documents.
Asynchronous Textract results are available for seven days by default through the retrieval API; configure an appropriate output strategy if your retention requirement is longer.
12. Security and cost optimization
Encrypt S3 input and any retained results, restrict IAM policies, protect credentials in Secrets Manager and verify AWS Region, residency and document retention requirements. Cost depends mainly on processed pages, chosen Textract API/features, storage, Lambda execution, notifications and operational services. Avoid sending every file through expensive forms-and-tables analysis when basic OCR is enough.
13. Common integration issues
| Problem | What to check |
|---|---|
| AccessDeniedException | Textract, S3, KMS, SNS role and iam:PassRole permissions |
| InvalidS3ObjectException | S3 object key, encryption, access and Region |
| Duplicate updates | SQS redelivery, idempotency and job-state transitions |
| Alfresco 401/403 | Authentication, token support, node permissions and network path |
| Unknown Alfresco property | Custom model deployment, namespace and applied aspect |
| Document not searchable | Indexer health, metadata indexing and OCR text ingestion strategy |
14. Frequently asked questions
Can AWS Textract integrate directly with Alfresco?
Yes, through a custom integration service, Lambda or containerized middleware. There is no need to replace Alfresco as the enterprise content repository.
Can Textract process multi-page PDF files?
Yes. Use the relevant asynchronous API for multipage PDF processing and consume its completion status before requesting results.
Is Lambda required?
No. Java/Spring Boot services or container workers can run the same orchestration logic. Lambda is attractive for event-driven workloads with variable volume.
Does Textract replace Alfresco Search Services?
No. Textract extracts information; Alfresco and its configured search/indexing services provide repository search, metadata lookup and access control.
What happens when extraction is wrong?
Validate against business rules, route questionable fields for review and keep an auditable record of corrections before updating authoritative metadata.
15. Recommended reading
- Alfresco AWS Deployment Architecture: AI Document Processing with Amazon Textract — introductory architecture, AWS configuration and cost context.
- Alfresco on AWS Deployment Architecture (2026): EC2, EKS, S3 & Cost Optimization — deployment and infrastructure design.
- Alfresco Deployment Architecture on AWS — French-language architecture guide.
Conclusion
A reliable AI document processing architecture using AWS Textract, Lambda and Alfresco is more than an OCR API call. It requires secure staging, event-driven completion, durable correlation, field-level validation, human review, metadata governance and operational recovery. Keeping Alfresco as the system of record while AWS handles extraction creates a flexible integration pattern for modern ECM platforms.
📢 Need help with Java, workflows, or backend systems?
I help teams design scalable, high-performance, production-ready applications and solve critical real-world issues.
Services:
- Java & Spring Boot development
- Camunda Training / consulting
- Alfresco Training / consulting
- Workflow architecture guidance
- Workflow implementation (Camunda, Flowable – BPMN, DMN)
- Backend & API integrations (REST, microservices)
- Document management & ECM integrations (Alfresco)
- Performance optimization & production issue resolution
🔗 https://shikhanirankari.blogspot.com/p/professional-services.html
📩 Email: ishikhanirankari@gmail.com | info@realtechnologiesindia.com
🌐 https://realtechnologiesindia.com
✔ Available for quick consultations
✔ Response within 24 hours
🎥 Learn IT with Shikha on YouTube
Prefer learning through videos? Watch practical tutorials on Kafka, Camunda, Alfresco, Java, Spring Boot, Microservices and Enterprise Architecture.▶ Subscribe to Learn IT with Shikha on YouTube

Comments
Post a Comment