How I Built an AI-Powered System That Saves Convenience Store Owners on Optimising Retail Operations

The Problem Hiding in Plain Sight

Building Sentinel: An intelligent operations management system for small retail businesses

 

Picture this: It’s 9 PM on a Tuesday. The minimart in Singapore has just closed for the day. Praba flips the sign, locks the door, and… sits down at the counter with a sigh. Not to go home—there are still 3-4 hours of admin work ahead.

Counting cash denomination by denomination. Reconciling four different payment methods. Manually typing invoice line items into Excel. Trying to remember which products are running dangerously low.

Every. Single. Night.

Do the math: That’s 90-120 hours of manual paperwork every month. For someone whose entire business depends on their time and energy, this isn’t just tedious—it’s slowly killing the business.

When I first sat down with Praba, they showed me the brutal reality:

  • 📋 15-20 supplier invoices weekly, each taking 10-15 minutes to process manually
  • 💰 Daily reconciliation across 4 payment types (cash, NETS, credit, QR) with frequent
    discrepancies
  • 📦 Tracking 1700+ products with no systematic reordering process
  • 💳 Missed payment deadlines, damaged supplier relationships
  • 🔮 Zero data-driven insights for inventory optimization

That’s when I decided: I’m building Sentinel—an AI system to fix this mess.

 

Understanding the Real Problem (Or: Why I Stalked a Store Owner for Two Weeks)

Here’s where most developers screw up: We jump straight to coding without understanding what people actually do.

Not me. I spent two full weeks basically living at this minimart. Watching. Taking notes. Asking annoying questions. (Praba was very patient with me.)

A Day in the Life

6:00 AM – Store opens. Praba counts the opening cash, mentally notes what might run out today.

Throughout the day – Serve 100-150 customers. Receive 2-3 supplier deliveries. Mental gymnastics: “Forgot to order cola yesterday. Definitely order today. Wait, did I check whether we’re low on chips?”

9:00 PM – Store closes. Now the “second shift” begins:

  1. Count cash by denomination (15-20 minutes)
  2. Reconcile POS with actual cash (10-15 minutes)
  3. Enter invoice line items into Excel (30-45 minutes)
  4. Update inventory spreadsheet (20-30 minutes)
  5. Note items to reorder (10 minutes)
  6. Review payment deadlines (15-20 minutes)

Total evening admin time: 1.5 to 2.5 hours. And that’s on a GOOD night.

The Root Causes

Data Entry Bottleneck: It’s 2024 and we’re still transcribing invoices like medieval scribes.Everything required manual typing from paper to digital.

Fragmented Systems: POS system over here. Excel spreadsheets over there. Paper invoices in a pile. Nothing talks to anything else. Pure chaos.

No Predictive Intelligence: Every decision based on memory and gut feel. No data. No forecasting. Just vibes.

Mobile Friction: Praba is rarely at a desk. They’re walking aisles, receiving deliveries, serving customers. But to do admin? Gotta sit at the back office computer.

What Praba actually needed: Mobile-first interface, automated data entry, AI-driven recommendations, ultra-simple UI, one integrated system.

Challenge accepted.

 

The Solution: Three Core Innovations

Innovation 1: Mobile-First Operations via Telegram Bot

Let me tell you about my best product decision: Using Telegram as the primary interface.

“Wait, Telegram? Like the messaging app?” Yep.

Why Telegram won:

  • Already installed on Praba’s phone (zero friction)
  • Rich bot API with inline keyboards and file uploads
  • No app store approval needed
  • Works on any device—phone, tablet, computer
  • Development time: weeks instead of months

The workflow became beautifully simple:
Invoice arrives → Praba pulls out phone → Takes photo → Sends to Telegram bot → AI extracts data automatically → Database updates → Praba reviews and confirms in 30 seconds.

Done.

Before: 15 minutes per invoice (manual typing nightmare)
After: 30 seconds per invoice (photo + confirm)
Time saved: 93% reduction

The key insight? Store owners are mobile-first users. They’re walking aisles, receiving deliveries, serving customers. Making them sit at a computer for data entry was the fundamental design flaw of traditional systems.

Innovation 2: AI-Powered Invoice Processing with Llama Models

This is where I got to geek out. Instead of manual data entry, I built an intelligent extraction pipeline using Meta’s Llama vision-language models.

The AI Pipeline:
Invoice Photo → Image Enhancement → Llama Model Processing →
Structured Data Extraction → Validation → Database Insert

Why Llama Models?

Traditional OCR just reads text: “C-o-c-a C-o-l-a 1-2 2-.-5-0”

Llama models actually understand context: “Oh, this is 12 units of Coca-Cola at $2.50 per unit, so the
total should be $30.00. Let me verify that math…”

I started with Llama-4-Maverick-17B and Llama Scout. Currently testing Llama 3.2 90B Instruct, which shows 15-20% accuracy improvement on complex invoices with handwritten notes or
weird formats.

The Real-World Challenge

Supplier invoices are CHAOS:

  • Computer-generated pristine PDFs ✅
  • Handwritten carbon paper with dying pen ❌
  • Photos of crumpled receipts in poor lighting ❌
  • Coffee stains, water damage, existential sadness ❌

Traditional OCR fails spectacularly. Vision-language models? They handle it like a human would—squinting, inferring, cross-referencing with the product catalog, and politely asking for clarification when unsure.

The Technical Secret Sauce: Confidence Scoring

Every piece of extracted data gets a confidence score:

if confidence > 90%:
    # Auto-process completely. Trust the AI. Done.
    save_to_database(extracted_data)

elif confidence > 70%:
    # Auto-process but flag for review. Takes 10 seconds.
    save_and_flag_for_review(extracted_data)

else:
    # Request manual input
    request_human_validation(partial_data)

This three-tier system was crucial. Perfect accuracy isn’t necessary—transparency and speed matter more.

Real example: The AI sees "Co<blur>Cola 1.<blur>L 12 2.50 30.00"

It thinks: “Hmm, blur here. But this store sells Coca-Cola 1.5L frequently. Math checks out: 12 × $2.50 = $30.00. Probably Coca-Cola 1.5L. Confidence: 88%”

Result: Auto-processed, flagged for Praba to confirm. Takes 5 seconds instead of 1 minute of manual entry.

The Numbers:

  • ✅ 95%+ accuracy on invoice extraction
  • ✅ 87% fully automatic processing
  • ✅ 13% flagged for quick review
  • ✅ Average processing: 8 seconds per invoice

Innovation 3: Predictive Inventory Intelligence (The Game-Changer)

Invoice automation is great. But you know what’s better? Never running out of best-selling products while simultaneously not wasting money on overstock.

The Problem

Most small stores use the sophisticated “eyeball method”:

“This shelf looks kinda empty. Better order some stuff.”
“We sold a lot of chips last week… I think? Order extra to be safe.”
“Wait, why do we have 47 cans of soup nobody buys??”

Result? Constant stockouts of fast-movers and mountains of slow-movers gathering dust.

The Solution: AI-Powered Demand Forecasting

I built a recommendation engine that analyzes:

  • Historical sales patterns over 90 days (recent data weighted more heavily)
  • Seasonal trends (holidays spike everything; weekends spike beverages)
  • Supplier lead times (3 days vs 7 days makes a huge difference)
  • Safety stock levels (never want to actually hit zero)

How It Works (In Plain English)

  1. Look at how fast a product is selling right now
  2. Calculate: “At this rate, when will we run out?”
  3. Add supplier delivery time + safety buffer
  4. If we’re getting close to danger, recommend a reorder
  5. Calculate quantity based on pack sizes and future demand

Real output the system gives Praba:
Coca-Cola 1.5L: Order 96 units

  • 📊 Current stock: 18 units
  • 📈 Daily consumption: 5–6 units/day
  • Days until stockout: 3–4 days
  • 🚚 Supplier lead time: 2 days
  • 🛡️ Safety buffer: 3 days
  • Confidence: 91%

Reasoning: At current consumption rate, you’ll run out in 3.2 days. With a 2-day supplier lead time and 3-day safety buffer, you should order now. Recommended quantity covers 2 weeks of demand.

Praba clicks “Add to order.” Done. No stress. No guesswork. No stockouts.

Impact:

  • Stockouts: 10-15 items/week → 1-2 items/week
  • Overstock waste: Dramatically reduced
  • Weekly ordering time: 2-3 hours → 20 minutes
  • Order accuracy: 40% improvement
 

The Technology Stack (For the Nerds)

Backend

  • Python + Flask: Lightweight, fast development, perfect for APIs
  • SQLAlchemy: Clean database operations with ORM
  • SQLite: Zero-config for MVP (PostgreSQL-ready for scaling)

AI/ML

  • Llama-4-Maverick-17B: Primary invoice processing
  • Llama Scout: Alternative model for testing
  • Llama 3.2 90B Instruct: Currently testing for better accuracy
  • Pandas/NumPy: Sales pattern analysis and forecasting

Integration & Deployment

  • Telegram Bot API: Mobile interface
  • Google Drive API: Document backup
  • Together AI: Llama model hosting
  • Docker, AWS EC2, Nginx: Production deployment

Key Architecture Decisions

Flask over Django: Needed lightweight flexibility for custom API endpoints and AI integration pipelines.

SQLite initially: Zero configuration. Perfect for single-store MVP. The beautiful part? My schema is 100% PostgreSQL-compatible. Scaling means changing one connection string—no code changes needed.

Llama models via Together AI: I tested GPT-4 Vision (expensive), Google Vision API (good but limited), AWS Textract (slow). Llama models won because:

  • ✅ Best context understanding (reads invoices like a human)
  • ✅ Cost-effective at scale
  • ✅ Can self-host for data privacy if needed
  • ✅ Adaptable to format variations without retraining

Telegram Bot: This was genius (if I say so myself). Zero friction for users. No app store approvals. Rich features. Works everywhere. Development speed 10x faster than native mobile apps.

 

Technical Challenges & Solutions

Challenge 1: Invoice Format Chaos

Problem: Every supplier uses different formats—pristine PDFs, handwritten carbon copies, photos of crumpled receipts. Traditional template-based OCR would need 50+ templates and still fail.

Solution: Multi-stage AI pipeline with quality checks:

  1. Pre-flight check: Is the image even usable? Too blurry? Too dark? Auto-rotate if upside down.
  2. Llama processing: Let the vision model handle format variability naturally. It understands
    document structure: “This messy part is supplier info. This table is the items. This number at bottom is total.”
  3. Validation: Cross-reference against product catalog with fuzzy matching. “Ckoa Cla 1.5”
    probably means “Coca-Cola 1.5L”
  4. Confidence scoring: Flag uncertain items for human review

Result: 95%+ accuracy even on terrible quality invoices.

Challenge 2: Real-Time Data Sync

Problem: Multiple entry points (web, mobile, background jobs) updating inventory simultaneously. Risk of data corruption.

Solution: Event-driven architecture with database transactions and row-level locking.

# Every invoice insertion triggers automatic inventory update
@db.event.listens_for(InvoiceTable, 'after_insert')
def update_inventory(mapper, connection, target):
    with db.session.begin_nested():  # Savepoint for rollback
        inventory = get_inventory_with_lock(target.item_name)
        inventory.current_stock += target.quantity
        db.session.commit()

If anything fails, transactions roll back. Zero data corruption. Ever.

Challenge 3: Non-Technical User UX

Problem: Praba isn’t a software developer. The interface needed to be bulletproof simple for a sleep-deprived store owner at 10 PM after a 16-hour shift.

Solution: Conversational UI with guided flows instead of forms:

Bot: “Ready to process invoices? 📸 Send me photos (you can send multiple)”
[User sends 3 photos]
Bot: “Got 3 invoices! Processing… ⏳”
Bot: “✅ Done! Invoice 1 from ABC Supplier
– Coca-Cola 1.5L: 12 × $2.50 = $30.00
– Sprite 1.5L: 12 × $2.30 = $27.60
Total: $57.60
Look good? ✅ Yes | ✏️ Edit | ❌ Delete”

Clear feedback. Every step confirmable or undoable. No mysterious errors—just plain language: “Photo too blurry. Can you retake it?”

Result: Praba was using the system confidently within 3 days. No training needed.

 

Results: What Changed

Time Savings (Monthly)

TaskBeforeAfterSaved
Invoice processing12 hours<1 hour11 hours
Daily closing15 hours<1 hour14 hours
Order planning25-30 hours~1.5 hours~28.5 hours
Payment tracking6-10 hours0.5 hour9.5 hours
TOTAL67 hours4 hours63 hours

That’s nearly a full work week reclaimed every month.

Think about what Praba can do with those extra hours: Actually take days off. Improve the store layout. Talk to
customers. Have a life outside the business.

Operational Improvements

  • 📊 Inventory accuracy: 70% → 96%
  • 📉 Stockout events: 10-15/week → 1-2/week
  • 💰 Payment timeliness: 65% → 100% on-time
  • ⚡ Invoice speed: 15 min → 30 sec (93% faster)
  • 📱 Mobile operations: 0% → 80% of tasks
 

Lessons Learned

1. User Research Trumps Technical Excellence

I spent 40% of development time just watching Praba work. Initially, I wanted to build a gorgeous React dashboard with real-time WebSocket updates. Other developers would have been impressed.

Praba just wanted to take a photo of an invoice and have it magically appear in the system.

Guess which one I built?

Learning: Build what users need, not what’s technically impressive. Two weeks of user research saved me months of building the wrong thing.

2. Mobile-First Isn’t Optional—It’s Survival

80% of Praba’s interactions happen on their phone. They’re walking aisles, receiving deliveries, at the cash register. They’re almost never at the back office computer.

Desktop-first would have failed completely.

Learning: Understand where and when users will actually use your product. Design for their reality, not your assumptions.

3. AI Assistance Beats AI Replacement

My initial algorithm was aggressive: “ORDER THESE 47 ITEMS IMMEDIATELY”

Praba: “Uh… why?”
System: “TRUST THE AI”
Praba: “Yeah, no.”

Acceptance rate: 60%

Then I added transparency—showing confidence scores, reasoning, and calculations. New acceptance rate: 95%

Learning: Humans trust AI more when they can see the reasoning. Show your work. Include confidence scores. Explain why. Let humans validate and override.

4. Why Llama Models Won

I tested everything:

  • Traditional OCR: 40-50% accuracy, failed on handwritten invoices
  • GPT-4 Vision: 85-90% accuracy, but expensive at scale
  • Llama models: 95%+ accuracy, cost-effective, can self-host

Why Llama won: Context understanding (reads invoices like a human), adaptability (handles format variations), cost-effective (viable for small business economics), privacy-friendly (can self-host if needed).

Currently testing Llama 3.2 90B because it even checks invoice math: “12 units at $2.50 should be $30.00, but invoice says $28.50… oh, there’s a 5% discount mentioned. Math checks out.”

Learning: Don’t pick the most expensive AI because it’s trendy. Test everything. Optimize for your use case. Cost matters for small businesses.

 

What’s Next: The Roadmap

Phase 2: Advanced Intelligence

  • 🔮 Seasonal forecasting: Predict holiday spikes, weather impacts
  • 💰 Dynamic pricing: Optimize margins based on demand
  • 📊 Profitability analysis: Which products actually make money?
  • 🤝 Supplier scoring: Track reliability, pricing, quality

Phase 3: Multi-Store Expansion

  • 🏢 Franchise dashboard: Manage 10+ stores centrally
  • 📦 Inter-store transfers: Optimize stock across locations
  • 📈 Comparative analytics: Benchmark store performance

Phase 4: Ecosystem Integration

  • 💳 POS integration: Real-time sales sync
  • 📧 Supplier APIs: Automated ordering
  • 💰 Accounting sync: QuickBooks, Xero integration
 

The Open Source Plan

There are millions of small retail businesses globally facing these exact problems. They can’t afford enterprise software. They don’t have IT departments. They just need something that works.

I’m planning to open-source major components to help other small business owners:

  • ✅ Core inventory management module
  • ✅ Invoice processing engine (Llama integration)
  • ✅ AI recommendation algorithms
  • ✅ Deployment guides and Docker configs

Repository: github.com/mdavala/sentinel
Target release: Q1 2025

 

Final Thoughts

Building Sentinel taught me that the best technology solutions aren’t the most technically complex—they’re the ones that solve real problems for real people.

Praba doesn’t care about my database schema. Praba doesn’t care about my ML algorithms. Praba cares about:

  • ✅ Going home 2 hours earlier every night
  • ✅ Never running out of Coca-Cola (it’s embarrassing to tell customers “we’re out”)
  • ✅ Not missing payment deadlines
  • ✅ Understanding which products make money
  • ✅ Having time to improve the business instead of drowning in paperwork

The technology is just the means to those ends.

If You’re Building for Small Businesses:

  1. Spend more time observing than coding – Watch how they actually work
  2. Optimize for mobile, always – They’re rarely at desks
  3. Make AI explainable – Show confidence scores and reasoning
  4. Release early, iterate fast – Weekly releases beat monthly
  5. Document for humans – Videos beat text
  6. Economics matter – Solution must pay for itself quickly

There are millions of small retail businesses—mom-and-pop shops, family stores, local minimarts. They’re the backbone of communities. They can’t afford enterprise software. They don’t have IT departments. They’re working 60-80 hour weeks just to keep the lights on.

Sentinel proves it’s possible to bring AI-powered intelligence to the smallest businesses. Not just Fortune 500 companies. Real people. Real problems. Real solutions.

That’s the future worth building.

 

Connect & Collaborate

Want to discuss technical details? Curious about implementation specifics? Building something similar? Let’s talk!

Star the repository if you find this interesting. Share it with small business owners who might benefit.

 

Building intelligent systems that respect the user’s time and expertise—that’s what great software engineering is all about.

Have questions about the architecture? Curious about AI implementation? Want to know how Llama models are integrated? Drop a comment below!