CAUSE2025 · Enterprising City · BizBuddy AI

Smart Inventory
& AI for Shops

An agentic AI-powered PWA that empowers Indian small shopkeepers with voice-first inventory, OCR bill scanning, real-time analytics, and a Llama-powered business assistant.

28
API Endpoints
15
AI-Powered
8
Agent Tools
8
App Pages
01 · Tech Stack

Built with the right tools

A lean, production-ready stack optimized for mobile-first PWA performance with real AI at the core.

Frontend
React 18 + Vite
Tailwind CSS, Recharts, Lucide Icons, PWA with service worker
Backend
FastAPI (Python)
28 endpoints, async routes, SSE streaming, Uvicorn
AI / LLM
Groq + Llama 3.3 70B
Tool-calling agent loop, 15 AI features, function definitions
Database
Firebase Firestore
Per-user isolation, real-time onSnapshot, 4 collections
Auth
Firebase Auth
Google OAuth, email/password, session persistence
OCR
Tesseract
pytesseract + Pillow, extracts text from bill photos
Streaming
SSE via fetch
ReadableStream for POST SSE, real-time agent step display
Voice
Web Speech API
Browser-native, no cost, Hindi + English, AI parsing
02 · Architecture

System architecture

A three-tier architecture with real-time Firebase sync and a streaming agentic AI layer.

📱 Frontend — React PWA (Mobile-First)
AuthPage
OnboardingPage
AISetupPage
DashboardPage
InventoryPage
ChatPage
AnalyticsPage
PosterPage
useAuth
useProducts
useAgentChat
useVoiceInput
useRentals
useNotifications
⚡ Transport Layer
Firebase Auth (Google OAuth)
Axios REST → FastAPI
fetch + ReadableStream SSE
Firestore onSnapshot (realtime)
🔧 Backend — FastAPI (Python)
19 Route Modules
Agent System (SSE)
Inventory CRUD
Transactions
Rentals
Analytics
Groq Service
Firebase Service
OCR (Tesseract)
🗄️ Data & AI Layer
Firestore — products
Firestore — transactions
Firestore — rentals
Firestore — settings
Groq API — Llama 3.3 70B
Pexels API — images
03 · User Flow

End-to-end user journey

From first open to daily operations — a guided onboarding that gets shopkeepers running in minutes.

step 01
📱
Open App
PWA loads, checks Firebase Auth session
step 02
🔐
Login
Google OAuth or Email/Password via Firebase
step 03
🏪
Onboarding
Select business type from 10 categories
step 04
🤖
AI Setup
AI generates 18 starter products + insights via /setup-shop
step 05
📊
Dashboard
Real-time stats, AI restock tips, demand forecast
daily
📦
Manage
Swipe to sell/rent, voice input, OCR bills
daily
💬
Ask AI
Agentic chat answers questions using live data

Sale Transaction Flow

💸 Sell Flow
1
Swipe Product Left
SwipeableProductCard reveals Sell / Rent / AI Price
2
SellModal Opens
Enter quantity + optional customer name
3
POST /sell
Validates stock, deducts qty, creates transaction record
4
Firestore onSnapshot
useProducts updates → UI re-renders instantly
📦 Rental Flow
1
Swipe → Rent
RentModal: qty + customer + return date
2
POST /rent
Deducts stock, creates rental (status: active)
3
Live Countdown
RentalCountdown ticks every second, color-coded urgency
4
Return → Stock Restored
POST /return-rental → status: returned, qty back
04 · Agentic AI

The agent loop

Llama 3.3 70B autonomously decides which tools to call, chains lookups, and streams results in real-time via SSE.

Agent execution flow (max 5 iterations)
1
User sends message
POST /agent/chat — full conversation history + business type sent
2
Groq LLM decides
Llama 3.3 70B with tool_choice: "auto" — picks 0 to N tools
3
Tool execution
Streams "status" event → queries Firestore → streams "tool_result"
4
Result fed back
Tool output appended to conversation, loop continues
5
Final response
Streams "message" event with formatted text → "done" event closes stream
SSE Event Types
status
tool_result
message
error
done
8 Available Tools
📦
get_inventory
All products for the user from Firestore
⚠️
get_low_stock
Products where qty ≤ threshold
📊
get_sales_analytics
Last 200 transactions summary
🧾
get_recent_transactions
Recent sales with optional limit
📈
get_demand_forecast
7-day AI demand predictions
🔄
get_restock_recs
AI restock recommendations
📋
get_business_report
Health score + AI summary
💰
record_sale
Write sale to Firestore via chat
05 · API Endpoints

All 28 endpoints

15 of 28 endpoints call Groq/Llama 3.3 70B. Each AI route has proper error handling and fallback responses.

# Method Path AI Purpose
1GET/inventoryList all products for user
2POST/inventoryAdd new product
3POST/sellRecord a sale, deduct stock
4POST/rentRecord a rental, deduct stock
5POST/return-rentalReturn rental, restore stock
6GET/rentalsActive rentals list
7GET/transactionsSales history
8GET/exportCSV export of all data
9GET/analyticsSales summary + stats
10POST/chatAISimple single-turn chat
11POST/agent/chatAIAgentic chat — SSE stream
12POST/setup-shopAIGenerate starter inventory + insights
13POST/suggest-productsAIProduct recommendations for business type
14POST/daily-insightAIDaily business tip
15GET/demand-forecastAI7-day demand prediction
16GET/smart-restockAIRestock recommendations
17GET/business-reportAIHealth score + business summary
18POST/optimize-priceAIAI price suggestion for product
19POST/auto-categorizeAIAuto-fill category, price, threshold
20POST/voice-parseAIParse natural spoken input
21POST/ocrAIExtract items from bill photo
22POST/image-recognizeAIIdentify product from image
23POST/posterAIGenerate promotional poster text
24POST/festival-insightsAIFestival-based stock tips + notifications
25POST/product-imageAIFetch product image via Pexels
26GET/Health check
27GET/healthHealth check
28POST/ocr/base64AIOCR from base64 image
06 · Database Schema

Firestore collections

Per-user data isolation under users/{userId}/. Real-time sync via onSnapshot listeners.

products
users/{uid}/products/{id}
namestring
categorystring
quantitynumber
pricenumber ₹
thresholdnumber
imagestring
createdAttimestamp
updatedAttimestamp
transactions
users/{uid}/transactions/{id}
type"sale"
productIdstring
productNamestring
categorystring
quantitynumber
pricePerUnitnumber ₹
totalAmountnumber ₹
createdAttimestamp
rentals
users/{uid}/rentals/{id}
productIdstring
productNamestring
quantitynumber
customerNamestring?
returnDatetimestamp
status"active"|"returned"
createdAttimestamp
returnedAttimestamp?
settings
users/{uid}/settings/ai_setup
business_insightsarray
welcome_messagestring
tipsstring[]
ai_greetingstring
createdAttimestamp
07 · Key Features

What makes it work

Every feature is designed for shopkeepers with limited digital literacy — simple, fast, and offline-capable.

🎤
Voice-First Input
Web Speech API for hands-free product entry. Speak naturally in English or Hindi — AI parses the intent and fills in product fields automatically.
📸
OCR Bill Scanning
Photograph any supplier invoice. Tesseract extracts text, Groq AI identifies product names, quantities, and prices — auto-populates inventory.
👆
Swipe to Sell / Rent
Swipe any product card left to reveal Sell, Rent, or AI Price buttons. Complete a sale in 3 taps — no complex forms.
⏱️
Live Rental Countdown
Real-time countdown timers on rentals, ticking every second. Color-coded urgency from green → amber → red as return date approaches.
🤖
Agentic Chat
Ask "What should I reorder?" and the AI autonomously queries inventory, runs demand forecast, and gives a specific answer — not generic advice.
🎨
AI Poster Generator
Describe any promotion and get professional poster text instantly. No design skills needed — ready to print or share on WhatsApp.
📊
Smart Dashboard
Real-time stats: total products, low stock count, portfolio value, top seller. AI restock recommendations and 7-day demand forecast updated daily.
🔔
Festival Insights
AI detects upcoming festivals and proactively suggests which products to stock up — Diwali, Holi, Eid, regional festivals included.
📱
PWA — Installable
Works like a native app on Android and iOS. Add to home screen, service worker caching, no app store required. Works on any phone browser.
08 · Impact

SDG alignment

BizBuddy AI directly supports three UN Sustainable Development Goals.

💼
SDG 8 — Decent Work & Economic Growth
Reduces manual workload for small businesses, enabling informed decisions via AI dashboards and chatbots. More time to grow, less time on paperwork.
🏗️
SDG 9 — Industry, Innovation & Infrastructure
Promotes digital inclusion through offline-first, mobile-friendly design. AI-driven features built for real-world use in low-connectivity environments.
⚖️
SDG 10 — Reduced Inequalities
Makes enterprise-grade AI tools accessible to small shops via voice input and local language support. SmartBiz Rooms enable peer learning among business owners.