OneBill Platform

Complete Feature Showcase

A multi-tenant billing & inventory SaaS built for small retail/shop owners. Hierarchical roles (Super Admin → Admin → Owner → Worker) with modular permissions and subscription-gated features.

FastAPI + MongoDB · React + Vite + TypeScript + Ant Design · JWT · RBAC · Per-tenant module grants

💡 About the Application

OneBill is a multi-tenant billing & inventory SaaS built for small retail shops, kirana stores, boutiques, and similar businesses. It gives every shop owner an end-to-end back-office — from product catalog and barcode scanning to checkout, inventory, expenses, multi-store reporting — wrapped in a role-based app with a Super Admin → Admin → Owner → Worker hierarchy.

🎯 What Owners Get

  • A POS / checkout system that prints 58mm or 80mm thermal receipts.
  • Catalog & inventory with GST, HSN, multi-store stock, and batch/expiry tracking.
  • Customer ledger with loyalty points and reminders.
  • Expenses, bank accounts, suppliers, and staff with attendance.
  • Reports for sales, P&L, inventory, staff performance, and stores comparison.
  • Multi-worker support with per-worker module grants.
  • Subscription-gated modules so customers pay only for what they use.

🏗️ Who Uses It

  • Super Admin — owner of the platform (manages admins & platform settings).
  • Admin — onboarding operator who creates owner tenants & manages their plans.
  • Owner — the shopkeeper / tenant running the business.
  • Worker — cashier / staff at the shop counter.
  • Public — visitors for registration, login, password reset.

🛠️ Design Goals

  • Modular by design — every feature is a module that can be toggled per tenant.
  • Multi-tenant safe — strict owner_id scoping across every query.
  • Secure by default — JWT with server-side session revocation, bcrypt, Fernet at rest, CSRF, CSP, rate limiting.
  • Fast at the counter — barcode scanning, atomic stock reservation, instant checkout.
  • Operable — Docker-ready, async Motor, audit logs, admin activity logs.

📌 User Types at a Glance

#RoleOne-Line Purpose
1Super AdminPlatform owner — manages admins, transfers owners, controls platform policies. Has every module.
2AdminReseller/operator — creates owners, manages their module access, subscriptions and alerts.
3OwnerShop/business tenant — runs the shop with a full back-office (sales, inventory, reports…).
4WorkerCashier/salesperson — uses a subset of the owner's modules; can never exceed owner grants.
5Public / GuestVisitor — can register, log in, or reset password only.

👑 Super Admin Features

Platform-level superuser

Bootstrap-created only · Has every system, business and admin module.

🔐 Authentication & Account

  • Log in to the platform with bootstrap credentials.
  • Forced first-run change-password flow.
  • Manage personal profile, sessions, and password.

👥 Admin Management

👤 Create Admin
Provision new admins with email + welcome email.
📋 List Admins
See all admin accounts in the system.
🚫 Deactivate Admin
Suspend an admin account without deletion.
🔑 Reset Admin Password
Issue a temporary password via secure delivery.
🔄 Transfer Owners
Reassign tenant accounts between admins.
📜 Admin Activity Log
Audit trail of all admin actions.

🗺️ Tracking & Oversight

  • Track Map — visual hierarchy: Super Admins → Admins → Owners → Workers.
  • View all admins, all owners (with assigned admin), and all workers (with assigned owner).
  • Owner / admin relationship graph for accountability.

⚙️ Platform Settings

  • Default modules enabled for new owners.
  • Platform branding / configuration.
  • Global toggles and defaults (/super-admin/settings).

🧩 Admin Module Grants

  • Grant / revoke admin-only modules to plain admins.
  • owner_stats — detailed statistics drawer.
  • alerts — send and manage alerts to owners.
  • Plain admins only see owners they have been granted access to.

🔒 Permissions

  • All system modules (auth, profile, subscription, sessions, dashboard).
  • All business modules (full business bypass).
  • All admin modules.

🛠️ Admin Features

Created by a Super Admin

Operates as a reseller/onboarding operator. Business bypass active; admin modules need Super Admin grant.

🧑‍💼 Owner (Tenant) Onboarding

🆕 Create New Owner
Provision a new tenant with name, email, shop name, place, phone.
/owners/new
✉️ Welcome Email
Auto-generates a temporary password and emails it.
🔐 Force Password Change
must_change_password flag on first login.

🧩 Manage Owner Module Access

  • Enable / disable modules for any owner they manage.
  • Toggle business modules: products, inventory, sales, customers, expenses, bank, reports, stores, suppliers, staff, alerts, batches.
  • Audit log of all grant changes.
/admin/owners/modules

📊 Owner Statistics

  • Detailed owner stats per owner.
  • Sales totals, expenses, profit.
  • Product count, customer count, worker count.
  • Active sessions and subscription status.
/admin/owners/{owner_id}/stats require_module("owner_stats")

🔔 Alerts Management

  • Send alerts/notifications to their owners (requires alerts module).
  • Configure alert rules and view history.
  • Stock and business alerts dispatched via SMTP / WhatsApp.

💳 Subscription Management

  • Grant subscription to an owner (plan, start, end date).
  • Renew subscription for an owner.
  • View subscription status: active · expired · grace.
  • Invoices, plan tier, expiry date, grace window.

📜 Activity & Tracking

  • Personal admin activity log.
  • View list of owners they created and manage.
  • View track map (admins → owners → workers).

🔒 Permissions (Default)

  • All system modules + all business modules (business bypass).
  • Does not automatically have admin modules — must be granted by Super Admin.

🏪 Owner Features

The primary tenant

Runs the shop. Configurable feature set via module_grants. Has PrintSettings, Subscription, and full back-office access.
🏠 Dashboard
Daily/weekly/monthly sales, top products, low stock, recent activity.
/
📦 Products
Catalog, pricing, GST, HSN, images, barcodes.
/products
🔖 Barcodes
Generate and scan with device camera.
/barcodes
📊 Inventory
Stock levels, adjustments, low-stock alerts.
/inventory
🛒 Sales / POS
POS checkout, atomic stock reservation, sales history.
/shop · /cart · /sales
👥 Customers
Directory, ledger, loyalty, reminders.
/customers
💸 Expenses
Categorized tracking by date, store, category.
expenses
🏦 Bank
Accounts, deposits, withdrawals, transfers.
/bank
🏬 Stores
Multi-outlet management with per-store inventory.
/stores
🚚 Suppliers
Supplier directory linked to products.
suppliers
👨‍💼 Staff
Create workers, set attendance, manage access.
/staff
🧩 Worker Modules
Per-worker module grants (intersected with owner).
/workers/modules
🔔 Alerts
Stock and business alerts via in-app/email/WhatsApp.
/alerts
📦 Batches
Batch/expiry tracking, expiry alerts, recall support.
/batches
📈 Reports
Sales, P&L, inventory, staff, stores comparison.
/reports
💳 Subscription
Plan, status, expiry, grace, invoices.
/subscription
👤 Profile
Personal info, password, print settings (58mm/80mm).
/profile
📱 Sessions
List and revoke active devices.
/sessions
🧮 Calculator
Built-in calculator utility.
/calculator

🖨️ Print Settings (58mm / 80mm)

  • Header note, footer note, thank-you message on receipt.
  • Paper size: 58mm or 80mm.
  • Settings inherited by all workers (used at receipt printing).

🛡️ Security & Recovery

  • Forced change-password-required flow on first login.
  • Password reset via tokenized email link.
  • Active session monitoring and revocation.

🔒 Permissions

  • All system modules (always): auth, profile, subscription, sessions, dashboard.
  • Business modules per module_grants (default = LAUNCH_CATALOG_KEYS for fresh accounts).

🧑‍💻 Worker Features

Created by an Owner

Scope is automatically narrowed: effective = worker.grants ∩ owner.grants
🏠 Dashboard
Scoped view of shop dashboard and daily sales.
/
🛒 POS / Sales
Browse products, cart, checkout, sales history.
/shop · /cart · /sales
👥 Customers
Lookup and create customers at checkout.
/customers
📦 Products
Browse catalog and lookup by barcode scan.
/products
📦 Batches
View batches during sales.
/batches
🧮 Calculator
In-app calculator.
/calculator
👤 Profile
View/update info, change password, view subscription.
/profile

🚫 What Workers Cannot Access

/inventory · /barcodes · /stores · /bank · /staff · /reports · /workers/modules · /admin/* · /super-admin/*. Any module not granted to them shows a friendly Module not available page.

🌐 Public / Guest Features

Unauthenticated users

See only essential auth flows.

🔐 Authentication

🔑 Login
Email + password.
/login
📝 Register
Self-signup where enabled.
/register
🔁 Reset Password
Via emailed token.
/reset-password
🔄 Change Password Required
Forced on first login.
/change-password-required

🛡️ Security Layers Seen by Guest

  • Login rate limiting (slowapi per-IP).
  • Account lockout after failed attempts.
  • CSRF protection (double-submit cookie pattern).
  • CSP enforced; security headers applied.

🔒 Cross-Cutting System Features

These run across the platform regardless of role.

🔐 Authentication & Security
JWT, server-side sessions, refresh, bcrypt, account lockout.
🏗️ Multi-Tenancy
All tenant data carries owner_id; strict isolation.
🧩 Permissions Engine
RBAC + per-tenant grants + dependency graph + audit log.
💳 Subscription Gating
Plan tiers, active/expired/grace, renewals.
📁 Secure Uploads
HMAC-signed expiring URLs, Pillow validation, per-owner quota.
🖨️ Barcode & Print
Generate (jsbarcode) + scan (@zxing/browser) + 58/80mm templates.
📣 Notifications
In-app + email + WhatsApp, encrypted credentials.
🧾 Auditing
Admin activity log, grant changes, session tracking.
🚀 Performance
Async Motor, lazy pages, bundle compression, React Query.
🧪 Testing
pytest, Playwright e2e, Vitest, React Testing Library.
🐳 Deployment
Dockerfile, run scripts, deploy.md guide.

⚡ Database Operations / sec (Estimated)

Realistic per-shop baseline estimates for a single tenant operating at moderate retail throughput (one busy checkout counter). Values represent peak ops/sec against MongoDB (Motor async driver). Reads are separate from writes; totals include both.

📊 Per-Module Throughput

Module Reads (ops/sec) Writes (ops/sec) Total (ops/sec) Reasoning
Sales / POS 8 – 12 2 – 4 10 – 16 Highest load. Every cart action, item scan, stock reservation, and checkout hits the DB. Atomic stock reservation on every line item.
Inventory 3 – 5 0.5 – 1 3.5 – 6 Stock-level lookups on every product view + sale. Adjustments are rare but write-heavy.
Products 2 – 4 0.1 – 0.3 2.1 – 4.3 Catalog browsing & barcode lookup are frequent. Edits are rare.
Customers 1 – 2 0.2 – 0.5 1.2 – 2.5 Lookups during checkout. New customer creation is occasional.
Batches 0.5 – 1 0.1 – 0.2 0.6 – 1.2 Batch lookup during sales; expiry scans are periodic.
Dashboard 0.2 – 0.5 0 0.2 – 0.5 Periodic refresh on home page. Mostly aggregated reads.
Reports 0.1 – 0.5 0 0.1 – 0.5 On-demand, heavy aggregation queries. Often cached.
Alerts 0.2 – 0.5 0.05 – 0.1 0.25 – 0.6 Polling for in-app notifications; occasional dispatch events.
Staff 0.1 – 0.3 0.05 – 0.1 0.15 – 0.4 Worker listing, attendance pings.
Stores 0.1 – 0.3 0.01 0.11 – 0.31 Store switcher on multi-outlet tenants.
Expenses 0.05 – 0.1 0.02 0.07 – 0.12 Rare writes; reads only when viewing expense reports.
Bank 0.05 0.02 0.07 Occasional transactions; mostly on reconciliation.
Suppliers 0.05 0.01 0.06 Rarely edited; rarely read outside purchase flows.
Auth 0.5 – 1 0.1 – 0.3 0.6 – 1.3 Login, JWT verification, session refresh, lockout checks.
Profile 0.05 0.01 0.06 Rare reads & saves.
Sessions 0.1 – 0.3 0.05 0.15 – 0.35 Active-session listing, periodic refresh.
Subscription 0.01 0.005 0.015 Checked on every protected request; cached aggressively.
Calculator 0 0 0 Client-only. No DB traffic.
Barcode scan 1 – 2 0 1 – 2 Each scan triggers a product lookup.

👤 Per-User Ops / sec

Each role drives a different mix of modules. Click a tab to see the DB load attributable to a single active user of each type, plus the per-endpoint breakdown of which APIs they primarily hit.

Total ops/sec
0.6 – 2.5
Reads / sec
0.5 – 2
Writes / sec
0.1 – 0.5
EndpointCalls/minCalls/sec
GET /api/super-admin/track-map0.1 – 0.50.002 – 0.008
GET /api/super-admin/admins0.1 – 0.30.002 – 0.005
GET /api/super-admin/activity0.1 – 0.30.002 – 0.005
GET /api/super-admin/settings/owner-defaults0.05 – 0.10.001 – 0.002
POST /api/super-admin/admins0.01 – 0.050.0002 – 0.001
PATCH /api/super-admin/admins/{id}/status0.01 – 0.050.0002 – 0.001
POST /api/super-admin/admins/{id}/reset-password0.01 – 0.030.0002 – 0.0005
POST /api/super-admin/owners/{id}/transfer0.03 – 0.150.0005 – 0.003
/api/auth/me60 – 3001 – 5
POST /api/auth/refresh6 – 300.1 – 0.5

Module breakdown: Admin management ~0.3 ops/sec · Track Map ~0.5 ops/sec · Activity log ~0.3 ops/sec · Platform settings ~0.1 ops/sec · Module grants ~0.1 ops/sec · Auth/sessions ~1.5 ops/sec.

Total ops/sec
1.2 – 3.8
Reads / sec
1 – 3
Writes / sec
0.2 – 0.8
EndpointCalls/minCalls/sec
GET /api/admin/owners/{owner_id}/stats0.5 – 20.008 – 0.033
GET /api/users/owners1 – 50.017 – 0.083
POST /api/users/owners0.01 – 0.050.0002 – 0.001
GET /api/subscriptions/owners0.5 – 20.008 – 0.033
POST /api/subscriptions/owners/{id}/grant0.05 – 0.20.001 – 0.003
GET /api/modules/owners/{id}/grants0.5 – 20.008 – 0.033
PUT /api/modules/owners/{id}/grants0.01 – 0.10.0002 – 0.002
POST /api/alerts/send0.05 – 0.20.001 – 0.003
GET /api/alerts/logs0.1 – 0.50.002 – 0.008
POST /api/expenses0.05 – 0.30.001 – 0.005
GET /api/expenses0.5 – 30.008 – 0.05
/api/auth/me60 – 3001 – 5
POST /api/auth/refresh6 – 300.1 – 0.5

Module breakdown: Owner onboarding ~0.4 ops/sec · Module access ~0.4 ops/sec · Owner stats ~0.5 ops/sec · Alerts ~0.4 ops/sec · Subscriptions ~0.3 ops/sec · Activity log ~0.3 ops/sec · Expenses ~0.1 ops/sec · Auth/sessions ~1.5 ops/sec.

Idle
1 – 3 ops/sec
Busy
18 – 31 ops/sec
Peak
30 – 50 ops/sec
EndpointCalls/minCalls/sec
POST /api/sales/checkout6 – 400.1 – 0.7
GET /api/sales5 – 300.08 – 0.5
GET /api/products10 – 800.17 – 1.3
GET /api/products/{id}10 – 800.17 – 1.3
GET /api/inventory5 – 300.08 – 0.5
GET /api/inventory/summary2 – 150.03 – 0.25
GET /api/inventory/movements2 – 150.03 – 0.25
GET /api/customers5 – 300.08 – 0.5
GET /api/customers/{id}5 – 300.08 – 0.5
GET /api/customers/{id}/ledger1 – 60.017 – 0.1
GET /api/customers/khata/summary2 – 120.03 – 0.2
GET /api/batches1 – 60.017 – 0.1
GET /api/batches/alerts0.5 – 30.008 – 0.05
GET /api/reports/dashboard1 – 50.017 – 0.083
GET /api/reports/sales0.5 – 30.008 – 0.05
GET /api/reports/profit-loss0.2 – 10.003 – 0.017
GET /api/reports/inventory0.2 – 10.003 – 0.017
GET /api/reports/customers0.1 – 0.50.002 – 0.008
GET /api/reports/staff-performance0.1 – 0.50.002 – 0.008
GET /api/reports/stores-comparison0.1 – 0.50.002 – 0.008
POST /api/batches0.2 – 20.003 – 0.033
POST /api/inventory/{id}/move0.5 – 50.008 – 0.083
POST /api/bank/transactions0.5 – 50.008 – 0.083
GET /api/bank/accounts1 – 60.017 – 0.1
GET /api/bank/transactions1 – 80.017 – 0.133
POST /api/staff/attendance/checkin0.5 – 40.008 – 0.067
POST /api/staff/attendance/checkout0.5 – 40.008 – 0.067
GET /api/staff/directory1 – 50.017 – 0.083
GET /api/stores0.5 – 30.008 – 0.05
GET /api/users/me60 – 3001 – 5
POST /api/auth/refresh6 – 300.1 – 0.5

Hot path: POST /api/sales/checkout drives 0.1 – 0.7 ops/sec and fans out to inventory + customer reads. Atomic stock reservation on every line item. Reports rate-limited 60/min/user.

Idle
0.5 – 1.7 ops/sec
Busy
6 – 13 ops/sec
Peak
12 – 23 ops/sec
EndpointCalls/minCalls/sec
POST /api/sales/checkout5 – 300.08 – 0.5
GET /api/sales5 – 300.08 – 0.5
PUT /api/sales/{id}0.1 – 10.002 – 0.017
GET /api/products5 – 300.08 – 0.5
GET /api/products/{id}5 – 300.08 – 0.5
GET /api/products/categories1 – 80.017 – 0.133
GET /api/products/summary1 – 80.017 – 0.133
GET /api/products/brands1 – 80.017 – 0.133
GET /api/products/reorder0.5 – 40.008 – 0.067
GET /api/customers5 – 300.08 – 0.5
GET /api/customers/{id}5 – 300.08 – 0.5
POST /api/customers0.5 – 50.008 – 0.083
GET /api/customers/{id}/ledger1 – 60.017 – 0.1
GET /api/customers/khata/summary2 – 120.03 – 0.2
GET /api/inventory5 – 300.08 – 0.5
GET /api/inventory/summary2 – 150.03 – 0.25
GET /api/inventory/movements2 – 150.03 – 0.25
POST /api/inventory/{id}/move0.5 – 50.008 – 0.083
POST /api/inventory/transfer0.1 – 10.002 – 0.017
GET /api/batches1 – 60.017 – 0.1
GET /api/batches/alerts0.5 – 30.008 – 0.05
GET /api/batches/by-product/{id}0.5 – 30.008 – 0.05
POST /api/batches0.2 – 20.003 – 0.033
GET /api/users/me60 – 3001 – 5
POST /api/auth/refresh6 – 300.1 – 0.5

Hot path: POST /api/sales/checkout is the worker primary driver. Cannot access admin-only or owner-only routes (inventory writes, reports, alerts, staff, bank, stores).

Total ops/sec
0.15 – 0.7
Reads / sec
0.1 – 0.5
Writes / sec
0.05 – 0.2
EndpointCalls/minCalls/sec
POST /api/auth/login0.5 – 50.008 – 0.083
POST /api/auth/forgot-password0.05 – 0.30.001 – 0.005
POST /api/auth/reset-password0.05 – 0.30.001 – 0.005
POST /api/auth/register0.01 – 0.10.0002 – 0.002
GET /0.5 – 50.008 – 0.083
GET /health0.5 – 50.008 – 0.083

Public endpoints only. Login rate-limited 10/min/IP; lockout after failed attempts. No JWT required.

📦 User-to-Tenant Multiplier

ScenarioUsers activeOps / sec (DB)Notes
1 owner + 1 worker, quiet2~2 – 5Mostly owner dashboard + worker idle.
1 owner + 2 workers, busy3~25 – 60Workers doing POS, owner reviewing reports.
1 owner + 3 workers, peak4~50 – 1103 active counters + owner.
1 admin managing 10 owners11~15 – 35Admin idle, owners split across platform.
1 super admin managing 5 admins6~5 – 15Mostly management views.

🧮 Aggregate Throughput

ScenarioWrites / secReads / secTotal / secNotes
Single shop, idle 0.1 – 0.3 1 – 3 1 – 3 Dashboard polling, auth pings, alert checks.
Single shop, busy 3 – 6 15 – 25 18 – 31 One active counter, frequent scans, periodic reports.
Single shop, peak hour 5 – 10 25 – 40 30 – 50 Multiple counters, batch entry, real-time report refresh.
Platform (10k tenants, 10% active) 500 – 1,000 2,500 – 4,000 3,000 – 5,000 Sharded across MongoDB cluster. owner_id is the shard key.

🚀 Hotspot Write Collections

  • sales — peak 2 – 4 writes/sec per shop. Indexed by owner_id, created_at, store_id, customer_id.
  • stock_movements — 1 – 3 writes/sec per shop from atomic stock reservation.
  • audit_log & admin_activity — bursty, low-rate but append-heavy.
  • sessions — periodic refresh on every protected request.

🔌 Backend Mitigations

  • Async Motor driver — non-blocking I/O across thousands of concurrent ops.
  • Compound indexes on (owner_id, created_at) for tenant-scoped queries.
  • React Query cache on the frontend — deduplicates reads within TTL.
  • Rate limiting (slowapi) — bounds burst spikes per IP.
  • Connection pooling on MongoDB Atlas.
  • Webhook & alert dispatch moved off the request path where possible.

📋 Module Catalog (Reference)

Authoritative module list lives in backend/app/models/module.py.

System Modules (always on, FR-003)

auth
Login, sessions, JWT, refresh, lockout.
profile
Profile, password change, print settings.
subscription
Plan/billing, status.
sessions
Active devices, revoke.
dashboard
Home overview.

Business Modules (per-tenant toggleable, FR-002)

products
Catalog, pricing, GST, HSN, images, barcode.
sales
POS, sales history, atomic stock reservation.
inventory
Stock levels, adjustments, summaries.
customers
Directory, ledger, loyalty, reminders.
expenses
Expense tracking.
bank
Bank accounts and transactions.
reports
Sales, P&L, inventory, staff, stores.
stores
Multi-outlet management.
suppliers
Supplier directory.
staff
Worker management and attendance.
alerts
Stock & business alerts.
batches
Batch / expiry tracking.

Admin Modules (superadmin-grantable to plain admins)

owner_stats
Detailed statistics drawer.
alerts
Admin-side alert management.

🎬 Demo Flow Suggestions

A typical demo could walk through:

  1. Public → Register / Login as a new user.
  2. Super Admin → Bootstrap, create Admin, review Track Map.
  3. Admin → Create Owner (tenant), grant modules, send welcome alert, renew subscription.
  4. Owner → Add products, configure print settings, add workers, set per-worker modules, perform a sale, view reports.
  5. Worker → Login, scan barcode, complete a sale, view own sales history.
  6. Owner → View worker activity in reports, run P&L, manage inventory alerts.