All writing

Python · FastAPI · OCR

Building an OCR scan-and-win campaign with FastAPI

UCC wanted to reward people who bought TOTOLINK routers: buy a product, enter the campaign, spin for a prize. The hard part of any campaign like this is fairness. If entry only asks for typed details, people invent serial numbers and enter many times.

So the UCC Scan & Win site asks for proof instead of trust.

The five steps

  1. Purchase: the buyer gets a TOTOLINK product with the official UCC sticker.
  2. Details: name, phone number, invoice number and serial number.
  3. Photos: a photo of the invoice and a photo of the serial number.
  4. Verify: a one-time code sent by SMS confirms the phone number.
  5. Spin: only then can the buyer spin to win.

Where OCR comes in

When the photos arrive, OCR (optical character recognition) reads the text in them. The details it finds are compared with what the buyer typed. If the serial number in the photo does not match the one in the form, the entry does not go through.

This catches honest mistakes as well as invented entries, and it saves the UCC team from checking every photo by hand.

Why FastAPI

The frontend is Next.js, and the backend is Python with FastAPI. Python has the strongest tools for image processing and OCR, so it made sense for the part of the system that handles photos. FastAPI is a good fit on top of that:

  • It handles file uploads and many requests at once without fuss.
  • Request data is checked against clear types, so bad input is rejected early.
  • It produces API documentation automatically, which makes the frontend easier to build against.

Built for real buyers

Buyers enter from their phones, often in a shop right after buying. The site is in Bangla and English, the steps are numbered, and each screen asks for one thing. A countdown shows how long the campaign runs and the prize table shows what can be won, so people know the offer is real before they start.

Campaigns run for a short time and attract sudden traffic, so the flow has to be simple and dependable on the first day, not just the tenth.

More writing