AWS Builder Center
Weekend Productivity Challenge: FactoryLens — AI Document Analyzer

Weekend Productivity Challenge: FactoryLens — AI Document Analyzer

FactoryLens is a serverless AI tool that turns manufacturing paperwork such as SOPs, quality reports, incident logs, etc., into instant, structured insights: drag in a PDF or scan, and it extracts the text, classifies the document, and flags issues like non-conformances or downtime with suggested actions. Built entirely on AWS Free Tier services, it delivers results live through a simple drag-and-drop web interface, with no dashboards or manual review required.

Vision & What the App Does
Anyone who has worked in food and drink manufacturing knows the paperwork problem: SOPs, quality reports, incident logs, and shift summaries pile up as PDFs and scanned printouts, and the insights buried inside them; deviations, non-conformances, downtime, and complaints, get read once and forgotten.
FactoryLens turns that pile of documents into a searchable, instant-response knowledge base. From a user's perspective, it's a single web page: drag a PDF or photo onto a drop zone, and within seconds the system extracts the text (including form fields and tables), classifies the document as an SOP, quality report, incident log, or production summary, flags any issues it finds with the evidence snippet and a suggested corrective action and displays the result live on screen. No dashboard to open, no CLI, no waiting for a report; just drop a file and watch the analysis appear.
How I Built It
I built the whole pipeline serverless and event-driven, then added a static front end on top so it's usable without touching a terminal.
The backend was the first weekend: an S3 upload triggers everything; no servers or schedules are involved. PDFs route through Textract's async API with in-Lambda polling, since the sync API only handles single-page documents. I use a Python keyword‑scoring rule engine for classification and issue detection instead of a custom Comprehend model, avoiding hourly endpoint costs while keeping the system free, transparent, and fully adaptable to manufacturing terminology.
The second piece was the upload interface: a single HTML/CSS/JS file hosted on S3 static website hosting, with a small new Lambda that hands the browser a short-lived presigned S3 URL so files upload directly to storage rather than through the Lambda. The page then polls the existing query API every few seconds until the result lands.
The trickiest part wasn't the AI pipeline; it was CORS. Because the browser, the API, and the storage bucket are three separate origins, I hit two distinct CORS failures in sequence: first the API Gateway route blocking the preflight request, then the S3 bucket itself blocking the direct file upload. Each needed its own CORS configuration, which was a useful reminder that "serverless" still means several independent trust boundaries to wire up correctly.


┌─────────────────────────────────────────┐
                                   │                AWS Cloud                │
  ┌──────────┐   upload            │                                         │
  │   User    │────────────────────▶│  S3 bucket                              │
  └──────────┘   (incoming/)       │  ├── incoming/    ◀── uploads land here │
       │                           │  └── processed/   ◀── analysis JSON     │
       │                           │        ▲                                │
       │                           │        │ S3 event (prefix: incoming/) │
       │                           │        ▼                                │
       │                           │  Lambda: doc-analyser-processor         │
       │                           │ 1. Textract  → text, forms, tables   │
       │                           │ 2. Comprehend → phrases, entities │
       │                           │                    sentiment            │
       │                           │ 3. Rule engine → classify + issues   │
       │                           │    4. Write → DynamoDB + processed/     │
       │                           │        │                                │
       │                           │        ▼                                │
       │   GET /documents          │  DynamoDB: DocumentAnalysis             │
       └──────────────────────────▶│        ▲                                │
           via API Gateway         │        │                                │
           (HTTP API)              │  Lambda: doc-analyser-query             │
                                   └─────────────────────────────────────────┘
FactoryLens AI Tool Architecture
**** 
AWS Services Used / Architecture Overview
Browser → S3 (static site) → API Gateway → Lambda → Textract/Comprehend → DynamoDB → API Gateway → Browser
  • Amazon S3 — document intake (incoming/), analysis output (processed/), and a separate bucket for static website hosting of the upload page
  • AWS Lambda (Python) — three functions: document processor (Textract + Comprehend + rules), query API, and presigned-upload-URL generator
  • Amazon Textract — OCR plus key-value and table extraction
  • Amazon Comprehend — key phrases, entities, sentiment
  • Amazon DynamoDB — one structured item per document, with a GSI for querying by type
  • API Gateway (HTTP API) — GET /documents, GET /documents/{id}, GET /issues, POST /upload-url, with CORS enabled for the frontend origin
Everything runs in eu-west-2 and sits comfortably inside the Free Tier at personal volume.
What I Learned
Beyond the AWS-service mechanics, Textract's block-graph response model, and Comprehend's per-call unit budgeting, the real lesson was architectural: presigned URLs are the right pattern for browser uploads (no file size limits, no base64 overhead through Lambda), but they introduce CORS as a first-class design concern rather than an afterthought. I also learned that Free Tier small print matters in practice: Textract's forms-and-tables allowance is a three-month trial, not twelve, which shaped the USE_FORMS_AND_TABLES toggle in the processor.
Link to App or Repo
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