Skip to content

Repository files navigation

🏪 उधार बुक (Udhar Book) — Store Credit Management System

Version Node.js SQLite PWA License

दुकानदारों के लिए उधार हिसाब-किताब रखने का स्मार्ट तरीका!

ग्राहकों का पूरा डेटा — नाम, फोटो, मोबाइल, खरीदा गया सामान, बिल फोटो, बकाया रकम, पेमेंट हिस्ट्री, ट्रस्ट रेटिंग — सब एक जगह track करो। SMS/WhatsApp से reminder भेजो, CSV export करो, monthly report देखो।


📋 Table of Contents

  1. Features
  2. What's New in v2.0
  3. Tech Stack
  4. Project Structure
  5. Prerequisites
  6. Installation & Setup
  7. Server Start करना
  8. App कैसे Use करें
  9. SMS Setup (Fast2SMS)
  10. API Endpoints
  11. Database Schema
  12. Performance
  13. Troubleshooting

✨ Features

Core Features

Feature Description
🔐 Registration & Login दुकानदार अपना अकाउंट बनाए — नाम, दुकान का नाम, मोबाइल, पासवर्ड
🔢 PIN Lock 4-digit PIN से app को lock करो — extra security layer
👥 Customer Management ग्राहक add करो with photo, mobile, address
📸 Customer Photos ग्राहक की photo upload करो — easy identification
🛒 Transaction Tracking हर उधार entry — सामान, quantity, rate, due date, बिल photo
🧾 Bill Photo Upload Transaction के साथ बिल की photo attach करो
💰 Partial Payment थोड़ा-थोड़ा पैसा लो — progress bar + payment history timeline
📱 SMS Reminder Fast2SMS API से automatic SMS भेजो
💬 WhatsApp Reminder Pre-typed WhatsApp message — बस send दबाओ
Auto Daily Reminder रोज़ सुबह 9 AM — overdue customers को auto SMS

Advanced Features (v2.0)

Feature Description
Trust Rating ग्राहकों को 1-5 star rating दो — track करो कौन reliable है
📝 Customer Notes हर ग्राहक पर personal notes लिखो
📊 Monthly Report Monthly analytics — total बकाया, collection, Chart.js graph
📅 Calendar View Calendar में due dates देखो — color-coded (paid/unpaid)
📁 CSV Export सारा data Excel-friendly CSV में download करो
💾 Database Backup One-click DB backup + download
🌓 Dark/Light Theme Toggle between dark glassmorphism & light theme
🌐 Hindi/English Language switch — पूरा app Hindi या English में
📲 PWA Support Phone में install करो like a native app — offline caching
🎇 Antigravity Particles Beautiful floating particle system — orbs, stars, diamonds, rings
🔄 Auto Backup Daily automatic database backup (cron job)
🎯 Overdue Alerts Color-coded overdue cards — critical, high, medium severity
🖨️ Print Receipt Transaction receipt print करो

🆕 What's New in v2.0

✅ PIN Lock System — 4-digit security lock
✅ Customer Photos — profile photo upload
✅ Bill Photos — attach bill to transactions
✅ Trust Rating — 1-5 star customer rating
✅ Customer Notes — personal notes per customer
✅ Monthly Report — analytics with Chart.js
✅ Calendar View — visual due date calendar
✅ CSV Export — Excel-friendly data export
✅ Database Backup — one-click backup & download
✅ Dark/Light Theme Toggle
✅ Hindi/English Language Switch
✅ PWA — installable on mobile
✅ Antigravity Particle System — orbs, stars, diamonds, rings
✅ Enhanced Animations — levitate, float, popIn, slideIn effects
✅ Gzip Compression — 78% smaller file transfers
✅ Lazy-loaded Chart.js — faster initial page load
✅ Color-coded Overdue Alerts
✅ Payment History Timeline
✅ Print Receipt Support

🛠 Tech Stack

Technology Use
Node.js Backend runtime
Express.js Web server & API routes
SQLite (better-sqlite3) Local database — WAL mode for performance
bcrypt Password & PIN hashing (secure storage)
express-session Login session management (7 दिन तक)
multer File uploads (customer photos, bill photos)
compression Gzip compression — ~78% smaller transfers
node-cron Daily backup + reminder scheduler (9 AM)
Chart.js Monthly report chart (lazy-loaded)
Fast2SMS API Indian SMS sending service
Service Worker PWA offline caching
HTML/CSS/JS Frontend SPA with glassmorphism UI

📁 Project Structure

storeDB/
├── server.js              # Express server — सारे API routes
├── database.js            # SQLite setup — tables, migrations, backup
├── package.json           # Dependencies & scripts
├── udhar_book.db          # SQLite database (auto-created)
├── README.md              # यह file
├── backups/               # Automatic daily backups
└── public/                # Frontend files
    ├── index.html         # Main HTML — screens, modals, PIN pad
    ├── manifest.json      # PWA manifest — installable app
    ├── service-worker.js  # Offline caching — network-first for API
    ├── uploads/           # Customer photos & bill photos
    ├── css/
    │   └── style.css      # Glassmorphism + antigravity animations
    └── js/
        └── app.js         # Frontend logic — i18n, particles, API calls

📌 Prerequisites

1. Node.js Install करो

  1. https://nodejs.org पर जाओ
  2. LTS version download करो (green button)
  3. Installer run करो → Next-Next-Finish
  4. Verify:
    node --version    # v18.x.x या ऊपर
    npm --version     # 9.x.x या ऊपर

⚠️ node not found आए तो PC restart करो।


🚀 Installation & Setup

Step 1: Project folder open करो

cd C:\Users\Amitj\OneDrive\Desktop\storeDB

Step 2: Dependencies install करो

npm install

यह command इन packages को install करेगा:

  • better-sqlite3 — SQLite database
  • bcrypt — Password encryption
  • express — Web server
  • express-session — Login sessions
  • multer — File upload handling
  • compression — Gzip compression
  • node-cron — Scheduler

⚠️ better-sqlite3 को C++ build tools चाहिए। Error आए तो:

npm install --global windows-build-tools

Step 3: Verify

dir node_modules    # folder बन गया होना चाहिए

▶️ Server Start करना

cd C:\Users\Amitj\OneDrive\Desktop\storeDB
node server.js

Output:

🏪 Udhar Book is running!
📍 Open: http://localhost:3000

Browser में खोलो: http://localhost:3000

Server बंद करना: Ctrl + C

💡 Port already in use?

Get-Process -Name "node" | Stop-Process -Force
node server.js

📖 App कैसे Use करें

🔐 Step 1: Account बनाओ (Register)

  1. http://localhost:3000 खोलो
  2. "Register" tab → भरो:
    • आपका नाम — दुकानदार का नाम
    • दुकान का नाम — जैसे "Sharma General Store"
    • मोबाइल नंबर — login mobile
    • पासवर्ड — कम से कम 4 characters
    • Confirm Password
  3. "Register" दबाओ → Dashboard खुल जाएगा!

🔢 Step 2: PIN Lock Setup (Optional)

  1. ⚙️ SettingsPIN Lock section
  2. 4-digit PIN enter करो → Save
  3. अब हर बार app खोलोगे तो PIN मांगेगा

👥 Step 3: ग्राहक Add करो

  1. "+ ग्राहक जोड़ें" बटन दबाओ
  2. नाम, मोबाइल, पता (optional) भरो
  3. "Save" → ग्राहक list में दिखेगा
  4. ग्राहक detail page पर 📷 icon से photo upload कर सकते हो

🛒 Step 4: उधार Entry करो

  1. ग्राहक पर click → "+ उधार Entry" दबाओ
  2. सामान add करो:
    • Item Name — "चावल", "दाल", "तेल"
    • Price ₹ — rate
    • Qty — quantity
    • "+ Add Item" — multiple items
  3. Due Date select करो
  4. 📷 बिल photo attach करो (optional)
  5. "Save" → Transaction card बन जाएगा

💰 Step 5: Payment लो

Full Payment:

  • Transaction पर "✅ पूरा भुगतान" click → green done!

Partial Payment:

  • "💰 कुछ भुगतान" → amount enter → "Pay"
  • Progress bar update + payment history timeline दिखेगा
  • पूरा amount भरने पर auto-complete

⭐ Step 6: Trust Rating & Notes

  1. ग्राहक detail page पर ⭐ stars click करो → rating save
  2. Notes section में कुछ भी लिखो → "Save"

📱 Step 7: Reminder भेजो

  1. "📱 Remind" बटन दबाओ
  2. SMS setup है → automatic SMS चला जाएगा
  3. SMS fail → "WhatsApp से भेजें" button → pre-typed message

📊 Step 8: Reports & Calendar

  • Report 📊 → Monthly analytics with chart
  • Calendar 📅 → Due dates visual calendar (color-coded)
  • Export 📁 → CSV download (Excel-friendly)
  • Backup 💾 → Database download

🌓 Theme & Language

  • ⚙️ Settings → Theme toggle (Dark/Light)
  • ⚙️ Settings → Language (Hindi/English)

📲 SMS Setup (Fast2SMS)

Step 1: Account बनाओ

  1. https://www.fast2sms.com → Sign Up
  2. Email verify करो

Step 2: API Key लो

  1. Login → Left sidebar → "Dev API"
  2. API Key Copy करो

Step 3: App में Save करो

  1. ⚙️ Settings → API Key paste → "Save Key"
  2. ✅ Status: Active दिखेगा

Step 4: Test करो

  1. "Test SMS" दबाओ → apne number pe SMS aayega

💡 Fast2SMS नए accounts पर free SMS credits देता है।


🔗 API Endpoints

Auth

Method Endpoint Description
POST /api/register नया account
POST /api/login Login
POST /api/logout Logout
GET /api/me Current user info

PIN Lock

Method Endpoint Description
POST /api/pin/set PIN set करो
POST /api/pin/verify PIN verify करो
POST /api/pin/remove PIN हटाओ

Customers

Method Endpoint Description
GET /api/customers सारे ग्राहक
POST /api/customers नया ग्राहक
GET /api/customers/:id ग्राहक detail
DELETE /api/customers/:id ग्राहक delete
POST /api/customers/:id/photo Photo upload
PUT /api/customers/:id/trust Trust rating
PUT /api/customers/:id/notes Notes save

Transactions

Method Endpoint Description
GET /api/customers/:id/transactions Transactions list
POST /api/customers/:id/transactions नई उधार entry
PUT /api/transactions/:id/pay Payment (full/partial)
DELETE /api/transactions/:id Transaction delete

Reminders & Reports

Method Endpoint Description
POST /api/customers/:id/remind Reminder भेजो
GET /api/report/monthly Monthly report
GET /api/calendar Calendar events

Export & Backup

Method Endpoint Description
GET /api/export/csv CSV download
POST /api/backup Manual backup
GET /api/backup/download DB download

Settings & Dashboard

Method Endpoint Description
GET /api/settings Settings load
POST /api/settings Setting save
POST /api/settings/test-sms Test SMS
GET /api/dashboard Dashboard stats

🗃 Database Schema

SQLite (file: udhar_book.db) — WAL mode, foreign keys enabled

Tables:

1. store_owners — दुकानदार

Column Type Description
id INTEGER (PK) Auto ID
name TEXT दुकानदार का नाम
shop_name TEXT दुकान का नाम
mobile TEXT (UNIQUE) मोबाइल नंबर
password TEXT Hashed password
pin TEXT Hashed 4-digit PIN (optional)
created_at DATETIME बनने की date

2. customers — ग्राहक

Column Type Description
id INTEGER (PK) Auto ID
owner_id INTEGER (FK) किस दुकानदार का
name TEXT ग्राहक का नाम
mobile TEXT मोबाइल नंबर
address TEXT पता (optional)
photo TEXT Photo file path
trust_rating INTEGER 1-5 star rating
notes TEXT Personal notes
created_at DATETIME बनने की date

3. transactions — उधार entries

Column Type Description
id INTEGER (PK) Auto ID
customer_id INTEGER (FK) किस ग्राहक का
owner_id INTEGER (FK) किस दुकानदार का
bill_photo TEXT Bill photo path
created_at DATETIME Entry date
due_date DATETIME Due date
is_paid INTEGER 0=pending, 1=paid
paid_amount REAL Partial amount paid
paid_at DATETIME Payment date
reminder_sent INTEGER Reminder sent flag

4. transaction_items — सामान list

Column Type Description
id INTEGER (PK) Auto ID
transaction_id INTEGER (FK) किस transaction का
item_name TEXT सामान का नाम
price REAL कीमत
quantity INTEGER कितना

5. payment_history — Payment timeline

Column Type Description
id INTEGER (PK) Auto ID
transaction_id INTEGER (FK) किस transaction का
amount REAL कितना दिया
paid_at DATETIME कब दिया

6. reminders — Reminder history

Column Type Description
id INTEGER (PK) Auto ID
transaction_id INTEGER (FK) किस transaction के लिए
customer_id INTEGER (FK) किस ग्राहक को
sent_at DATETIME कब भेजा
type TEXT manual / auto

7. settings — App settings

Column Type Description
id INTEGER (PK) Auto ID
owner_id INTEGER (FK) किस दुकानदार का
setting_key TEXT Key name
setting_value TEXT Value

⚡ Performance

App is optimized for mobile:

Optimization Impact
Gzip Compression ~78% smaller transfers (112KB → 24KB)
Lazy Chart.js 250KB+ removed from initial load
Static Caching maxAge: 1 day — browser caches files
Google Fonts 3 weights only (400, 600, 700)
Reduced Particles 12 on mobile, 28 on desktop
Service Worker Cache-first for static, network-first for API

❓ Troubleshooting

🔴 npm install में error

npm install --global windows-build-tools
npm install

🔴 EADDRINUSE: port 3000 in use

Get-Process -Name "node" | Stop-Process -Force
node server.js

🔴 Database reset (सारा data delete)

# Server बंद करो पहले (Ctrl+C)
Remove-Item udhar_book.db, udhar_book.db-shm, udhar_book.db-wal -ErrorAction SilentlyContinue
node server.js
# नया database बन जाएगा

🔴 SMS नहीं जा रही

  1. Fast2SMS API key check करो (Settings)
  2. Test SMS बटन use करो
  3. Fast2SMS balance check करो
  4. 10-digit Indian number होना चाहिए

🔴 Photos upload नहीं हो रही

  • public/uploads/ folder exist करना चाहिए (auto-created)
  • File size limit: 5MB

🔴 PIN भूल गए

  • Database reset करना होगा (ऊपर देखो)
  • या manually DB se PIN column clear करो

🔴 App mobile पर slow load

  • Server pe gzip compression enabled है (auto)
  • Browser cache clear करो
  • WiFi/mobile data check करो

📄 License

Personal use — Made for Amit Ji 🙏


Made with ❤️ — Udhar Book v2.0

Glassmorphism UI • Antigravity Particles • PWA Ready

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages