Multi Tenant POS and Retail Management Platform

POSDokan
Multi-tenant retail POS, inventory, billing, and business management SaaS
- Live website: https://posdokan.com
- Project type: Production SaaS application
- Work covered: Full-stack Laravel development and system architecture
- Architecture: Central SaaS application with isolated tenant POS environments
Project Overview
POSDokan is a multi-tenant retail management platform built for independent stores and multi-branch businesses. It combines point-of-sale, inventory, purchasing, sales, accounting, staff management, reporting, and subscription billing in one web application.
The platform has two clearly separated areas:
- Central application: Marketing website, tenant onboarding, plans, subscriptions, invoices, CRM, affiliate management, accounting, blog, and platform administration.
- Tenant application: A business-specific POS environment running on its own domain or subdomain with isolated data, settings, users, files, and permissions.
The Challenge
The application needed to support many businesses from one maintainable codebase without allowing tenant data to leak between organizations. It also needed to handle real retail workflows such as branch-level stock, lot and expiry tracking, partial payments, returns, transfers, cash registers, and financial reporting.
The SaaS layer introduced additional requirements:
- Safe tenant provisioning and domain assignment
- Plan-based feature access and usage limits
- Trial and subscription lifecycle management
- Recurring invoice generation and payment history
- Tenant-aware local and S3 file storage
- Queue-based email delivery
- Central administration, accounting, CRM, and audit trails
- Search-engine and AI-answer visibility for the public website
Solution Architecture
I implemented POSDokan with Laravel 12 and stancl/tenancy using domain-based tenant identification.
- Central business, billing, and marketing data is stored in the central database.
- Each tenant receives an isolated POS database and tenant-scoped filesystem path.
- Tenant domains initialize the correct database, cache, queue, and filesystem context.
- Central and tenant authentication flows remain separate.
- Database-backed settings prevent one tenant's configuration from affecting another tenant or the central application.
- Tenant storage supports local disks and S3-compatible storage with tenant-specific prefixes.
Central SaaS Features
- Public pricing and plan checkout
- Automated tenant provisioning with duplicate-submission protection
- Trial activation and subscription lifecycle management
- Monthly and yearly plan pricing
- Feature entitlements and per-feature usage limits
- Scheduled upgrades and downgrades using a next-billing-cycle policy
- Storage quotas and subscription storage add-ons
- Automated recurring invoice generation
- Invoice taxes, setup fees, discounts, and manual payment recording
- Downloadable PDF subscription invoices
- Full invoice event and payment transaction history
- Central chart of accounts, journal entries, expenses, transfers, and profit reporting
- Tenant, lead, notification, affiliate, commission, and withdrawal management
- Administrative roles, permissions, search, settings, and audit logs
- Blog categories, tags, rich-text publishing, analytics, and structured data
Tenant POS Features
- Fast POS checkout and standard sales entry
- Cash-register opening and closing workflows
- Products, variants, units, categories, brands, and taxes
- Barcode generation, scanning, and printing
- Multi-branch stock management and branch-to-branch transfers
- Lot, batch, expiry, FIFO, FEFO, and LIFO inventory workflows
- Purchases, suppliers, supplier payments, and purchase returns
- Sales, partial payments, customer dues, deliveries, and sales returns
- Customers, customer groups, deposits, gift cards, and coupons
- Quotations and quotation-to-sale or purchase conversion
- Stock counts, adjustments, quantity alerts, and expiry reports
- Expenses, accounts, account deposits, money transfers, statements, and balance sheets
- Employees, departments, attendance, payroll, and holidays
- Granular role and permission management
- Activity logs and operational audit history
- CSV and Excel import/export for core business records
- Tenant-specific general, POS, mail, SMS, and HRM settings
Billing and Transaction Tracking
The billing system records the complete journey of an invoice instead of overwriting its previous state. Invoice issuance, status changes, payment attempts, successful payments, failures, accounting postings, and administrative actions are stored as separate history records.
Additional safeguards include:
- Sequential invoice numbers protected by application locks
- Database transactions around sensitive billing operations
- Idempotency controls for duplicate checkout submissions
- Preserved billing history after tenant deletion
- Dry-run commands for invoice generation and history backfills
- Configurable billing notifications and queued invoice emails
Security and Data Isolation
- Domain-based tenant resolution
- Separate tenant databases and storage paths
- Separate central and tenant authentication guards
- Role-based authorization with Spatie Laravel Permission
- Subscription and feature-access middleware
- Server-side validation for all critical workflows
- Database transactions for financial and stock operations
- Sanitized rich-text blog content to prevent stored XSS
- Audit logs for central and tenant actions
- No passwords or sensitive configuration values exposed in emails
Performance and Reliability Work
- Redis-compatible cache, queue, and session configuration
- Queue-based email processing so SMTP does not delay user requests
- Eager loading and query reduction in high-traffic POS layouts
- Cached permission and shared layout data
- Pagination for large administrative and activity-log datasets
- Indexed billing, transaction, and reporting tables
- Scheduler-driven billing and storage maintenance commands
- Safe deployment script with Git pull, Laravel cache clearing, queue restart, and Supervisor restart support
SEO, AEO, and GEO Implementation
The central website includes technical SEO and content features designed for both traditional search engines and AI answer systems:
- Page-specific titles, descriptions, canonical URLs, Open Graph, and Twitter metadata
- XML sitemaps, blog sitemap, RSS feed, and
robots.txt - Structured data for the organization, software product, offers, breadcrumbs, articles, FAQs, and how-to content
- Search-safe blog categories, tags, pagination, previews, and indexing controls
- GEO summaries, named entities, definitions, takeaways, sources, and custom schema JSON
- Dedicated solution pages for retail use cases, including multi-branch POS
- Legacy URL redirects that preserve search equity after terminology changes
Testing and Quality Assurance
The repository contains unit and feature tests covering the central SaaS and tenant POS applications, including:
- Tenant bootstrapping and data isolation
- Roles, permissions, and access boundaries
- Plan, subscription, invoice, tax, and storage workflows
- Duplicate submission and billing risk regressions
- Transaction history and accounting balance rules
- Product, sales, purchase, payment, lot, and stock workflows
- Tenant image and storage behavior
- Blog publishing, rich-content sanitization, SEO metadata, schema, and sitemaps
- Queueable mail behavior and tenant-aware settings
Technologies Used
Backend
- PHP 8.3+
- Laravel 12
- MySQL
- Redis
stancl/tenancy- Laravel Sanctum
- Spatie Laravel Permission
- Dompdf
- Maatwebsite Laravel Excel
Frontend
- Blade templates
- JavaScript and jQuery
- HTML5 and CSS3
- Bootstrap
- Alpine.js
- Tailwind CSS tooling
- Summernote rich-text editor
Infrastructure and Operations
- Linux and Nginx
- CloudPanel
- Supervisor queue workers
- Laravel Scheduler
- Local and S3-compatible object storage
- Git-based deployment
- PHPUnit automated tests
My Contributions
- Designed and implemented the central-plus-tenant application architecture
- Integrated domain-based multi-tenancy with isolated databases and filesystems
- Developed tenant onboarding, plan selection, subscriptions, invoices, taxes, and billing history
- Built and improved core POS, inventory, lot, purchase, sales, return, and reporting workflows
- Implemented plan-based feature restrictions and usage limits
- Added central and tenant accounting capabilities with balanced journal rules
- Moved slow email workflows to tenant-aware queues
- Implemented tenant-safe local and S3 storage behavior
- Added CRM leads, affiliate management, audit logs, and operational dashboards
- Built the central blog and its SEO, AEO, and GEO publishing tools
- Improved security, duplicate-submission handling, query performance, responsive tables, and deployment reliability
- Added regression tests for high-risk billing, accounting, tenancy, storage, and POS workflows
Outcome
POSDokan provides a single SaaS platform for onboarding and billing retail businesses while giving every tenant an isolated, full-featured POS environment. The resulting architecture supports multi-branch retail operations, protects tenant boundaries, moves slow work out of user requests, preserves financial history, and provides a maintainable foundation for continued product growth.