High-level architecture
The BMS POS system is built as a modern desktop application using a client-server architecture:Frontend architecture
Technology stack
| Component | Technology | Version | Purpose |
|---|---|---|---|
| Framework | React | 19.1.1 | UI component library |
| Language | TypeScript | 5.9.2 | Type-safe development |
| Build Tool | Vite | 7.1.4 | Fast bundling and HMR |
| Styling | Tailwind CSS | 4.1.12 | Utility-first CSS |
| Desktop | Electron | 37.3.0 | Native desktop wrapper |
| Routing | React Router | 7.2.0 | Client-side navigation |
| UI Components | shadcn/ui | - | Accessible component system |
Component structure
The frontend is organized into feature-based components:src/frontend/)
Key frontend features
Real-time barcode scanning
Real-time barcode scanning
The POS component includes a sophisticated barcode scanner detection system:(src:
src/frontend/components/POS.tsx:182-218)Session management
Session management
Secure session handling with automatic expiration:
- Sessions stored in
sessionStorage(cleared on window close) - Automatic logout after inactivity
- Business action extends session (e.g., completing a sale)
- Session guards protect routes requiring authentication
src/frontend/utils/SessionManager.ts)Touch-optimized UI
Touch-optimized UI
Designed for touchscreen POS terminals:
- Large tap targets (minimum 44x44px)
- On-screen keyboard for PIN/text entry
- Modal keyboards with numeric, decimal, and QWERTY layouts
- Gesture-friendly card-based interface
- Responsive grid layouts for product catalogs
src/frontend/components/ModalKeyboard.tsx, src/frontend/components/HybridInput.tsx)Inventory validation
Inventory validation
Real-time stock checking prevents overselling:(src:
src/frontend/components/POS.tsx:308-337)Backend architecture
Technology stack
| Component | Technology | Version | Purpose |
|---|---|---|---|
| Framework | ASP.NET Core | 8.0 | Web API framework |
| ORM | Entity Framework Core | 9.0.12 | Database abstraction |
| Database Driver | Npgsql | 9.0.4 | PostgreSQL .NET driver |
| Authentication | BCrypt.Net | 0.1.0 | PIN hashing |
| Logging | Serilog | 9.0.1 | Structured logging |
| Documentation | Swashbuckle | 7.3.0 | Swagger/OpenAPI |
API structure
BMS_POS_API/)
Core API endpoints
Authentication flow
The authentication system supports both legacy plaintext PINs and modern hashed PINs with automatic upgrades:BMS_POS_API/Controllers/AuthController.cs:190-211)
Sales transaction processing
Sales are processed atomically with automatic inventory updates:
(src:
BMS_POS_API/Controllers/SalesController.cs:64-160)
Database architecture
Entity Relationship Diagram
Database tables
The system uses 14 PostgreSQL tables with snake_case naming:employees - User accounts
employees - User accounts
0001 / 1234 (Manager)products - Product catalog
products - Product catalog
sales - Transaction headers
sales - Transaction headers
sale_items - Transaction line items
sale_items - Transaction line items
returns - Return transactions
returns - Return transactions
user_activities - Audit trail
user_activities - Audit trail
stock_adjustments - Inventory changes
stock_adjustments - Inventory changes
system_settings - Configuration
system_settings - Configuration
BMS_POS_API/Data/BmsPosDbContext.cs)
Database connection
The system connects to PostgreSQL via Supabase using Npgsql:.env):
BMS_POS_API/Program.cs, .env.example)
Electron integration
Main process architecture
The Electron main process handles:- Window management - Multi-display support, kiosk mode
- Printing - Direct thermal printer integration via escpos
- Hardware access - Barcode scanners, receipt printers, cash drawers
- IPC communication - Bridge between renderer and Node.js APIs
- API configuration - Runtime API URL configuration
src/electron/main.js)
Multi-display support
The system intelligently selects the target display:src/electron/main.js:63-106, package.json)
IPC endpoints
Electron exposes Node.js APIs to the renderer via IPC:src/electron/preload.js)
Security architecture
PIN security
- Hashing algorithm: BCrypt with auto-generated salt
- Legacy support: Automatic upgrade from plaintext to hashed PINs
- Background upgrade: Non-blocking PIN hash migration
- Minimum length: 4 digits (configurable)
BMS_POS_API/Services/PinSecurityService.cs)
Activity logging
All user actions are logged to theuser_activities table:
- Login/logout events
- Sale transactions
- Inventory modifications
- Settings changes
- Failed authentication attempts
- Employee ID and name
- Action type and details
- Entity type and ID (product, sale, etc.)
- IP address
- Timestamp (UTC)
BMS_POS_API/Services/UserActivityService.cs)
Session security
- Sessions stored in
sessionStorage(cleared on window close) - Automatic expiration after configurable inactivity period
- No persistent tokens (requires re-login)
- Session validation on protected routes
Performance optimizations
Fast product search
- In-memory filtering of active products
- Debounced search input (300ms)
- Indexed barcode lookups in PostgreSQL
- Client-side product caching
Optimized database queries
- EF Core query optimization
- Eager loading with
.Include() - Indexed foreign keys
- Date-based query filtering
React performance
React.memofor expensive componentsuseMemofor filtered/sorted lists- Virtual scrolling for large datasets
- Lazy route-based code splitting
Vite build optimization
- Tree-shaking unused code
- Code splitting by route
- Minification and compression
- Hot Module Replacement (HMR)
Deployment architecture
Development environment
Production build
System requirements
- OS: Windows 10/11, macOS 11+, or Linux (Ubuntu 20.04+)
- CPU: Dual-core 2.0 GHz or better
- RAM: 4 GB minimum (8 GB recommended)
- Disk: 500 MB for application + database size
- Display: 1024x768 minimum (1920x1080 recommended for POS terminals)
- Network: Required for PostgreSQL connection
- Peripherals (optional):
- USB barcode scanner (HID keyboard mode)
- Thermal receipt printer (ESC/POS compatible)
- Cash drawer (connected via printer)
Next steps
API reference
Detailed documentation of all REST API endpoints
Configuration
Configure system settings, taxes, and payment methods
Database schema
Complete database schema with all tables and relationships
Development
Development guide and project structure