work/closeby/
CloseBy
Local shop platform for Guna, with AI tools that take routine work off shop owners
Solo: design, frontend, backend, AI layer · 2026

Manual work before
Shop owners type every product by hand, keep stock in their heads, and answer the same buyer questions all day. Unpaid orders and refunds are chased by hand.
What it automates
- -Stock entry from photos and voice lists
- -Restock and price ideas
- -Draft chat replies
- -Cancelling unpaid orders
- -Refunds for rejected orders
The workflow
- triggerThe owner uploads a shelf photo or a voice list of stock.
- step 1The AI reads the catalogue through tools and drafts a stock import.
- step 2The owner reviews the draft and approves it. Nothing is saved before that.
- step 3Buyers nearby find the shop through geohash search and place an order.
- step 4The order moves through a seven-state machine. Razorpay holds stock until the server confirms payment.
- step 5Unpaid orders cancel after 15 minutes. Rejected paid orders are refunded automatically.
- outcomeCatalogue entry, order tracking, payment checks and refunds run on their own; the owner only approves.
status Live demo.
In short
- -Every AI call passes one gateway: auth, rate limit, kill switch, daily spend cap, input cleaning, tool loop, cost logging.
- -AI only drafts (stock imports, restock ideas, chat replies); the owner approves before anything is saved.
- -Razorpay flow holds stock until payment is confirmed and auto-refunds rejected orders.
- -27 eval cases covering Hindi aliases, misspellings and gibberish input.
Architecture
A Next.js app with a single server-side AI gateway. The model never writes to the database directly; it returns Zod-validated drafts that the owner approves.
- user
- client
- guard
- service
- ai
- data
- external
- call
- logical link
- ← scroll →
- 01Owner uploads a shelf photo or voice list
- 02Gateway: auth → rate limit → kill switch → spend cap → input cleaning
- 03Claude tool loop returns a structured draft (validated with Zod)
- 04Owner reviews and approves the draft
- 05Approved items saved to Supabase Postgres; cost logged per call
Decisions
+ One gateway for every model call- Calling the model from each feature directly Rate limits, spend caps and logging live in one place, so a new AI feature can't skip them.
+ Human approval before any write- Letting the model save stock automatically A wrong price or quantity costs a real shop money; a review step is cheap.
+ Integer paise and a seven-state order machine- Float rupees and free-form status strings No rounding errors, and illegal status jumps are rejected at the boundary.
Failure handling
Model returns malformed or partial output
Zod validation fails closed; the owner sees an error, nothing is saved.
Daily AI spend exceeds the cap
Gateway refuses new calls until the next day; manual entry still works.
Prompt injection in uploaded text
Input cleaning plus tool-only output; the model can't trigger writes.
- user
- client
- guard
- service
- ai
- data
- external
- call
- logical link
- ← scroll →
users
userBuyer
search nearby shops, order, pay, track
userShop owner
catalogue, orders, AI drafts to approve
- client
Next.js 15 app
App Router · server actions · Clerk auth · role-gated dashboards
server
guardAI gateway
every model call goes through here
serviceOrder service
7-state machine · integer paise
serviceRealtime
live order updates · in-order chat
providers + data
aiClaude / OpenAI
tool loop · provider switchable
dataSupabase Postgres
catalogue · orders · cost logs · RLS
externalRazorpay
checkout · webhooks · refunds
- user
Owner uploads a shelf photo or voice list
- guard
Session + role check
not an owner → rejected
- guard
Rate limit → per-helper kill switch → daily spend cap
cap reached → AI off until tomorrow, manual entry still works
- guard
Input cleaning + size limits
user text fenced against prompt injection
- ai
Tool loop
model reads the catalogue through tools; can't write
- guard
Zod validation
malformed output → error shown, nothing saved
- client
Draft shown to the owner
edit, approve or discard
on approve
dataApproved items saved
dataCost logged for the run
- ● PLACED
- ACCEPTED
- PREPARING
- READY
- COMPLETED
CANCELLED
unpaid orders cancelled after 15 minutes; stock released
REJECTED
owner rejects; paid orders refunded automatically
Calling the model from each feature directly
One gateway for every model call
Rate limits, spend caps and logging live in one place, so a new AI feature can't skip them.
Letting the model save stock automatically
Human approval before any write
A wrong price or quantity costs a real shop money; a review step is cheap.
Float rupees and free-form status strings
Integer paise and a seven-state order machine
No rounding errors, and illegal status jumps are rejected at the boundary.
Model returns malformed or partial output
Zod validation fails closed; the owner sees an error, nothing is saved.
Daily AI spend exceeds the cap
Gateway refuses new calls until the next day; manual entry still works.
Prompt injection in uploaded text
Input cleaning plus tool-only output; the model can't trigger writes.
Numbers
27
Eval cases
7
Order states
TODO
p50 import latency
measure and fill in
TODO
Cost per import
from cost logs
Next
- ○ Grow the eval set to ~100 hard cases
- ○ Record a 90-second demo video
- ○ Stock substitution suggestions