Full-stack, Dockerized invoice processing system with FastAPI, PostgreSQL, OCR, and a React dashboard.
- Invoice upload: PDF / PNG / JPG via
POST /invoices/upload - OCR & parsing: Tesseract +
pdfplumberwith regex-based field extraction - Database: PostgreSQL + SQLAlchemy + Alembic
- Dashboard: React (Vite) UI for uploads and browsing invoices with pagination
- Email summary: Daily summary at 18:00 UTC with CSV attachment
- Dockerized: Backend, frontend, and Postgres in
docker-compose
backend/– FastAPI app, models, services, Alembic, Dockerfilefrontend/– React (Vite-style) app and Dockerfiledocker-compose.yml– Multi-container stack.env.example– Example environment variables
- Docker and Docker Compose
- Copy
.env.exampleto.envin the project root and adjust values:
cp .env.example .env- Ensure your SMTP settings are valid if you want daily summary emails.
From the invoice-rpa directory:
docker compose up --buildServices:
- Frontend:
http://localhost:3000 - Backend API docs (Swagger):
http://localhost:8000/docs - Backend health:
http://localhost:8000/health
- Main app:
app/main.py - Config:
app/config.py(reads env vars, upload dir, SMTP, DB URL) - DB models:
models/invoice.py - Schemas:
app/schemas.py - Routers:
routers/invoices.pyPOST /invoices/upload– multipart upload, saves file, runs OCR, parses fields, stores invoice withVALID/PARTIAL/FAILEDstatus.GET /invoices– paginated list (query paramspage,page_size).
- Services:
services/ocr_service.py– PDF/image OCRservices/invoice_extraction.py– regex-based extraction + status classificationservices/email_service.py– builds and sends daily summary email + CSVservices/scheduler.py– APScheduler daily job at 18:00 UTC
Alembic is configured under backend/alembic with an initial migration to create the invoices table.
- Vite-style React app with:
- Upload form with loading/error states
- Invoice table with vendor, date, amount, status, created time
- Pagination (Previous/Next, page count)
- Uses Axios to call:
GET /invoices?page=&page_size=POST /invoices/uploadwithmultipart/form-data
- API base URL is controlled by:
VITE_API_BASE_URLenv (Docker sets this tohttp://backend:8000)
- Files are stored under
/app/uploadsin the backend container, mapped to theuploadsvolume. - Logging is configured with structured output to stdout.
- Error handling uses FastAPI exceptions and try/except in services.