Files · AWS Bedrock Document Pipeline for Magento Invoice Automation
82 (1 binary, 694.7 kB total)attempt 1
README.md·2010 B·markdown
markdown
# AWS Bedrock Document Pipeline for Magento Invoice Automation
> Automatically extract vendor invoice data from PDFs and emails, then reconcile and post them as Magento purchase orders or payments without manual data entry.
## Problem
Small e‑commerce businesses receive dozens of supplier invoices weekly as PDFs or images. Entering each manually into Magento is tedious, introduces errors, and delays payment tracking, causing late fees and stock discrepancies.
## Architecture
```
Webhook → Classification (Confidence Router) → Textract OCR → Bedrock LLM (Claude) → Structured Repair → Magento REST API
```
## Prerequisites
- AWS account with Bedrock + Textract access
- Magento Admin API token
- Langfuse account (optional)
## Environment Variables
| Variable | Description |
|---|---|
| `AWS_REGION` | AWS credentials – region |
| `AWS_ACCESS_KEY_ID` | AWS credentials – access key |
| `AWS_SECRET_ACCESS_KEY` | AWS credentials – secret key |
| `MAGENTO_ADMIN_API_URL` | Magento instance base URL |
| `MAGENTO_INTEGRATION_ACCESS_TOKEN` | Magento API token |
| `LANGFUSE_PUBLIC_KEY` | Langfuse observability config |
| `LANGFUSE_SECRET_KEY` | Langfuse observability config |
| `LANGFUSE_BASE_URL` | Langfuse observability config |
| `SESSION_STORAGE_TYPE` | Session backend (default: memory) |
| `PORT` | Application port |
| `NEXT_PUBLIC_APP_URL` | Public-facing application URL |
## API Endpoints
- `POST /api/webhook/invoice` — Upload invoice / packing slip / remittance document
- `GET /api/health` — Health check
## Quick Start
```bash
pnpm install
cp .env.example .env
# update .env with your values
pnpm dev
```
## Project Structure
```
app/api/ Next.js API route handlers
src/pipeline/ Document processing pipeline stages
src/services/ Shared services (AWS, Magento, Langfuse)
tests/ Vitest test suite (mirrors src/)
```
## Testing
```bash
pnpm test # vitest run with coverage
```
## License
MIT — see [LICENSE](./LICENSE).