Skip to content

Point of Sale (POS) Simulator - implementing core retail transaction workflows using team-based agile practices.

Notifications You must be signed in to change notification settings

bugsNburgers/POS-Point-Of-Sales-Simulator

Repository files navigation

POS Simulator

A comprehensive Point of Sale (POS) System implementing core retail transaction workflows with a focus on robust inventory management, payment processing, and audit compliance.

🎯 Overview

The POS Simulator is a full-featured retail management system built with Python and Streamlit. It provides cashiers and managers with tools to process transactions, manage inventory, handle returns, and maintain comprehensive audit logs.

Key Features

  • πŸ›’ Shopping Cart Management - Add/remove items, apply discounts, calculate taxes
  • πŸ’³ Payment Processing - Support for cash and card payments with change calculation
  • 🧾 Receipt Generation - PDF receipt generation with detailed transaction info
  • πŸ“¦ Inventory Management - Real-time stock tracking with low-stock alerts
  • πŸ“Š Sales Reporting - Daily sales summaries and transaction analytics
  • πŸ”„ Returns & Exchanges - Process product returns and exchanges
  • πŸ‘₯ Role-Based Access Control - Manager, Cashier, and Auditor roles
  • πŸ“œ Audit Logging - Comprehensive activity logging for compliance
  • πŸ“₯ Bulk Import - Import products from CSV/JSON files
  • πŸ’° Approval Workflows - Manager approval for high-value discounts and voids

πŸ› οΈ Tech Stack

  • Backend: Python
  • Frontend: Streamlit
  • Database: MySQL
  • PDF Generation: xhtml2pdf, ReportLab
  • ORM: SQLAlchemy

πŸ“‹ Requirements

  • Python 3.8+
  • MySQL 8.0+
  • Dependencies listed in requirements.txt

πŸš€ Installation

1. Clone the Repository

git clone https://github.com/bugsNburgers/POS_self.git
cd POS_self

2. Install Dependencies

pip install -r requirements.txt

3. Environment Configuration

Create a .env file in the project root:

MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=1234
MYSQL_DB=pos_db

4. Database Setup

Ensure MySQL is running and create the database schema (consult your database setup documentation).

5. Run the Application

streamlit run app.py

The application will be available at http://localhost:8501

πŸ“ Project Structure

POS_self/
β”œβ”€β”€ app. py                          # Main Streamlit application
β”œβ”€β”€ requirements. txt                # Python dependencies
β”œβ”€β”€ . env                           # Environment variables (create locally)
β”œβ”€β”€ pytest.ini                     # Pytest configuration
β”œβ”€β”€ . pylintrc                      # Pylint configuration
β”‚
β”œβ”€β”€ services/                      # Business logic layer
β”‚   β”œβ”€β”€ __init__.py               # Service exports
β”‚   β”œβ”€β”€ db. py                     # Database connection pooling
β”‚   β”œβ”€β”€ auth_service.py           # User authentication & authorization
β”‚   β”œβ”€β”€ cart_service.py           # Shopping cart logic
β”‚   β”œβ”€β”€ payment_service.py        # Payment processing
β”‚   β”œβ”€β”€ receipt_service.py        # Receipt generation
β”‚   β”œβ”€β”€ stock_service.py          # Inventory management
β”‚   β”œβ”€β”€ import_service.py         # CSV/JSON product import
β”‚   β”œβ”€β”€ return_service.py         # Return/exchange processing
β”‚   β”œβ”€β”€ approval_service.py       # Approval workflows
β”‚   β”œβ”€β”€ report_service.py         # Sales reporting
β”‚   β”œβ”€β”€ logs_service.py           # Activity log queries
β”‚   └── monitoring_service.py     # System monitoring
β”‚
β”œβ”€β”€ pages/                         # Streamlit pages (UI routes)
β”‚   β”œβ”€β”€ cart.py                   # Cart management page
β”‚   β”œβ”€β”€ payment.py                # Payment processing page
β”‚   β”œβ”€β”€ receipt.py                # Receipt display page
β”‚   β”œβ”€β”€ returns.py                # Return processing page
β”‚   β”œβ”€β”€ reports.py                # Sales reports page
β”‚   β”œβ”€β”€ stock.py                  # Stock management page
β”‚   β”œβ”€β”€ import_products.py        # Product import page
β”‚   β”œβ”€β”€ users.py                  # User management page
β”‚   β”œβ”€β”€ approvals.py              # Approval requests page
β”‚   β”œβ”€β”€ logs.py                   # Activity logs page
β”‚   └── monitoring. py             # System monitoring page
β”‚
β”œβ”€β”€ assets/                        # Static assets
β”‚   └── receipt_template.html     # Receipt PDF template
β”‚
β”œβ”€β”€ tests/                         # Unit and integration tests
β”‚   β”œβ”€β”€ test_auth.py              # Authentication tests
β”‚   β”œβ”€β”€ test_cart.py              # Cart logic tests
β”‚   β”œβ”€β”€ test_payment.py           # Payment processing tests
β”‚   β”œβ”€β”€ test_import.py            # Import functionality tests
β”‚   └── ... 
β”‚
β”œβ”€β”€ DB/                           # Database scripts & schemas
β”‚
β”œβ”€β”€ CART_README.md                # Cart feature documentation
β”œβ”€β”€ STOCK_IMPORT_README.md        # Import feature documentation
└── CICD pipeline. md              # CI/CD setup documentation

πŸ” User Roles & Permissions

Manager

  • Full system access
  • Approve/deny discount and void requests
  • User management
  • System monitoring
  • All reports and inventory features

Cashier

  • Process transactions
  • View cart and payment
  • Generate receipts
  • Process returns (with limitations)
  • View own activity logs
  • Discounts >10% require manager approval

Auditor

  • Read-only access to activity logs
  • Compliance reporting
  • No transaction permissions

πŸ—„οΈ Core Services

Database (services/db.py)

Connection pooling for MySQL with prepared statements and transaction support.

Authentication (services/auth_service.py)

User login, password verification, role-based access control, and audit logging.

Cart Management (services/cart_service.py)

  • Add items to cart
  • Quantity updates
  • Line-item discounts
  • GST calculation
  • Cart persistence

Payment Processing (services/payment_service.py)

  • Cash payment processing
  • Card payment integration
  • Change calculation
  • Stock decrement on payment

Receipt Generation (services/receipt_service.py)

  • PDF receipt generation using Jinja2 templates
  • Receipt storage in database
  • Receipt retrieval and display

Stock Management (services/stock_service.py)

  • Real-time inventory tracking
  • Low stock alerts
  • Stock adjustments
  • Stock history

Import Service (services/import_service.py)

  • CSV/JSON product import
  • Data validation
  • Batch insert with duplicate handling
  • Import audit logging

Approval Workflow (services/approval_service.py)

  • Manager approval requests
  • Discount approval tracking
  • Void transaction approvals

Activity Logging (services/logs_service.py)

  • Comprehensive audit trails
  • Log filtering and search
  • Export capabilities

πŸ§ͺ Testing

Run tests using pytest:

# Run all tests
pytest

# Run tests with coverage
pytest --cov=services tests/

# Run specific test file
pytest tests/test_cart. py -v

πŸ“ API Documentation

Refer to the individual module docstrings and the CART_README.md and STOCK_IMPORT_README.md files for detailed API documentation on specific features.

πŸ”„ Development Workflow

  1. Create feature branch from main
  2. Make changes and write tests
  3. Run pytest to ensure all tests pass
  4. Commit with conventional commit messages
  5. Push and create pull request for review

πŸ“Š Performance Considerations

  • Database connection pooling (5 connection pool size)
  • Decimal precision for financial calculations
  • Indexed queries for receipt and transaction lookups
  • Batch operations for bulk imports

🚨 Error Handling

  • User-friendly error messages in Streamlit UI
  • Detailed logging of system errors
  • Transaction rollback on failures
  • Validation of all user inputs

πŸ“„ License

Developed for retail point-of-sale operations.


For more detailed information on specific features:

  • Cart Operations: See CART_README.md
  • Product Imports: See STOCK_IMPORT_README.md
  • CI/CD Pipeline: See CICD pipeline.md

About

Point of Sale (POS) Simulator - implementing core retail transaction workflows using team-based agile practices.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5