TaxHacker
TaxHacker copied to clipboard
draft - feat: Paperless-ngx integration (import/export)
Summary
Adds bidirectional integration with Paperless-ngx, a self-hosted document management system. Closes #39.
- Import: Browse, search, and select documents from Paperless-ngx. Downloads files into TaxHacker's unsorted queue for AI analysis.
- Export: Upload transaction files to Paperless-ngx with tag and correspondent mapping from the bulk actions menu.
- Settings: New settings page at
/settings/paperlesswith URL, API token, enable toggle, and connection test button. - Deduplication: Tracks
paperlessDocumentIdon the File model to prevent duplicate imports/exports. - Security: All API calls are server-side (server actions), URL validated for SSRF prevention, 30s request timeouts.
New files
lib/paperless/— Typed API client (native fetch, auth, pagination, error handling)app/(app)/settings/paperless/— Settings page + test connection actionapp/(app)/import/paperless/— Import page + server actionsapp/(app)/export/paperless/— Export server actionscomponents/settings/paperless-settings-form.tsx— Settings formcomponents/import/paperless.tsx— Import UI (browse, search, select, paginate)components/export/paperless-export-dialog.tsx— Export dialog with tag/correspondent selectiondocs/paperless-ngx.md— Full documentation- Prisma migration adding
paperless_document_idtofilestable
Modified files
prisma/schema.prisma—paperlessDocumentIdfield + index on File modelforms/settings.ts— Paperless fields in settings Zod schemaapp/(app)/settings/layout.tsx— "Paperless-ngx" in settings navmodels/files.ts—getFileByPaperlessDocumentId()querycomponents/sidebar/sidebar.tsx— "Import from Paperless" sidebar linkcomponents/transactions/bulk-actions.tsx— "Export to Paperless" buttoncomponents/transactions/list.tsx+app/(app)/transactions/page.tsx— Pass Paperless enabled flag
Test plan
- [ ] Run
npx prisma migrate dev— migration applies cleanly - [ ]
npm run build— no type errors (verified) - [ ] Settings: configure URL + token, save, test connection shows document count
- [ ] Import: browse documents with search/pagination, import selected, verify in
/unsorted - [ ] Import: re-import same documents — verify they are skipped (deduplication)
- [ ] Export: select transactions, export to Paperless with tags/correspondent, verify in Paperless
- [ ] Export: re-export same files — verify already-uploaded files are skipped
- [ ] Sidebar shows "Import from Paperless" link
- [ ] Bulk actions show "Export to Paperless" only when Paperless is configured
🤖 Generated with Claude Code