Skip to main content

Gupshup (WhatsApp)

Gupshup receives WhatsApp messages and sends replies on behalf of the business number. Required env vars:
Order flow:
  1. Customer sends an order via WhatsApp
  2. Gupshup forwards it to POST /gupshup_incoming_webhook
  3. Backend validates the sender against ALLOWED_PHONE_NUMBERS
  4. Message is sent to OpenAI for parsing
  5. An OrderDraft is created
  6. A WhatsApp confirmation is sent back to the customer
  7. 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:
  1. Upload a photo or PDF of a khata page via POST /khata-upload or /khata-upload-v2
  2. Backend converts PDF to image using pdf2image if needed
  3. OCR extracts transaction data
  4. User reviews in a multi-step UI: UploadStepReviewStepAssignStep
  5. On submission, entries are posted to the relevant party ledgers

PDF Generation

PDFs are generated server-side using reportlab via pdf_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)
Configured in backend/src/sj/__init__.py using FastAPI’s CORSMiddleware.