Inventory-Point-of-Sale-System

๐Ÿ›’ Inventory & Point-of-Sale System

A web-based Inventory and Point-of-Sale (POS) System designed for small shops to manage products, process sales, track inventory, and maintain transaction history.

The system provides a simple POS interface where users can browse products, search or scan barcodes, add items to a cart, complete purchases, and automatically update stock levels.


โœจ Features

๐Ÿ” Authentication

๐Ÿ›๏ธ Point of Sale

๐Ÿ“ฆ Inventory Management

๐Ÿ“Š Sales & History

๐Ÿ›ก๏ธ Data Protection


๐Ÿ› ๏ธ Technologies

Technology Purpose
HTML5 Application structure
CSS3 Responsive UI and layouts
JavaScript Cart logic, search, filtering, and API communication
PHP Backend logic and authentication
MySQL Database and data persistence
PDO Database connection and queries
XAMPP Local development environment

The project uses vanilla HTML, CSS, JavaScript, PHP, and MySQL without Bootstrap, Tailwind, or other frontend frameworks.


๐Ÿ“‚ Project Structure

inventory-pos/
โ”‚
โ”œโ”€โ”€ index.php
โ”œโ”€โ”€ login.php
โ”œโ”€โ”€ logout.php
โ”œโ”€โ”€ setup.php
โ”œโ”€โ”€ history.php
โ”œโ”€โ”€ sale_details.php
โ”œโ”€โ”€ database.sql
โ”‚
โ”œโ”€โ”€ admin/
โ”‚   โ”œโ”€โ”€ products.php
โ”‚   โ”œโ”€โ”€ add_product.php
โ”‚   โ”œโ”€โ”€ edit_product.php
โ”‚   โ””โ”€โ”€ delete_product.php
โ”‚
โ”œโ”€โ”€ api/
โ”‚   โ”œโ”€โ”€ get_products.php
โ”‚   โ”œโ”€โ”€ checkout.php
โ”‚   โ””โ”€โ”€ get_sale_details.php
โ”‚
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ db.php
โ”‚   โ””โ”€โ”€ auth.php
โ”‚
โ””โ”€โ”€ assets/
    โ”œโ”€โ”€ css/
    โ”‚   โ””โ”€โ”€ style.css
    โ”‚
    โ””โ”€โ”€ js/
        โ””โ”€โ”€ app.js

โš™๏ธ Installation

1. Install XAMPP

Install XAMPP with:

2. Clone or copy the project

Place the project inside the XAMPP htdocs directory:

C:\xampp\htdocs\inventory-pos

3. Start XAMPP

Open the XAMPP Control Panel and start:

Apache
MySQL

4. Create the database

Open phpMyAdmin:

http://localhost/phpmyadmin

Import:

database.sql

The SQL file creates the:

inventory_pos

database and the required tables.

5. Configure the database

Open:

config/db.php

The default XAMPP configuration uses:

$user = 'root';
$pass = '';

If your MySQL installation uses a password, update the configuration accordingly.

6. Run the setup

Open:

http://localhost/inventory-pos/setup.php

The setup script creates the administrator account.

7. Launch the application

Open:

http://localhost/inventory-pos/

You will be redirected to the login page if authentication is required.


๐Ÿ”‘ Default Login

After running the setup script:

Username: admin
Password: admin123

For a real deployment, change the default credentials and remove or protect the setup script.


๐Ÿ—„๏ธ Database Design

The system uses four main tables:

users

Stores application users and authentication information.

id
username
password
created_at

products

Stores inventory information.

id
name
category
barcode
price
stock
created_at

sales

Stores completed sales/invoices.

id
total
sale_date

sale_items

Stores the individual products included in each sale.

id
sale_id
product_id
product_name
quantity
price
subtotal

The database uses foreign keys to connect sales with their corresponding sale items.


๐Ÿ”„ Sales Workflow

The checkout process follows this general workflow:

Select Product
      โ†“
Add to Cart
      โ†“
Adjust Quantity
      โ†“
Calculate Total
      โ†“
Checkout
      โ†“
Create Sale
      โ†“
Create Sale Items
      โ†“
Reduce Inventory
      โ†“
Generate Invoice

The checkout operation uses a database transaction so that the sale, sale items, and stock updates are handled together.

If an operation fails, the transaction can be rolled back instead of leaving partially completed data.


๐Ÿ“ฑ Responsive Design

The interface is designed to work across:

CSS Grid, Flexbox, and media queries are used to adapt the layout to different screen sizes.


๐Ÿ“„ Main Pages

Page Purpose
login.php User login
setup.php Initial administrator setup
index.php Main POS interface
admin/products.php Inventory management
admin/add_product.php Add product
admin/edit_product.php Edit product
admin/delete_product.php Delete product
history.php Sales history
sale_details.php Individual invoice
logout.php Logout

๐Ÿ”Œ API Endpoints

The frontend communicates with PHP endpoints using JavaScript fetch() requests.

Get Products

api/get_products.php

Returns available products as JSON.

Checkout

api/checkout.php

Processes the current cart and creates the sale.

Sale Details

api/get_sale_details.php

Returns information about a specific completed sale.


๐Ÿงช Sample Data

The database includes sample products such as:

Products are organized into categories such as:

Dairy
Bakery
Grocery
Beverages
Snacks

A low-stock product is included so the inventory warning functionality can be tested.


๐ŸŽฏ Project Objectives

This project demonstrates practical experience with:


๐Ÿšง Future Improvements

Possible improvements include:


๐Ÿ‘จโ€๐Ÿ’ป Author

Ziad Sayed Ahmed (Zico)

๐Ÿ“ง z.hamzawyyy@gmail.com


๐Ÿ“Œ Disclaimer

This project was developed as a Web Programming course project and is intended primarily for educational and portfolio purposes.

For production use, additional security hardening, deployment configuration, user management, and validation would be recommended.