Author: Mateen Qureshi
Think of Stampd as a smart API gateway for enterprise cash flow, or a high-speed automated sorting machine in a mailroom. It intercepts raw, incoming packages (OCR invoice data), scans the barcode against our internal records (the Database), and instantly pushes the package down the correct conveyor belt—straight to the approving manager or into a reject bin.
Stampd is a headless routing engine that reduces the Procure-to-Pay cycle. It:
- Ingests unstructured invoice metadata via a webhook (simulated by Postman).
- Validates the data by executing deterministic 3-way matching logic against a mock ERP database.
- Routes the approval by returning actionable Approve/Reject statuses based on the amount threshold and Purchase Order existence.
graph TD
A[OCR Scanner / Postman] -->|JSON Webhook POST| B(InvoiceController)
B -->|Maps to IncomingInvoiceDto| C{InvoiceRoutingService}
C -->|Validates PO| D[(PostgreSQL Database)]
D -.->|Returns PO & Manager Data| C
C -->|PO Not Found| E[FALLBACK: Exceptions Queue]
C -->|Amount Mismatch| F[WARNING: Flag for Review]
C -->|Perfect Match| G[SUCCESS: Route to Manager]
- Backend Framework: Java (Spring Boot 3) - The core engine handling webhooks and logic.
- Database: PostgreSQL - The strict, relational mock ERP holding Managers, Vendors, and POs.
- ORM: Spring Data JPA (Hibernate) - Translates Java objects into SQL database rows.
- Dependencies: Maven (Build Tool), Lombok (Ghostwriter for boilerplate getters/setters), Spring Web (REST APIs).
- Java Development Kit (JDK 17 or higher): Required to run Spring Boot.
- PostgreSQL & pgAdmin 4: The database engine and visual interface.
- IntelliJ IDEA (or Eclipse): IDE with built-in Maven support.
- Postman: To send simulated webhook payloads.
- Open pgAdmin 4 and log in.
- Expand your server, right-click Databases -> Create -> Database...
- Name it exactly
stampd_dband save.
- Clone this repository to your local machine.
- Open the folder as a Maven Project in IntelliJ.
- The
application.propertiesfile uses a masked password for security. Set your local environment variable to connect to your database:- In IntelliJ, click the Edit Configurations... dropdown near the Run button.
- In Environment variables, add:
DB_PASSWORD=your_actual_postgres_password
- Hit the green Play button in IntelliJ to run
RouterApplication.java. (TheDatabaseSeederwill automatically inject dummy test data on the first run). - Open Postman and create a POST request to
http://localhost:8080/api/invoices/webhook. - Set the Body to raw -> JSON and send the payload:
{ "poNumber": "PO-98765", "totalAmount": 2500.00, "vendorName": "Dell Technologies" } - Check the response for the
SUCCESSrouting message!