AWS SAM Python 3.11 License: MIT
A fully serverless document processing pipeline built on AWS. Upload PDFs or images to S3 — Lambda automatically triggers AWS Textract for OCR — extracted text is stored in DynamoDB — and SNS notifications alert downstream consumers when processing completes.
Designed with event-driven architecture, IAM least-privilege policies, and infrastructure-as-code via AWS SAM.
[S3 Upload] → [Lambda: ProcessDocument] → [AWS Textract]
↓
[API Gateway] ← [Lambda: GetDocument] ← [DynamoDB: Results]
↓
[SNS Notification]
- Event-driven S3 triggers — automatic processing on file upload
- AWS Textract OCR — extract text from PDFs, images, and scanned documents
- DynamoDB storage — document metadata and extracted text with TTL cleanup
- REST API — retrieve documents and results via API Gateway
- SNS notifications — real-time alerts on processing completion or failure
- IAM least-privilege — each Lambda gets only the permissions it needs
- Pagination support — efficiently list large document collections
- X-Ray tracing — built-in observability for all Lambda functions
| Method | Endpoint | Description |
|---|---|---|
| GET | /documents |
List all processed documents |
| GET | /documents/{documentId} |
Get document details and results |
- AWS CLI configured with credentials
- AWS SAM CLI
- Python 3.11+
sam build sam deploy --guided
On first deploy, SAM will walk you through configuration (stack name, region, etc.). Subsequent deploys use the saved samconfig.toml.
aws s3 cp my-document.pdf s3://<DocumentsBucketName>/uploads/my-document.pdf
intelligent-doc-engine/
├── template.yaml # SAM infrastructure template
├── samconfig.toml # Deployment configuration
├── handlers/
│ ├── __init__.py
│ ├── process_document.py # S3 trigger → Textract
│ ├── store_results.py # Textract results → DynamoDB
│ ├── get_document.py # GET /documents/{id}
│ ├── list_documents.py # GET /documents
│ └── requirements.txt
├── tests/
│ └── test_process_document.py
├── README.md
└── LICENSE
pip install pytest boto3 pytest tests/ -v
This project is designed to stay within the AWS Free Tier for low-volume usage:
| Service | Free Tier Allowance |
|---|---|
| Lambda | 1M requests / 400,000 GB-seconds |
| DynamoDB | 25 GB storage / 25 RCU / 25 WCU |
| S3 | 5 GB storage / 20,000 GET requests |
| Textract | 1,000 pages/month (first 3 months) |
| SNS | 1M publishes / 100,000 HTTP delivers |
| API Gateway | 1M REST API calls/month |
Note: Textract free tier is limited to the first 3 months. Monitor usage in the AWS Billing Dashboard.
Kushal Pitaliya
This project is licensed under the MIT License — see the LICENSE file for details.