A state-of-the-art, offline-first pharmacy inventory and POS management system designed for modern, high-volume pharmacy operations.
Pharmacy inventory should not fail when the internet does. NexPharm acts as a high-reliability local-first platform designed to solve real-world billing, expiry tracking, and medicine scanning challenges. Operating with a robust offline-first architecture, it provides pharmacy staff with uninterrupted operations, microsecond-latency POS billing, and real-time backend synchronization.
| Category | Technologies |
|---|---|
| π Frontend | Next.js, React, Tailwind CSS, shadcn/ui (Radix UI) |
| βοΈ Backend & Logic | Next.js Server Components, Structured Service Layer |
| βοΈ Infrastructure | Supabase (PostgreSQL), Supabase Auth, Row Level Security (RLS) |
| π Sync & Local DB | PowerSync (Real-time Sync Engine), IndexedDB (Local DB) |
| β‘ Database ORM | Kysely (Type-safe SQL Query Builder) |
| π€ Intelligence & OCR | Tesseract.js (On-device OCR), Fuse.js (Fuzzy search), Barcode Detector API |
| π¦ Forms & Validation | Formik, Yup |
| π Visualization | Recharts (Dynamic inventory & analytics dashboard) |
| Capability | Description |
|---|---|
| π Offline-First Sync | Fully operational CRUD via local IndexedDB, automatically syncing with Supabase using PowerSync. |
| π· OCR Medicine Scanner | Instant on-device medicine identification using Tesseract.js with image pre-processing. |
| π·οΈ Barcode Detection | Ultra-fast barcode scanning for seamless medicine lookups at point-of-sale checkout. |
| π¦ Batch & Expiry System | Smart sorting of medicine batches based on First-Expiry-First-Out (FEFO) to minimize product loss. |
| π Multi-Tier Alerts | Dynamic notifications (15/30/90 days expiry) and low-stock alerts to prevent shelf empty-outs. |
| π Point of Sale (POS) | Sequential, GST-compliant invoice generation with atomic multi-batch inventory updates. |
| π Advanced Analytics | Real-time charts covering daily sales, total revenue, high-demand items, and valuation. |
| π Multi-Tenant Security | Multi-pharmacy tenant isolation using Supabase Row Level Security (RLS) policies. |
NexPharm is engineered around a local-first paradigm. Pharmacy checkout workflows function instantly without any network delays.
- Zero-Latency Interactions: Immediate UI updates regardless of current network state.
- Bi-directional Sync: Automatically uploads local mutations and fetches remote changes.
- Conflict Handling & Queuing: Smart handling of offline transactional queues.
pharmacy-inventory/
βββ public/ # Static assets & PowerSync copy-assets
β βββ images/ # NexPharm architecture, banner and features media
βββ src/
β βββ app/ # Next.js 15 App Router pages & SSR loaders
β βββ components/ # Reusable shadcn components & POS UI elements
β βββ hooks/ # Custom hooks managing medicine & POS states
β βββ lib/ # Initialization scripts for PowerSync & Supabase
β βββ services/ # Business logic layer executing type-safe queries
β βββ types/ # Strict type definitions for database tables
β βββ utils/ # Image processing helpers & Levenshtein matching
β βββ middleware.ts # Authentication & SSR routing guards
βββ package.json # Scripts (dev, build, start, postinstall)
βββ tsconfig.json # Strict TypeScript configurationA complete overview of NexPharmβs core capabilities β from barcode & OCR scanning to real-time sync, GST billing, analytics, alerts, and multi-pharmacy management β all built for modern pharmacy operations.
An architectural overview of how NexPharm works under the hood, including offline-first synchronization, PowerSync data flow, Supabase integration, local IndexedDB caching, and scalable multi-tenant infrastructure.
Follow these steps to set up and run NexPharm locally on your machine:
- Node.js: v18.x or v20.x+
- Supabase Account: An active PostgreSQL instance
- PowerSync Account: To orchestrate real-time client synchronization
Clone the repository and install the dependencies:
git clone https://github.com/sayandas24/pharmacy-inventory.git
cd pharmacy-inventory
npm install(Note: A postinstall script runs automatically to copy the PowerSync WASM assets into the public folder.)
Create a .env.local file in the root directory:
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
NEXT_PUBLIC_POWERSYNC_URL=your_powersync_instance_url- Apply the database schemas in your Supabase SQL editor.
- Enable Row-Level Security (RLS) policies for data isolation.
- Configure your sync rules in the PowerSync Dashboard to target your local client tables.
npm run devOpen http://localhost:3000 in your browser.




