Skip to content

Back Office (Merchant Management)

1. Document Control

PropertyValue
Package@nx-app/bo
Version0.0.1-0
TypeWeb Application (SPA)
RuntimeBrowser / Bun (dev)
DeploymentDocker / Nginx

2. Scope & Objectives

2.1. Scope

The Back Office (bo) is the merchant management interface for the BANA platform. It provides business owners, operators, and system administrators with tools to manage merchants, products, categories, inventory, invoices, finances, and employee operations through a web browser.

2.2. Objectives

  • Merchant Management: Full lifecycle management of merchants, organizers, and vendor relationships.
  • Comprehensive Operations: Products, categories, inventory, purchase orders, sale orders, invoices, and finance management.
  • Role-Based Access: Permission-controlled screens for different user roles.
  • Data Visualization: Reports for revenue, orders, and product performance.
  • Responsive Design: Desktop, tablet, and mobile browser support.

3. Technology Stack

3.1. Core Framework

TechnologyVersionPurpose
React^19.2.1UI Component Library
React DOM^19.2.1DOM Rendering
React Router^7.9.4Client-side Routing
TypeScript~6.0.2Type Safety
Vite^7.1.7Build Tool & Dev Server

3.2. State Management

TechnologyVersionPurpose
Redux Toolkit^2.9.1Global State Management
React Redux^9.2.0React-Redux Bindings
TanStack Query^5.90.5Server State & Caching
TanStack Table^8.21.3Data Table Management
ra-core^5.13.2Admin Framework Core

3.3. UI Components

TechnologyVersionPurpose
@nx-app/admin-ui-kitworkspace:*Shared UI Component Library
Radix UI^1.4.3Accessible Primitives
Tailwind CSS^4.1.16Utility-first Styling
Lucide React^0.552.0Icon Library
next-themes^0.4.6Theme Switching

3.4. Forms & Validation

TechnologyVersionPurpose
React Hook Form^7.66.0Form State Management
@hookform/resolvers^5.2.2Schema Validation Bridge
react-phone-number-input^3.4.14Phone Input
react-number-format^5.4.4Numeric Formatting
react-day-picker^9.13.2Date Picker

3.5. Utilities

TechnologyVersionPurpose
@dnd-kitVariousDrag-and-Drop (sortable)
xlsx^0.18.5Excel Import/Export
papaparse^5.5.3CSV Parsing
compressorjs^1.2.1Image Compression
dayjs^1.11.18Date Formatting
sonner^2.0.7Toast Notifications

4. Architecture

4.1. Application Bootstrap

The BO app extends AdminUiKitApplication via RaApplication:

typescript
class RaApplication extends AdminUiKitApplication {
  // Initializes 18+ API services:
  // Auth, Merchant, Product, Category, User, Employee,
  // SaleChannel, SaleOrder, Invoice, Inventory, Finance,
  // Payment, Transaction, Role, Device, Report, etc.
}

ApplicationContext wraps the app with:

  • CoreApplicationContext - Admin framework context
  • Redux Provider - Global state
  • ThemeProvider - Dark/light mode
  • TooltipProvider - Global tooltips

4.2. Configuration

ConfigSourceDefault
API Base URLVITE_BASE_URLhttp://localhost:3000/api
OAuth URLVITE_NX_OAUTH_BASE_URL-
App Namepackage.json@nx-app/bo

4.3. Data Layer

  • DefaultRestDataProvider for all API communication
  • DefaultAuthService for JWT authentication
  • TanStack Query for server state caching and invalidation
  • Redux for UI state (sidebar, filters, preferences)

5. Screen Modules

BO screens live under src/screens/ in two route tiers: root/organizer-level admin modules (auth/root/, 29 module directories) and a per-merchant workspace (auth/merchant/$merchant-id/). Each module typically exposes list / create / edit (or show) views. The module names below are the real source directory names; the path column reflects the route constant in src/constants/routes.ts.

5.1. Identity & Access

ModulePathDescription
organizer/organizerOrganizer (parent entity) management
merchant/merchantsMerchant profile management
user/userPlatform user accounts
merchant-user/merchant-userMerchant-scoped user accounts
role/roleRole management
permission/permissionPermission management
policy-definition/policy-definitionCasbin policy definitions

5.2. Catalog & Configuration

ModulePathDescription
categories-product/categories-productProduct category catalog
category-template/category-templateReusable category templates
unit-of-measure/unit-of-measureUnits of measure
tax-group/tax-groupTax group configuration
settings/settingsApp-wide settings

5.3. Subscription & Licensing

ModulePathDescription
subscription-plan/subscription-planSubscription plan catalog
license/licenseLicense records
activation/activationLicense activation records
onboarding/onboardingMerchant onboarding flow

5.4. Outreach

ModulePathDescription
outreach-inquiry/outreach-inquiryInbound outreach inquiries
outreach-subscriber/outreach-subscriberOutreach subscribers

5.5. Help Desk

ModulePathDescription
agent/agentHelp desk agents
agent-group/agent-groupAgent groups
assignment-rule/assignment-ruleTicket assignment rules
sla-policy/sla-policySLA policies
hd-ticket-category/hd-ticket-categoryTicket categories
hd-ticket-tag/hd-ticket-tagTicket tags

5.6. Inventory & Devices

ModulePathDescription
vendors/inventory-vendorsSupplier/vendor management
locations/inventory-locationsInventory locations
devices/deviceDevice registration

5.7. Home & Reports

ModulePathDescription
home/Dashboard home
report/reportRevenue and operations reports

5.8. Merchant Workspace

Scoped under /merchant/:merchantId/ and hydrated from the selected merchant (auth/merchant/$merchant-id/):

ModulePathDescription
sale/sale-order, /transaction, /sale-channelSale orders, transactions, sale channels
finance/finance-category, /finance-account, /finance-voucherFinance categories, accounts, vouchers
report/ledger, /revenue/by-day, /revenue/by-product, /revenue/by-categoryLedger and revenue reports
role/roleMerchant-scoped roles
setting-general/generalMerchant general settings
merchant/merchant/:merchantIdMerchant detail (create / edit)

5.9. Authentication

ModulePathDescription
sign-in/sign-inLogin screen (no-auth/)

6. Layout System

6.1. Main Layout

Authenticated layout with collapsible sidebar navigation (grouped by module), header with user profile, and content area.

6.2. Form Layout

BaseFormLayout provides standardized form pages with:

  • Filter bar - TextField, Status dropdown filters
  • Action buttons - Save, Cancel, custom actions
  • RouteContextProvider - Screen-level routing context

6.3. No-Auth Layout

Minimal layout for sign-in/sign-up screens without sidebar navigation.

7. Custom Hooks

7.1. API Hooks

HookPurpose
useGetDataFetch data with TanStack Query
useInfiniteGetDataInfinite scroll data fetching
useMutationDataCreate/Update/Delete mutations
useRefreshForce data refresh
useVirtualAutocompleteVirtualized autocomplete (single)
useVirtualAutocompleteArrayVirtualized autocomplete (multi)

7.2. State Hooks

HookPurpose
useAppDispatchTyped Redux dispatch
useAppSelectorTyped Redux selector
useUserPreferencesUser settings persistence
useUserProfileCurrent user profile data
useLogoutLogout flow
useWarnUnsavedChangesUnsaved changes warning

7.3. Table Hooks

HookPurpose
useDataTableControllerTable state + data fetching
useDataTableStateTable column/filter state
useBaseTableAutosaveAuto-save inline edits

8. Build & Deployment

8.1. Vite Configuration

  • Code splitting: Manual chunk for infra bundle
  • Chunk size warning: 600KB limit
  • PWA: Auto-update strategy, no manifest
  • Dev server: Port 3000, strict port, HMR enabled

8.2. Docker Build

Multi-stage build:

dockerfile
# Stage 1: Dependencies (bun:1-alpine)
# Stage 2: Build (bun run build:production)
# Stage 3: Production (nginx:1.27-alpine)

8.3. Nginx Configuration

FeatureSetting
CompressionGzip enabled (text, JS, CSS, JSON, SVG)
Security HeadersX-Frame-Options, X-Content-Type-Options, X-XSS-Protection
Asset Caching1 year (immutable)
Service Worker1 hour cache
SPA RoutingCatch-all redirect to index.html
Hidden FilesDenied (except .well-known)

8.4. Scripts

ScriptCommandPurpose
devvite --mode devDevelopment server
buildsh ./scripts/build.shProduction build
build:developsh ./scripts/rebuild.sh developmentDevelopment build
build:productionsh ./scripts/rebuild.sh productionProduction build
previewvite preview --port 4173Preview production build
lintsh ./scripts/lint.shESLint + Prettier

9. Differences from Client App

AspectClient (@nx-app/client)BO (@nx-app/bo)
PurposeAdmin dashboard (all platform management)Merchant-focused management
ScopeFull platform administrationMerchant operations
Modules10 merchant-workspace modules (POS operations) + onboarding/organizer flows29 root/organizer admin modules + 6 merchant-workspace modules
Additional Tools-Excel import/export, CSV parsing, image compression, drag-and-drop

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.