A modern, self-hosted business operating system for wholesale import and distribution companies. Replaces spreadsheet-driven workflows with a reliable, auditable, all-in-one platform.
- Vision
- Features
- Technology Stack
- Architecture
- Screenshots
- Hosting / Deployment
- Development Setup
- Project Structure
- Development Status
- Design Philosophy
- Why WBOS Exists
- Contributing
- License
WBOS was born from a real business need. Our wholesale snack import business relied heavily on Excel (and eventually Odoo) to manage inventory, purchase orders, shipments, customers, suppliers, sales, payments, and financial reporting. Spreadsheets offered flexibility but became increasingly difficult to maintain, audit, and scale as the business grew.
WBOS is the single source of truth for every operational workflow — from purchasing inventory to receiving customer payments.
- Products with SKU, barcode, categories, and unit of measure tracking
- Multi-warehouse support with per-warehouse stock levels
- FIFO inventory costing with lot-level tracking
- Immutable inventory ledger — every stock movement is recorded and cannot be altered
- Stock adjustments, warehouse transfers, and cycle counts
- Low stock alerts and inventory valuation
- Supplier management with contact details and history
- Purchase orders with partial receiving support
- Goods receipt notes (GRN) with automatic inventory posting
- Receiving against POs or manual (ad-hoc) receiving
- Approval workflow (self-approval or dual approval)
- Customer management with credit limits and outstanding balances
- Sales orders with line-item pricing from product catalog
- Sales invoices with credit notes
- Customer statements and aging reports
- Partial payment allocation across invoices
- Payment recording with allocation to specific invoices
- Payment history per customer and invoice
- Outstanding balance tracking
- Real-time KPIs: today's sales, monthly revenue, outstanding receivables, inventory value, low stock items, overdue customers
- Monthly sales trend chart
- Top products and top customers charts
- Recent activity feed
- Unpaid invoices summary
- Sales reports
- Inventory valuation reports
- Gross profit analysis
- Purchasing reports
- Customer and supplier reports
- In-app notification center with unread indicators and bulk actions (read all / clear read)
- Task and shipment lifecycle notifications (assigned, scheduled, available, completed, shipment ready)
- Optional Firebase Cloud Messaging push delivery for mobile clients
- Retention pruning keeps the activity feed bounded
- One-click backup creation — PostgreSQL dump + uploads archive + config/manifest
- Timestamped backup packages with integrity verification
- Download, restore, and diagnostics from the Settings UI
- Runtime retention tiers (daily, weekly, monthly, yearly)
- Guided first-run setup wizard (warehouses → products → customers → suppliers → orders)
- Dismissible onboarding card that collapses into a compact progress banner
- Welcome dashboard with quick-action buttons for empty organizations
- Responsive sidebar with desktop collapsible (Ctrl+B) and mobile slide-over drawer
- Dark mode support
- Production-ready error boundaries on all forms
- Print-ready invoice layout with
window.open()navigation - Server-side PDF generation via Playwright in Docker
- Auth session handling fixed — API routes pass request headers directly
- All client-side
crypto.randomUUID()replaced with a universaluid()fallback for compatibility - Health endpoints switched from raw SQL (
SELECT id FROM "Organization") to Prisma ORM — zeroprisma:erroron build - Complete favicon set (
favicon.ico, SVG, 16×16, 32×32, Apple Touch Icon,site.webmanifest) - Logo upload fixed with cache-busting and image-load error fallback
- Empty states across all list pages
- Next.js 16 (App Router)
- React 19
- TypeScript
- Tailwind CSS 3
- shadcn/ui components
- Next.js Server Actions — form mutations
- Route Handlers — API endpoints (PDF generation, health checks)
- Application Services — business logic layer
- Repository Pattern — database access abstraction
- PostgreSQL 17
- Prisma ORM with migrations
- Better Auth with email/password, session management, and organization-level multi-tenancy
- Docker with
output: "standalone"for self-hosting - Docker Compose — single-command deployment
- GitHub Container Registry (GHCR) — container image distribution
WBOS follows a Modular Monolith architecture with domain-driven structure.
Browser
│
▼
React Components (Server + Client)
│
▼
Server Actions / Route Handlers
│
▼
Application Services ──► Domain Logic
│
▼
Repositories ──► Prisma ORM ──► PostgreSQL
Key architectural decisions:
- Immutable business history — inventory ledger entries, once written, are never modified
- Transaction-based inventory — every stock movement is a double-entry ledger transaction
- FIFO inventory costing — cost layers tracked per lot, consumed in order of receipt
- Multi-tenant — all data scoped to
organizationIdvia authenticated request context - Column-level encryption — sensitive fields (VAT numbers, financial data) encrypted at rest
GitHub ──► GitHub Container Registry (GHCR)
│
▼
Homelab Server
│
▼
Docker Compose (wbos + postgres)
│
▼
Port 3005 → Container 3000
Images are built via GitHub Actions, pushed to ghcr.io/devhoss/wbos:latest, and pulled onto the server.
services:
wbos:
image: ghcr.io/devhoss/wbos:latest
ports:
- "3005:3000"
environment:
DATABASE_URL: "postgresql://user:password@db:5432/wbos"
BETTER_AUTH_URL: "https://wbos.yourdomain.com"
INTERNAL_APP_URL: "http://127.0.0.1:3000"
BETTER_AUTH_SECRET: "<generate-a-secret>"
BETTER_AUTH_TRUSTED_ORIGINS: "http://localhost:3000"
WBOS_STORAGE_ROOT: "/app/storage"
volumes:
- ./storage:/app/storage
- ./backups:/app/backups
depends_on:
- db
restart: unless-stopped
db:
image: postgres:17-alpine
environment:
POSTGRES_DB: wbos
POSTGRES_USER: user
POSTGRES_PASSWORD: password
volumes:
- pgdata:/var/lib/postgresql/data
restart: unless-stopped
volumes:
pgdata:-
Create storage directories with the correct UID (the app runs as UID 1001):
mkdir -p storage backups sudo chown -R 1001:1001 storage backups sudo chmod -R 775 storage backups
-
Copy the snippet above into a
docker-compose.ymlfile. -
Replace
BETTER_AUTH_SECRETwith a random string (runopenssl rand -hex 32). -
Replace the database credentials and domain.
-
Start the stack:
docker compose up -d
On first start, the entrypoint script automatically:
- Validates storage directories exist and are writable
- Runs database migrations
- Starts the application server
-
Visit
https://wbos.yourdomain.com, sign up, and complete the onboarding wizard.
git pull # if using a local checkout
docker compose pull # pull the latest GHCR image
docker compose up -d # recreate containersThe database schema is automatically migrated on container start via the entrypoint script.
| Variable | Required | Description |
|---|---|---|
DATABASE_URL |
Yes | PostgreSQL connection string |
BETTER_AUTH_URL |
Yes | Public URL (must match what users type in the browser, e.g. https://wbos.example.com) |
BETTER_AUTH_SECRET |
Yes | Secret key for session encryption |
BETTER_AUTH_TRUSTED_ORIGINS |
No | Comma-separated list of additional origins to trust (for reverse proxy or development) |
INTERNAL_APP_URL |
No | Internal URL for Playwright PDF generation (default: http://127.0.0.1:3000) |
WBOS_STORAGE_ROOT |
No | Directory for uploaded files and runtime data (default: <cwd>/storage). Must be a persisted Docker volume. |
If using Nginx Proxy Manager (or similar) in front of the Docker container:
- Set
BETTER_AUTH_URLto the public HTTPS URL (e.g.https://wbos.home.lab). - Forwarded headers — ensure NPM passes these to the backend:
X-Forwarded-Proto: httpsX-Forwarded-Host: wbos.home.labX-Forwarded-For(your client IP)
- Trusted origins — add any development or internal URLs to
BETTER_AUTH_TRUSTED_ORIGINS:BETTER_AUTH_TRUSTED_ORIGINS=http://localhost:3000,http://192.168.100.36:3000 - WebSocket support (optional, for hot reload) — enable WebSocket passthrough in NPM.
Uploaded files (organization logos) are stored in WBOS_STORAGE_ROOT/uploads/. Mount a Docker volume to persist uploads across container restarts:
volumes:
- ./storage:/app/storage
- ./backups:/app/backupsOn first deployment, ensure the directories exist and have correct permissions:
mkdir -p storage backups
sudo chown -R 1001:1001 storage backups
sudo chmod -R 775 storage backupsThe container runs a storage validation check on startup. If permissions are incorrect, the container will fail immediately with a clear error message and instructions. Run docker compose logs app to see the validation output.
The application exposes a health check at /api/health:
curl http://localhost:3000/api/healthResponse:
{
"healthy": true,
"app": { "uptime": 42, "status": "running" },
"database": { "ok": true, "latency": "2ms" },
"prisma": { "ok": true, "latency": "1ms", "organizationExists": true },
"storage": { "root": "/app/storage", "exists": true, "writable": true, "uploads": true, "backups": true },
"environment": "production"
}The health check validates:
- Database connectivity (
SELECT 1) - Prisma ORM initialization
- Storage root exists and is writable
- Required subdirectories exist (uploads, backups)
The Docker HEALTHCHECK polls this endpoint every 30 seconds.
WBOS uses PostgreSQL 17. The schema is managed through Prisma migrations:
# Apply migrations
npx prisma migrate deploy
# Seed demo data (optional)
node prisma/seed.mjsThe Docker entrypoint runs npx prisma migrate deploy automatically before starting the Next.js server.
- Node.js 22+
- PostgreSQL 17 (local or Docker)
- pnpm (recommended) or npm
# 1. Clone the repository
git clone <repo-url>
cd wbos
# 2. Install dependencies
pnpm install
# 3. Copy environment variables
cp .env.example .env
# Edit .env with your database credentials
# 4. Run database migrations
npx prisma migrate deploy
# 5. Seed demo data (optional)
node prisma/seed.mjs
# 6. Start the dev server
pnpm devVisit http://localhost:3000.
pnpm dev # Start development server
pnpm build # Production build
pnpm test # Run tests (Vitest)
pnpm lint # Run linter (ESLint / Biome)
npx prisma studio # Database GUI (port 5555)docs/
├── adr/ # Architecture Decision Records
├── accounting-principles.md
├── alpha-test-checklist.md
├── architecture.md
├── business-rules.md
├── coding-standards.md
├── database.md
├── deployment.md
├── development-setup.md
├── domain-model.md
├── glossary.md
├── inventory-architecture.md
├── landed-costs-architecture.md
├── phase-3-progress.md
├── progress.md
├── roadmap.md
├── ui-guidelines.md
└── workflows.md
src/
├── app/ # Next.js App Router pages + API routes
│ ├── api/ # Route handlers (uploads, backups, /api/v1 for mobile)
│ ├── audit/
│ ├── categories/
│ ├── credit-notes/
│ ├── customers/
│ ├── health/
│ ├── inventory/
│ ├── invoices/
│ ├── onboarding/
│ ├── payments/
│ ├── products/
│ ├── purchasing/
│ ├── quotations/
│ ├── reports/
│ ├── returns/
│ ├── sales/
│ ├── settings/
│ ├── sign-in/
│ ├── sign-up/
│ ├── suppliers/
│ ├── tasks/
│ ├── units/
│ └── warehouses/
├── components/ # Shared React components
│ ├── ui/ # shadcn/ui primitives
│ ├── sidebar.tsx
│ ├── app-shell.tsx
│ └── ...
├── domains/ # Business domains (DDD)
│ ├── activity/
│ ├── attachments/
│ ├── backups/
│ ├── categories/
│ ├── credit-notes/
│ ├── customers/
│ ├── documents/
│ ├── import-shipments/
│ ├── inventory/
│ ├── notifications/
│ ├── organization/
│ ├── products/
│ ├── purchasing/
│ ├── quotations/
│ ├── reports/
│ ├── returns/
│ ├── sales/
│ ├── settings/
│ ├── supplier-invoices/
│ ├── suppliers/
│ ├── tasks/
│ ├── units/
│ └── warehouses/
├── infrastructure/ # Framework concerns (auth, DB, storage, notifications, request context)
├── shared/ # Shared utilities & errors
├── test/ # Vitest tests
└── lib/ # General utilities
Status: Production-ready for single-organization deployments.
Completed modules:
- ✅ Authentication & authorization (Better Auth, RBAC: Owner/Admin/Manager/Staff)
- ✅ Organization onboarding & multi-tenancy
- ✅ Master data: products, customers, suppliers, warehouses, categories, units of measure
- ✅ Inventory management: stock ledger, transfers, adjustments, cycle counts, FIFO costing
- ✅ Purchasing: purchase orders, goods receipt, partial receiving, approval workflow
- ✅ Sales: sales orders, invoices, credit notes, customer statements
- ✅ Payments: payment allocation, outstanding balance tracking
- ✅ Reporting: dashboard analytics, sales/inventory/purchasing reports
- ✅ Operational dashboard with KPIs, charts, and activity feed
- ✅ Print-layout invoices with server-side PDF generation
- ✅ Responsive layout with mobile navigation
- ✅ Production polish: error boundaries, empty states, onboarding UX, favicon set
- ✅ Docker self-hosting with automated DB migrations
- ✅ Notifications: task & shipment lifecycle alerts (in-app + optional Firebase push)
- ✅ Backups: one-click backup, download, restore, and diagnostics
- ✅ Public REST API (
/api/v1) consumed by the mobile companion - ✅ WBOS Mobile companion app (React Native + Expo) with barcode scanning
Planned:
- AI purchasing assistant & demand forecasting
- Third-party integrations & plugin system
- Remaining mobile phases (delivery, inventory, offline sync)
WBOS is productivity software. The interface is designed to help users complete work quickly and confidently.
Design inspiration:
- Linear — clean, fast task management
- Stripe Dashboard — data density with clarity
- GitHub — familiar navigation patterns
- Vercel — modern, minimal admin UI
- Notion — flexible content organization
Focus areas:
- Clarity over visual effects
- Consistency across all modules
- Efficiency for frequent actions
- Keyboard shortcuts where they add value (Ctrl+B for sidebar toggle)
Most small and medium wholesale businesses begin with spreadsheets (or expensive, over-engineered ERPs). Over time, spreadsheets become difficult to maintain, audit, and scale.
WBOS exists to replace disconnected spreadsheets — and complex ERPs — with a single, reliable operating system that models how a wholesale business actually works. The software is built from real operational experience rather than hypothetical requirements.
Build the right software before building more software.
Before contributing, please read the documentation in docs/:
docs/coding-standards.md— code style, naming conventions, patternsdocs/architecture.md— architectural overview and decisionsdocs/domain-model.md— domain entities and relationshipsdocs/business-rules.md— core business logic rules
Every significant architectural decision should be documented through an Architecture Decision Record (ADR) in docs/adr/.
This project is currently private. Licensing terms will be determined if the project is released publicly.