A full-stack Point of Sale (POS) system built with React (Vite) frontend and Node.js/Express backend with PostgreSQL database. Features include inventory management, sales tracking, customer loyalty, expense tracking, and comprehensive reporting with PDF/Excel exports.
- Node.js 18+ and npm
- PostgreSQL 13+
- Docker Desktop (optional, for containerized deployment)
- Clone the repository
git clone <your-repo-url>
cd Heaven_Bakers- Backend setup
cd backend
npm installCreate a .env file in backend:
PORT=5000
DATABASE_URL=postgres://postgres:postgres@localhost:5432/Heaven_Bakers
JWT_SECRET=your-secret-key-here
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin123Start the backend:
npm startBackend runs at http://localhost:5000
- Frontend setup
cd frontend
npm install
npm run devFrontend runs at http://localhost:5173
- Login
- Username:
admin - Password:
admin123
For production deployment with Docker and Nginx reverse proxy, see QUICK_START_GUIDE.md for detailed instructions.
Quick Docker start:
docker compose up -dAccess at http://localhost:8080 (or configured domain)
Heaven_bakers/
βββ backend/ # Node.js/Express API
β βββ src/
β β βββ routes/ # API endpoints
β β βββ middleware/ # Auth & error handling
β β βββ services/ # Business logic
β β βββ database.sql # Database schema
β β βββ db.ts # Database connection
β βββ index.ts # Server entry point
β βββ Dockerfile # Backend container config
β
βββ frontend/ # React/Vite application
β βββ src/
β β βββ pages/ # Application pages
β β βββ components/ # Reusable components
β β βββ services/ # API client & utilities
β βββ nginx.conf # Production nginx config
β βββ Dockerfile # Frontend container config
β
βββ docker-compose.yml # Multi-container orchestration
βββ scripts/ # Utility scripts
βββ sql/ # SQL migrations and queries
βββ docs/ # Documentation
See [docs/PROJECT_STRUCTURE.md](docs/PROJECT_STRUCTURE.md) for complete directory structure.
- Sales Management - Process sales, generate invoices, receipt printing
- Inventory Control - Track stock levels, low stock alerts, product management
- Purchase Orders - Manage vendor purchases and stock replenishment
- Customer Loyalty - Points system, customer tracking
- Expense Tracking - Record and categorize business expenses
- Vendor Management - Maintain vendor information and purchase history
- User Management - Role-based access control (Admin/Cashier)
- Sales Reports - Daily, product-wise, invoice-level analysis
- Inventory Reports - Stock levels, movement tracking
- Purchase Reports - Vendor analysis, purchase history
- Export Options - Excel and PDF exports for all reports
- Detailed PDF Reports - Narrative reports with breakdowns and summaries
- WhatsApp Integration - Receipt delivery via WhatsApp
- Barcode Support - Product scanning and barcode generation
- Error Logging - Comprehensive error tracking and monitoring
- Receipt Printing - Thermal printer support (XP-80C)
- Real-time Updates - Live inventory and sales tracking
- Responsive Design - Works on desktop and tablet devices
Backend (.env)
PORT=5000
DATABASE_URL=postgres://user:password@host:port/database
JWT_SECRET=your-secret-key
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin123
WHATSAPP_ENABLED=trueDocker Deployment (.env.docker)
POSTGRES_USER=heaven_user
POSTGRES_PASSWORD=heaven_password
POSTGRES_DB=Heaven_Bakers
JWT_SECRET=your-production-secretThe database schema is automatically created on first startup. Tables include:
- users (authentication)
- products (inventory items)
- customers (loyalty program)
- vendors (suppliers)
- sales_invoices & sales_items
- purchases & purchase_items
- expenses
- loyalty_transactions
- error_logs
See backend/src/database.sql for complete schema.
POST /api/auth/login- User loginPOST /api/auth/register- Create new userGET /api/auth/me- Get current user
GET /api/sales- List all salesPOST /api/sales- Create new saleGET /api/sales/:id- Get sale detailsGET /api/sales/invoice/:id- Get invoice
GET /api/inventory- List productsPOST /api/inventory- Add productPUT /api/inventory/:id- Update productDELETE /api/inventory/:id- Delete product
GET /api/sales/report- Sales report with filtersGET /api/inventory/report- Inventory reportGET /api/purchases/report- Purchase report
For complete API documentation, see individual route files in backend/src/routes/
# Backend tests
cd backend
npm test
# Frontend tests
cd frontend
npm test# Backend
cd backend
npm run build
# Frontend
cd frontend
npm run buildBackend Routes:
auth.ts- Authentication endpointssales.ts- Sales and invoicesinventory.ts- Product managementpurchases.ts- Purchase ordersexpenses.ts- Expense trackingcustomers.ts- Customer managementvendors.ts- Vendor managementloyalty.ts- Loyalty programbarcode.ts- Barcode operationsprint.ts- Receipt printingwhatsapp.ts- WhatsApp integrationlogs.ts- Error log retrieval
Frontend Pages:
- Dashboard - Overview and quick stats
- Sales - Process new sales
- Inventory - Manage products
- Purchase - Create purchase orders
- Expenses - Track expenses
- Loyalty - Customer loyalty management
- Vendors - Vendor information
- Reports - Analytics and exports
- Settings - User management
- JWT-based authentication
- Password hashing with bcrypt
- Role-based access control (RBAC)
- SQL injection protection via parameterized queries
- CORS configuration for API security
- Environment variable protection
- Session management
See docs/RBAC_DOCUMENTATION.md for detailed role permissions.
The application includes comprehensive error logging:
- Frontend error boundary
- Backend error middleware
- Database error logging
- API endpoint:
GET /api/logs(Admin only)
The application is fully containerized with:
- Backend service (Node.js)
- Frontend service (Nginx + static files)
- PostgreSQL database
- Persistent volumes for data
See docs/QUICK_START_GUIDE.md for complete Docker and Nginx setup instructions.
# Local
pg_dump -U postgres Heaven_Bakers > backup.sql
# Docker
docker compose exec postgres pg_dump -U heaven_user Heaven_Bakers > backup.sql# Local
psql -U postgres Heaven_Bakers < backup.sql
# Docker
docker compose exec -T postgres psql -U heaven_user -d Heaven_Bakers < backup.sqlDatabase Connection Failed
- Verify PostgreSQL is running
- Check DATABASE_URL in .env
- Ensure database exists (auto-created on first run)
Port Already in Use
- Backend (5000): Check for other Node processes
- Frontend (5173): Check for other Vite servers
- Docker (8080): Check for other containers
Login Issues
- Restart backend to re-run admin seeding
- Check database users table for admin entry
- Verify JWT_SECRET is set
Export/Print Issues
- Ensure user is logged in
- Check browser console for errors
- Verify API endpoints are accessible
# Docker logs
docker compose logs -f backend
docker compose logs -f frontend
# Application logs
# Access via frontend: Settings > Error Logs (Admin only)- docs/PROJECT_STRUCTURE.md - Complete directory structure
- docs/QUICK_START_GUIDE.md - Docker/Nginx setup
- docs/DOCKER.md - Docker deployment details
- docs/NGINX_WINDOWS_SETUP.md - Nginx configuration guide
- docs/RBAC_DOCUMENTATION.md - Role-based access control
- docs/BARCODE_SCANNING_GUIDE.md - Barcode implementation
- docs/WHATSAPP_INTEGRATION_GUIDE.md - WhatsApp setup
- docs/CONFIGURE_LOCAL_POSTGRES.md - Database setup
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is proprietary software. All rights reserved.
For issues and questions:
- Check existing documentation
- Review error logs via the application
- Consult troubleshooting section above
Version: 1.0.0
Last Updated: November 2024