How krama/ocrmypdf-test-task works
Main Components
• Frontend – The "frontend" directory (with app.js, index.html, style.css) indicates a web interface. This user interface is responsible for interacting with users (uploading PDFs, displaying results).
• API Gateway – Defined in the api-gateway.tf file, this acts as the entry point for API calls.
• Dockerized OCR Processor – The Docker directory consists of a Dockerfile and a Python script (ocr_processor.py) that performs OCR processing, likely deployed to Amazon ECS. Terraform configuration files (ecs.tf, ecr.tf) support container orchestration and image repository management.
• Lambda Functions – The lambda directory contains scripts like file_updater.py and file_uploader.py, and additional Terraform files (lambda-upload.tf, lambda-status.tf) define these. Lambdas are used for tasks such as file updates and upload events.
• Storage and Website Hosting – S3 is referenced via s3.tf and s3-website.tf. This service is used both for storing files and possibly hosting the frontend.
• Additional AWS Services – Other Terraform files (iam.tf, vpc.tf, sns.tf, sqs.tf, providers.tf, variables.tf, outputs.tf) indicate the configuration of security, networking (VPC), messaging (SNS/SQS) and other deployment-related settings.
Relationships and Interactions
• The User interacts with the Frontend (web interface).
• The Frontend makes REST calls via API Gateway.
• The API Gateway routes requests to various backend services:
• Some requests trigger Lambda functions (for uploading and status updates).
• Other requests might be forwarded to the Dockerized OCR processor hosted on ECS, which reads images from S3 or processes incoming payloads.
• The OCR Processor container can communicate with other components (e.g., sending messages to SNS/SQS) to trigger workflow events.
• The S3 bucket serves dual roles: hosting the static frontend (via s3-website.tf) and storing PDFs or processed files.
• IAM, VPC, and other configuration files ensure that all these services securely interact according to AWS best practices.
Architectural Patterns and Principles
• Microservices/Serverless: The project clearly separates responsibilities (frontend, Dockerized OCR service, and lambdas) which aligns with modern microservice and serverless architectures.
• Infrastructure as Code: Use of Terraform files for each AWS service (ECR, ECS, Lambda, S3, etc.) emphasizes a declarative approach to infrastructure management.
• Containerization: Dockerization is used for packing and deploying the OCR processor, which simplifies scalability and consistency.
• Event-Driven Workflow: The integration of SNS/SQS and Lambda functions suggests an event-driven architecture where asynchronous processing is leveraged.
Relevant Technologies, Frameworks, and Libraries
• AWS Services: API Gateway, ECS/ECR, Lambda, S3, IAM, VPC, SNS, SQS.
• Docker: Containerization for running the OCR processing logic.
• Web Technologies: HTML, JavaScript, and CSS for the frontend interface.
• Terraform: Infrastructure as Code to handle AWS resource definitions.
• Clear labels with each component’s name and their role (Frontend, API Gateway, OCR Processor, Lambda – File Uploader, Lambda – File Updater, S3 Storage, Messaging Services, etc.).
• Notations for security (IAM) and networking (VPC) as foundational layers that all services rely on.
• Deployment and orchestration elements indicating container management (ECS/ECR) and infrastructure provisioning (Terraform).