惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recent Announcements
Recent Announcements
J
Java Code Geeks
U
Unit 42
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
L
LangChain Blog
D
Docker
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
罗磊的独立博客
I
InfoQ
The Cloudflare Blog
小众软件
小众软件
V
Visual Studio Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Engineering at Meta
Engineering at Meta
S
SegmentFault 最新的问题
爱范儿
爱范儿
Hugging Face - Blog
Hugging Face - Blog
P
Proofpoint News Feed
V
V2EX
月光博客
月光博客
Martin Fowler
Martin Fowler

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How I built an Offline-First AI App using LLaMA 3 and React
Amit Mishra · 2026-05-13 · via DEV Community

Amit Mishra

Hi everyone, I wanted to share a portfolio project I just finished.. # MedVerify — AI-Powered Medicine Authenticator 🛡️

MedVerify is a production-grade, offline-capable Progressive Web Application (PWA) designed to detect counterfeit medicines in rural and low-connectivity environments across India.

It uses an edge-deployed 5-layer AI analysis engine (Visual AI, OCR, Barcode/QR, Pricing Intelligence, and Pharmacy Registry Checks) backed by a massive locally-cached CDSCO database.

![Architecture: Zero-Storage, Edge-First]


🚀 Key Features (Enterprise-Grade)

  • 📡 Hybrid "Offline-Second" Architecture: Gracefully degrades from Cloud AI to a local IndexedDB cache when internet is lost.
    • Online Mode (Full Power): Uses LLaMA 3, EasyOCR, and Python to extract text from photos and answer complex usage questions.
    • Offline Mode (Backup): AI image extraction and LLM answering are disabled. Users manually enter the medicine name or barcode to instantly verify it against a highly-compressed 50MB local CDSCO registry cached on their mobile phone.
  • 🔒 Zero-Storage Security Architecture: All uploaded images are processed entirely in-memory using BytesIO. No user data, prescriptions, or images are ever written to disk, ensuring 100% HIPAA and privacy compliance.
  • 🤖 Defensive AI Pipeline: Employs rigorous LLM prompt injection defenses, strict max_tokens limits (to prevent token-exhaustion attacks), and real-time usage logging via Groq's high-speed inference engine.
  • 🚧 Hardened API Infrastructure: Protected by multi-tier rate limiting (global 60/min, AI routes 5/min), strict CORS policies, and rigorous MIME-type and byte-signature validation for all file uploads.
  • PWA Edge Caching: Installs directly to iOS and Android home screens, bypassing App Store delays, with fully automated background syncing.
  • 🌐 Bilingual (English/Hindi): Deep context translation powered by deep-translator to support grassroots health workers.

🛠️ Technology Stack

Frontend (Vercel)

  • Framework: React 18 + Vite + TypeScript
  • Styling: Tailwind CSS + shadcn/ui + ScrollReveal (micro-animations)
  • Offline Engine: Workbox Service Workers + IndexedDB (idb)
  • Routing: React Router DOM

Backend (HuggingFace Spaces)

  • Framework: Python Flask (Application Factory Pattern)
  • AI / Inference: Groq API (LLaMA 3 70B) + EasyOCR + OpenCV
  • Database: Google BigQuery (Parameterized Queries for SQLi prevention)
  • Security: Flask-Limiter, Flask-CORS, secure HTTP headers (HSTS, CSP, X-Frame-Options)

🔒 Security Posture & Hardening

This application has been meticulously hardened for production scale:

  1. Dependency Pinning: All packages strictly version-pinned to prevent supply chain attacks.
  2. HTTP Security Headers: Enforced Content-Security-Policy, X-Content-Type-Options, and Strict-Transport-Security.
  3. Graceful Error Boundaries: Stack traces and internal server paths are strictly hidden behind NODE_ENV checks in production.
  4. Token Cost Management: Granular throttling and token-capping prevent malicious automated scraping and API bill shocks.

💻 Local Development Setup

1. Frontend

git clone https://github.com/Amit4517187/med-verify-authenticator.git
cd med-verify-authenticator
npm install
npm run dev

Enter fullscreen mode Exit fullscreen mode

Frontend runs at http://localhost:5173

2. Backend

Ensure you have Python 3.10+ installed.

cd backend # Assuming you have cloned the backend repo
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt

Enter fullscreen mode Exit fullscreen mode

Create a .env file in the backend root:

GROQ_API_KEY=your_key_here
GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/gcp/key.json
MEDVERIFY_ACCESS_TOKEN=your_secure_secret_here

Enter fullscreen mode Exit fullscreen mode

Run the server:

gunicorn "app:create_app()" -w 4 -b 0.0.0.0:5000

Enter fullscreen mode Exit fullscreen mode


🧠 Engineering & Architecture Philosophy

This project was architected to solve a genuine, life-threatening problem: ₹6,000 Cr worth of counterfeit medicines circulating in India.

Instead of building a simple wrapper, MedVerify is built with "Resilient Engineering" in mind. Knowing that the primary users are ASHA workers and community pharmacists in tier-3 cities with patchy 3G connections, the application uses a Graceful Degradation approach:

  1. Cloud-Heavy Operations (Online): We offload OCR, image processing, and LLM generative answers to the HuggingFace backend because mobile browsers cannot handle heavy AI inference or massive batch-number cross-referencing without crashing.
  2. Edge-Caching Fallback (Offline): If the connection drops, the app switches to an offline backup mode. The LLM is disabled, and the app relies strictly on the user manually typing the name or barcode to verify against a 50MB IndexedDB CDSCO cache.

This strict separation ensures that the app never just shows a "No Internet" screen; it always provides a critical path to verification.


Built with ❤️ to protect lives.