Skip to content

Latest commit

 

History

History
292 lines (203 loc) · 8.65 KB

File metadata and controls

292 lines (203 loc) · 8.65 KB

LAN Access Setup - Complete! ✅

What Has Been Configured

Your POS system is now ready for LAN access from any device on your network!

Changes Made:

  1. Backend Server (Node.js)

    • Configured to listen on 0.0.0.0 (all network interfaces)
    • Port: 3001
    • File: server/index.js
  2. Frontend (Angular)

    • Configured with --host 0.0.0.0 --disable-host-check flags
    • Port: 4200
    • File: package.json (start script)
  3. Environment Configuration

    • Updated API URLs to use LAN IP: 192.168.160.1
    • File: src/environments/environment.ts
  4. Search Input Auto-Focus

    • Focuses on component load
    • Focuses after switching sale tabs
    • Focuses after adding products to cart
    • File: src/app/components/pos/pos.component.ts

Quick Start Guide

Option 1: Automated Start (Recommended)

Run the quick start script:

cd c:\Users\IRWIN\Documents\pdev
.\start-pos.ps1

This will:

  • Check and start MongoDB if needed
  • Start both backend and frontend servers
  • Display access URLs

Option 2: Manual Start

Terminal 1 - Backend:

cd c:\Users\IRWIN\Documents\pdev\server
node index.js

Terminal 2 - Frontend:

cd c:\Users\IRWIN\Documents\pdev
npm start

Firewall Configuration

Required for LAN Access

Run this script as Administrator (one-time setup):

cd c:\Users\IRWIN\Documents\pdev
.\setup-firewall.ps1

Or manually configure in Windows Defender Firewall:

  • Allow TCP Port 3001 (Backend)
  • Allow TCP Port 4200 (Frontend)

Access URLs

Your Network IP: 192.168.160.1

Service Local URL LAN URL
Frontend http://localhost:4200 http://192.168.160.1:4200
Backend API http://localhost:3001/api http://192.168.160.1:3001/api
Product Images http://localhost:3001/product_images http://192.168.160.1:3001/product_images

Testing from Other Devices

Step-by-Step:

  1. Ensure both servers are running on your main PC
  2. Connect your device (phone/tablet/laptop) to the same WiFi network
  3. Open a web browser on the device
  4. Navigate to: http://192.168.160.1:4200
  5. You should see the POS login screen

Troubleshooting:

Can't access from other devices?

  • ✅ Check firewall rules (run setup-firewall.ps1 as admin)
  • ✅ Verify both devices are on the same network
  • ✅ Ping the server: ping 192.168.160.1
  • ✅ Check if servers are running: netstat -ano | findstr "3001 4200"

IP address changed?

  • Run: ipconfig | findstr IPv4
  • Update src/environments/environment.ts with new IP

Auto-Focus Search Bar

The search bar now automatically receives focus in these scenarios:

  1. On Initial Load - Ready for barcode scanning immediately
  2. After Tab Switch - When switching between sale tabs
  3. After Product Add - After adding a product to the cart

This ensures seamless barcode scanning workflow!


Network Diagram

┌─────────────────────────────────────────────────┐
│      Your WiFi Network (192.168.160.x)          │
│                                                  │
│  ┌────────────────────────────────────────────┐ │
│  │  Main PC (192.168.160.1)                   │ │
│  │                                            │ │
│  │  ┌──────────────┐    ┌──────────────┐    │ │
│  │  │  Node.js     │    │  Angular     │    │ │
│  │  │  :3001       │◄───┤  :4200       │    │ │
│  │  │  (Backend)   │    │  (Frontend)  │    │ │
│  │  └──────────────┘    └──────────────┘    │ │
│  │         ▲                    ▲            │ │
│  │         │                    │            │ │
│  │         └────────┬───────────┘            │ │
│  └──────────────────┼─────────────────────────┘ │
│                     │                            │
│     ┌───────────────┼───────────────┐            │
│     │               │               │            │
│  ┌──▼────┐    ┌─────▼────┐    ┌────▼───┐       │
│  │ Tablet│    │  Phone   │    │ Laptop │       │
│  │  POS  │    │   POS    │    │  POS   │       │
│  └───────┘    └──────────┘    └────────┘       │
│                                                  │
│  All access via: http://192.168.160.1:4200      │
└─────────────────────────────────────────────────┘

Use Cases

Multi-Device POS Setup

  • Main Counter: Desktop PC running the backend
  • Checkout 1: Tablet accessing via LAN
  • Checkout 2: Another tablet/phone via LAN
  • Mobile Sales: Phone with Bluetooth barcode scanner

Benefits:

  • ✅ Multiple cashiers can operate simultaneously
  • ✅ All data syncs through MongoDB on the main PC
  • ✅ Tablets/phones don't need to run the backend
  • ✅ Barcode scanners work seamlessly with auto-focus
  • ✅ Real-time inventory updates across all devices

Important Files

File Purpose
LAN_ACCESS.md Detailed LAN configuration guide
setup-firewall.ps1 Firewall configuration script (run as admin)
start-pos.ps1 Quick start script for both servers
src/environments/environment.ts API and image URL configuration
server/index.js Backend server with LAN binding
package.json Frontend start command with LAN flags

Security Notes

Current Setup (Development)

  • ✅ Perfect for local network testing
  • ✅ No authentication on network level
  • ✅ Uses --disable-host-check for any hostname access

For Production Deployment

When going live with customers:

  • 🔒 Enable HTTPS/SSL
  • 🔒 Add user authentication
  • 🔒 Configure proper CORS policies
  • 🔒 Remove --disable-host-check
  • 🔒 Use environment-specific builds
  • 🔒 Set up reverse proxy (nginx)
  • 🔒 Implement rate limiting
  • 🔒 Add network segmentation

Next Steps

Immediate:

  1. ✅ Run setup-firewall.ps1 as Administrator
  2. ✅ Run start-pos.ps1 to start both servers
  3. ✅ Test access from another device
  4. ✅ Set up tablets/phones for POS operation

Future Development:

  • ⬜ Product management interface
  • ⬜ User management system
  • ⬜ Receipt printing templates
  • ⬜ Reports and analytics
  • ⬜ Discount management
  • ⬜ Digital scale integration
  • ⬜ Customer display screen
  • ⬜ End-of-day cash reconciliation

Support

Check System Status

Verify servers are running:

# Check backend
curl http://192.168.160.1:3001/api/health

# Check frontend (should return HTML)
curl http://192.168.160.1:4200

Check port bindings:

netstat -ano | findstr "3001 4200"

Get Current IP

(Get-NetIPAddress -AddressFamily IPv4 | Where-Object {
    $_.InterfaceAlias -notlike "*Loopback*" -and
    $_.IPAddress -notlike "169.254.*"
} | Select-Object -First 1).IPAddress

Success Indicators

You'll know everything is working when:

✅ Backend logs show: LAN: http://192.168.160.1:3001 ✅ Frontend shows: Angular Live Development Server is listening on 0.0.0.0:4200 ✅ You can access the POS from another device's browser ✅ Search bar is automatically focused and ready for input ✅ Product images load correctly from all devices ✅ Barcode scanning works seamlessly


Your POS system is now ready for multi-device operation! 🎉

Test it from your phone or tablet to verify LAN access is working correctly.