Multi-branch sales management software (REST API - Backend)
A RESTful backend platform for managing sales, inventory, and operations across multiple branches, with secure authentication, offline synchronization, and centralized reporting.
🚀 Project Overview
In the modern business landscape, effectively managing sales activities across multiple branches is a critical challenge. The Multi-Branch POS API is a robust RESTful backend platform designed to address this necessity by optimizing transaction processes and enhancing operational performance. The system acts as the central hub that provides flexible access and seamlessly synchronizes data between distributed branches and the central server. The ultimate goal of this solution is to improve service quality, streamline inventory and sales tracking, and drive increased revenue for multi-branch organizations.
🌟 Core Features
Multi-Branch Management: Manage the branches of the store chain, including contact information and geographic locations.
Product & SKU Management: Maintain a centralized product catalog with unique identifiers (SKUs), product descriptions, and pricing configurations.
Branch-Specific Inventory: Automatically track the inventory quantity of each product at every branch.
Authentication & Authorization (JWT Authentication):
Secure login using JSON Web Tokens (JWT) and password hashing with bcryptjs.
Role-based access control: Admin (full system administrator privileges) and Staff (operational staff with data access restricted to their assigned branch).
Offline Synchronization Engine:
Provide dedicated APIs that allow offline Desktop sales clients to upload temporarily stored retail invoices to the central server as soon as connectivity is restored.
Ensure data integrity, resolve invoice ID conflicts, and automatically adjust the branch's actual inventory quantities after successful synchronization.
Strict Data Validation: Use express-validator to enforce data types, formats, and validity for all inputs before processing, helping keep the system stable and secure.
Advanced Logging System: Integrate winston and morgan to automatically track system operations and HTTP requests, while recording errors promptly in separate log files.
Reporting & Analytics (Admin Analytics Dashboard): Aggregate revenue over time, rank branch sales performance, monitor low-stock items, and display the latest transactions.
Automatic API Documentation (Swagger Integration): Integrate Swagger UI so developers can browse and test all API endpoints directly at /api-docs.
🛠️ Technology Stack
Runtime: Node.js (Requires version >= 22.0.0)
Framework: Express.js (v5.x with modern routing capabilities)
Database ORM: Sequelize v6 (Uses the sqlite3 driver as the default database and can be extended to PostgreSQL, MySQL, or MS SQL Server by reconfiguring the connection).
Security & Validation: bcryptjs for password hashing, jsonwebtoken for issuing Bearer Tokens, and express-validator for input validation.
API Documentation: swagger-jsdoc & swagger-ui-express for writing API documentation directly in the code according to the OpenAPI 3.0 standard.
Logs & Development: winston combined with morgan provides a robust logging system with daily log files; nodemon enables instant server reloads when the code changes.
📖 API Documentation (Swagger UI)
🌍 Live Environment: Demo here
Here you can find the complete list of APIs organized by category:
Auth (/api/auth): POST /login, POST /register, GET /me...
Branches (/api/branches): CRUD operations for store branches.
Products (/api/products): View and create products in the system.
Inventories (/api/inventories): Update the inventory of each product at a branch.
Customers (/api/customers): Manage customer directory information.
Orders (/api/orders): Create orders directly or query invoice history.
Sync (/api/sync):
POST /api/sync/orders: Upload batches of temporarily stored orders from offline clients to the cloud.
GET /api/sync/pending: View orders pending synchronization on the Express Server.
PUT /api/sync/status: Update invoice statuses after reconciliation is completed.
Dashboard (/api/dashboard): Retrieve analytics data for admin dashboards (branch sales and revenue overview).