-
Technologies:
- Java EE (Servlets)
- MySQL
- Jakarta JSON-B
- Logback (Logging)
- Apache Tomcat
-
Project Purpose: The POS system allows small to medium-sized businesses to manage their sales operations effectively, including customer management, inventory control, and order processing.
Ensure you have the following installed:
- JDK 11 or higher
- Apache Tomcat 9.x or higher
- MySQL Server
- Git (for cloning the repository)
-
Clone the Project Repository:
git clone(https://github.com/ruwibdilshani/Pos-System-Backend.git)
-
Set Up MySQL Database:
- Create a new database in MySQL:
CREATE DATABASE simple_pos;
- Import the database schema:
mysql -u [username] -p pos_system < db_schema.sql
- Create a new database in MySQL:
-
Deploy the Application:
- Package the project into a WAR file.
- Deploy the WAR file to the Tomcat server.
The system provides RESTful APIs for managing customers, items, and orders. Below is an overview of the available endpoints:
-
Add Customer (POST /customer):
- Request:
{ "id": "C001", "name": "Ruwi", "address": "Galle", "salary": 5000 }
- Response:
201 Created
- Request:
-
Retrieve Customers (GET /customer):
- Parameters:
type=one&id=C001
: Fetch a single customer by ID.type=all
: Fetch all customers.
- Response:
200 OK
- Parameters:
-
Update Customer (PUT /customer?id={customerId}):
- Request:
{ "name": "Ruwi", "address": "Galle", "salary": 6000 }
- Response:
200 OK
- Request:
-
Delete Customer (DELETE /customer?id={customerId}):
- Response:
204 No Content
- Response:
-
Add Item (POST /item):
- Request:
{ "code": "I001", "itemName": "Rice", "qty": 10, "unitPrice": 1500 }
- Response:
201 Created
- Request:
-
Retrieve Items (GET /item):
- Parameters:
type=one&itemCode=I001
: Fetch a single item by code.type=all
: Fetch all items.
- Response:
200 OK
- Parameters:
-
Update Item (PUT /item?itemCode={itemCode}):
- Request:
{ "itemName": "Rice", "qty": 5, "unitPrice": 2000 }
- Response:
200 OK
- Request:
-
Delete Item (DELETE /item?itemCode={itemCode}):
- Response:
204 No Content
- Response:
-
Place Order (POST /placeorder):
- Request:
{ "orderId": "ORD001", "date": "2024-08-09", "customerId": "C001" }
- Response:
201 Created
- Request:
-
Save Order Details (POST /orderdetail):
- Request:
[ { "itemCode": "I001", "qty": 2, "unitPrice": 1500 } ]
- Response:
201 Created
- Request:
The application uses Logback for logging. Logs are generated in both the console and log files, providing detailed information about API requests, errors, and other significant events.
The API includes robust error handling mechanisms to return meaningful HTTP status codes and messages, ensuring clients can easily identify and resolve issues.
-# Features