Skip to content

Dash1234-user/Pharma-Pro-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

119 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PharmaPro-Project

Academic minor project (On Development)

- Building a multi-user SaaS-style pharmacy system deployed on cloud (Render)

- Currently evolving from a working prototype toward a production-ready SaaS product

πŸ’Š PharmaCare Pro

A full-stack pharmacy management web application built for both Wholesale and Retail pharmacies β€” featuring billing, inventory, credit management, expiry tracking, sales analytics, and more.


πŸ—οΈ Tech Stack

Frontend

Technology Version Purpose
React 18.3 UI framework
Vite 5.4 Build tool & dev server
React Router v6 6.26 Client-side routing
TanStack React Query 5.56 Server state, caching (30s stale time)
Zustand 5.0 Client state (auth, settings)
Axios 1.7 HTTP client with JWT interceptor
Recharts 3.8 Charts β€” bar, line, pie

Backend

Technology Version Purpose
Python / Flask 3.x REST API server
Flask-JWT-Extended β€” JWT authentication & partition identity
Flask-CORS β€” Cross-origin requests
psycopg2 β€” PostgreSQL driver with connection pooling
Werkzeug β€” Password hashing (bcrypt)
Resend API β€” Transactional email (credit bills, OTP)
SMTP fallback β€” Email fallback if Resend unavailable

Database & Infrastructure

Service Purpose
PostgreSQL (Supabase) Primary database β€” Transaction Pooler port 6543
Render Web Service Flask backend hosting
Render Static Site React frontend hosting
GitHub Source control & auto-deploy trigger

✨ Features

πŸ” Authentication

  • JWT-based login & registration
  • Drug License No. as primary identifier
  • OTP-based password reset via email
  • OTP-based email change verification
  • Welcome email on registration
  • Auto-logout on token expiry (401 intercept)

🏒 Dual Pharmacy Type Support

The entire app is partition-aware β€” every feature, endpoint, and UI adapts to the active pharmacy type:

  • Wholesale Pharma β€” Box/Strip pricing, retailer billing, GSTIN fields, supplier-side credit
  • Retail Pharmacy / Hospital / Medical Store / Ayurvedic Store β€” Strip/Piece pricing, customer billing, doctor fields, patient-side credit

πŸ“Š Dashboard

  • Today's revenue & bill count
  • Total medicines & low stock alerts
  • Expiry alerts (expired + upcoming)
  • Revenue trend β€” last 7 days (bar chart)
  • Weekly profit analysis β€” current month (4 weeks)
  • Top selling medicines (horizontal bar chart)
  • Expiring soon panel
  • Recent bills list
  • Per-pharmacy-type dashboard reset (hide old data without deleting)

πŸ’Š Inventory Management

  • Add / Edit / Delete medicines
  • Fields: Name, Brand, Category, SKU/Batch, Form (Tablet/Syrup/etc.), Unit, MRP, Selling Price, Purchase Price, GST%, Stock, Min Stock, Pieces/Strip, Strips/Box, Expiry Month
  • Low stock threshold alerts
  • Real-time stock deduction on billing
  • Category-based filtering

🧾 Billing

Wholesale billing:

  • Shop / Retailer name, Shopkeeper GSTIN, phone
  • Box / Strip quantity types with automatic pack-size price calculation
  • Bill No. format: GSTIN-XXXX
  • Columns: Medicine, Form, Qty, MRP, Selling Price, Disc%, GST, Amt Before Tax, Total
  • Bill preview modal with QR code (UPI payment)

Retail billing:

  • Customer name, phone, doctor name
  • Strip / Piece quantity types
  • Bill No. format: #XXXX
  • Columns: Medicine, Form, Qty, MRP, Disc%, GST, Amount
  • TAX INVOICE layout with green header

Both types:

  • Live GST + discount calculation
  • Round-off to nearest rupee
  • Print-ready PDF preview
  • Low stock toast alert after bill generation
  • Print Last Bill button

πŸ“‹ Sales History

  • All bills with search & date filter
  • Bill detail expand / print
  • Export as CSV
  • Filter by payment mode

πŸ“¦ Stock Details (Stock-In)

  • Track every stock entry with supplier, quantity, purchase price, batch, expiry
  • Per-pharmacy-type filtering
  • Linked to Purchase Records

πŸ›’ Purchase Records

  • Supplier order tracking
  • Delivery status management
  • Linked to stock-in entries

πŸ’³ Credit Management

Wholesale Credit:

  • Multi-item credit bills for retailers
  • GST / discount toggles per item
  • Email credit bill to shopkeeper via Resend API
  • PDF print of credit bill
  • Bulk delete

Retail Credit (Shop Credits):

  • Track supplier / wholesaler payments
  • Cumulative pending balance calculation
  • Supplier History Modal β€” full payment timeline
  • MAX(ctid) tiebreaker for accurate latest-record queries

πŸ“ˆ Sales Analysis

  • Revenue by period (7 / 30 / 90 / 365 days)
  • Category-wise revenue breakdown with progress bars
  • Top selling medicines ranking
  • GST collected summary
  • Profit margin analysis
  • Line chart & bar chart views

πŸ“… Expiry Tracker

  • Medicines grouped by: Expired / Within 30 / 60 / 90 days / Safe
  • Color-coded badges (red / amber / green)
  • Stat cards with counts per group
  • Filter buttons to switch views instantly

πŸ—‚οΈ Categories

  • Add / Edit / Delete medicine categories
  • Medicine count per category
  • Revenue contribution per category (from analysis data)
  • Revenue progress bars

βš™οΈ Settings

  • Store name, type, address, phone, email
  • GSTIN, Drug License No.
  • Owner name, Supplier name
  • UPI QR code upload (separate for Wholesale & Retail)
  • Currency symbol
  • Low stock threshold
  • Pharmacy type lock (prevents accidental type change)
  • OTP-based email update

πŸ“€ Import / Export

  • Excel import for medicines bulk upload
  • Sales history import
  • Credits import
  • Full backup export (JSON)

πŸ—‚οΈ Project Structure

Pharma-Pro-Project/
β”‚
β”œβ”€β”€ app.py                  # Flask backend β€” 61 API routes, 4800+ lines
β”œβ”€β”€ requirements.txt        # Python dependencies
β”œβ”€β”€ Procfile                # Render start command
β”œβ”€β”€ runtime.txt             # Python version
β”‚
└── frontend/               # React + Vite SPA
    β”œβ”€β”€ public/
    β”‚   β”œβ”€β”€ favicon.ico
    β”‚   β”œβ”€β”€ logo.jpeg
    β”‚   └── site.webmanifest
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ api/
    β”‚   β”‚   └── client.js         # Axios instance with JWT interceptor
    β”‚   β”œβ”€β”€ store/
    β”‚   β”‚   β”œβ”€β”€ authStore.js      # Zustand β€” token, user
    β”‚   β”‚   └── settingsStore.js  # Zustand β€” pharmacy settings, type
    β”‚   β”œβ”€β”€ components/
    β”‚   β”‚   └── Layout.jsx        # Sidebar, topbar, bottom nav
    β”‚   β”œβ”€β”€ pages/
    β”‚   β”‚   β”œβ”€β”€ AuthPage.jsx
    β”‚   β”‚   β”œβ”€β”€ DashboardPage.jsx
    β”‚   β”‚   β”œβ”€β”€ ProductsPage.jsx
    β”‚   β”‚   β”œβ”€β”€ BillingPage.jsx
    β”‚   β”‚   β”œβ”€β”€ HistoryPage.jsx
    β”‚   β”‚   β”œβ”€β”€ StockInPage.jsx
    β”‚   β”‚   β”œβ”€β”€ CreditPage.jsx
    β”‚   β”‚   β”œβ”€β”€ AnalysisPage.jsx
    β”‚   β”‚   β”œβ”€β”€ ExpiryPage.jsx
    β”‚   β”‚   β”œβ”€β”€ CategoriesPage.jsx
    β”‚   β”‚   β”œβ”€β”€ PurchasePage.jsx
    β”‚   β”‚   └── SettingsPage.jsx
    β”‚   β”œβ”€β”€ App.jsx               # Routes + protected route wrapper
    β”‚   β”œβ”€β”€ main.jsx              # React Query + BrowserRouter setup
    β”‚   └── styles.css            # Global CSS with responsive utilities
    β”œβ”€β”€ index.html
    β”œβ”€β”€ vite.config.js
    └── package.json

πŸ”Œ API Overview

Method Endpoint Description
POST /api/auth/register Register new pharmacy
POST /api/auth/login Login, returns JWT
GET /api/auth/me Get current user
GET/PUT /api/settings Get / update pharmacy settings
GET/POST /api/products List / add medicines
PUT/DELETE /api/products/:id Edit / delete medicine
GET/POST /api/categories List / add categories
GET/POST /api/bills List / create bills
GET /api/bills/next-number Next formatted bill number
GET/POST /api/stock-ins Stock entry records
GET/POST /api/credits Wholesale credit records
GET/POST /api/shop-credits Retail supplier credits
GET /api/dashboard Full dashboard aggregation
GET /api/analysis Sales analytics (7/30/90/365 days)
GET /api/expiry Medicines by expiry category
GET/POST /api/purchase-records Supplier purchase orders
POST /api/auth/forgot-password/send-otp Password reset OTP
GET /api/export/backup Full data backup (JSON)
POST /api/import/medicines Bulk medicine import (Excel)

πŸš€ Local Development

Backend

# Install dependencies
pip install -r requirements.txt

# Set environment variables
export DATABASE_URL="postgresql://..."
export JWT_SECRET_KEY="your-secret"
export RESEND_API_KEY="re_..."

# Run Flask
python app.py

Frontend

cd frontend

# Install dependencies
npm install

# Run dev server (proxies /api to localhost:5000)
npm run dev

# Build for production
npm run build

🌐 Deployment (Render)

Service Type Config
Pharma-Pro-Project Web Service (Flask) Root dir: /, Build: pip install -r requirements.txt, Start: gunicorn app:app
Pharma-Pro-Project-1 Static Site (React) Root dir: frontend, Build: npm install && npm run build, Publish: dist

Environment variables on Static Site:

VITE_API_URL = https://pharma-pro-project.onrender.com/api

Credintials for Exploring Website:

(Wholesaler Pharma) : GSTIN : 27ABCEF1234F1Z0

(Retail Pharma) : GSTIN : 27ABCEF1234F2Z4

(MAIL ME FOR PASSWORD)


πŸ“„ License

Not licensed for commercial use.