Files · Mistral AI Invoice Reconciliation for Stripe
35 (1 binary, 5304.2 kB total)attempt 4
README.md·1454 B·markdown
markdown
# Mistral AI Invoice Reconciliation for Stripe
Automatically extracts structured data from PDF invoices and reconciles them against Stripe transactions, flagging discrepancies for your finance team.
## Architecture
```
PDF Upload → unpdf/tesseract OCR → Confidence Router classification
→ Mistral LLM extraction → jsonrepair validation
→ Stripe reconciliation → Discrepancy report email
```
## Setup
1. Copy `.env.example` to `.env` and fill in values.
2. Run `pnpm install`.
3. Run `pnpm typecheck` and `pnpm lint`.
4. Start the server with `node dist/server.js` after building, or use `tsx src/server.ts`.
## Environment Variables
| Variable | Description |
|----------|-------------|
| `MISTRAL_API_KEY` | Mistral API key |
| `STRIPE_SECRET_KEY` | Stripe secret key |
| `EMAIL_HOST` | SMTP host |
| `EMAIL_PORT` | SMTP port |
| `EMAIL_USER` | SMTP username |
| `EMAIL_PASS` | SMTP password |
| `EMAIL_FROM` | From address for emails |
| `BUDGET_PER_FILE_LIMIT` | Max spend per file in USD |
| `MISTRAL_MODEL` | Mistral model ID |
| `ROUTE_THRESHOLD` | Confidence threshold to route |
| `FALLBACK_THRESHOLD` | Confidence threshold to fallback |
| `UPLOAD_MAX_SIZE` | Max upload size in bytes |
| `PORT` | Server port |
## API Usage
Upload a PDF invoice:
```bash
curl -X POST http://localhost:3000/upload \
-F "file=@invoice.pdf" \
-F "email=finance@example.com"
```
## Testing
```bash
pnpm test
```
## License
MIT