Gupshup (WhatsApp)
Gupshup receives WhatsApp messages and sends replies on behalf of the business number. Required env vars:- Customer sends an order via WhatsApp
- Gupshup forwards it to
POST /gupshup_incoming_webhook - Backend validates the sender against
ALLOWED_PHONE_NUMBERS - Message is sent to OpenAI for parsing
- An
OrderDraftis created - A WhatsApp confirmation is sent back to the customer
- Staff review and convert the draft at
/order-drafts
OpenAI
OpenAI is used with structured output (JSON mode) to parse unstructured WhatsApp order messages into typed order entries. Used in:services.py / gupshup_incoming_webhook.py
Required env var:
Khata OCR
Processes scanned/photographed hand-written ledger pages. Flow:- Upload a photo or PDF of a khata page via
POST /khata-uploador/khata-upload-v2 - Backend converts PDF to image using
pdf2imageif needed - OCR extracts transaction data
- User reviews in a multi-step UI:
UploadStep→ReviewStep→AssignStep - On submission, entries are posted to the relevant party ledgers
PDF Generation
PDFs are generated server-side using reportlab viapdf_service.py.
The
side parameter accepts in or out. All responses return Content-Type: application/pdf and trigger a browser download.
HTTP Client (Frontend)
The Axios instance (src/lib/axiosInstance.ts) is configured with:
CORS
The backend allows requests from:http://localhost:5173(Vite dev server)http://localhost:3000- Production EC2 domain (
ec2-15-207-84-167.ap-south-1.compute.amazonaws.com)
backend/src/sj/__init__.py using FastAPI’s CORSMiddleware.