A comprehensive Desktop and Web UI-based Trading Management System built using Java Spring Boot, MySQL, HTML, CSS, and AngularJS.
- Add/Update purchase records with date, shop, item, bags, amount, and discount
- Search purchases by date range and shop name
- Display total bags and total amount
- Edit and delete purchase records
- Add/Update sales records with date, item, customer, bags, and amount
- Search sales by date range and customer name
- Automatic customer balance update when sales are added
- Display total bags and total amount
- Edit and delete sales records
- View all customer balances in real-time
- Make payments against customer balances
- Automatic balance deduction when payment is made
- Add payment notes for record-keeping
- View payment history
- Delete payment records
- Add, list, and delete Items
- Add, list, and delete Shops with address and contact information
- Add, list, and delete Customers with address and contact information
- View customer balance information
- Java 11
- Spring Boot 2.7.14
- Spring Data JPA
- MySQL 8
- Maven
- HTML5
- CSS3
- AngularJS 1.8.2
- MySQL 8.0
sr-trading/
├── src/
│ ├── main/
│ │ ├── java/com/trading/srtrading/
│ │ │ ├── controller/ # REST Controllers
│ │ │ │ ├── CustomerController.java
│ │ │ │ ├── ItemController.java
│ │ │ │ ├── PaymentController.java
│ │ │ │ ├── PurchaseController.java
│ │ │ │ ├── SalesController.java
│ │ │ │ └── ShopController.java
│ │ │ ├── entity/ # JPA Entities
│ │ │ │ ├── Customer.java
│ │ │ │ ├── Item.java
│ │ │ │ ├── Payment.java
│ │ │ │ ├── Purchase.java
│ │ │ │ ├── Sales.java
│ │ │ │ └── Shop.java
│ │ │ ├── repository/ # JPA Repositories
│ │ │ │ ├── CustomerRepository.java
│ │ │ │ ├── ItemRepository.java
│ │ │ │ ├── PaymentRepository.java
│ │ │ │ ├── PurchaseRepository.java
│ │ │ │ ├── SalesRepository.java
│ │ │ │ └── ShopRepository.java
│ │ │ ├── service/ # Business Logic Services
│ │ │ │ ├── CustomerService.java
│ │ │ │ ├── ItemService.java
│ │ │ │ ├── PaymentService.java
│ │ │ │ ├── PurchaseService.java
│ │ │ │ ├── SalesService.java
│ │ │ │ └── ShopService.java
│ │ │ └── SrTradingApplication.java # Main Application
│ │ └── resources/
│ │ ├── static/ # Frontend Files
│ │ │ ├── css/
│ │ │ │ └── styles.css
│ │ │ ├── js/
│ │ │ │ └── app.js
│ │ │ └── index.html
│ │ ├── application.properties
│ │ └── schema.sql
│ └── test/
├── pom.xml
└── README.md
Before running this application, ensure you have the following installed:
-
Java Development Kit (JDK) 11 or higher
- Download from: https://adoptium.net/
-
Apache Maven 3.6+
- Download from: https://maven.apache.org/download.cgi
-
MySQL 8.0+
- Download from: https://dev.mysql.com/downloads/mysql/
-
Git (for cloning the repository)
- Download from: https://git-scm.com/downloads
git clone https://github.com/rangegowdaym/sr-trading.git
cd sr-trading-
Start MySQL server
-
Login to MySQL:
mysql -u root -p
-
Create the database:
CREATE DATABASE sr_trading;
-
(Optional) Create a dedicated user:
CREATE USER 'trading_user'@'localhost' IDENTIFIED BY 'trading_password'; GRANT ALL PRIVILEGES ON sr_trading.* TO 'trading_user'@'localhost'; FLUSH PRIVILEGES;
Edit src/main/resources/application.properties if needed:
spring.datasource.url=jdbc:mysql://localhost:3306/sr_trading?createDatabaseIfNotExist=true&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=rootNote: Update the username and password to match your MySQL credentials.
mvn clean installmvn spring-boot:runAlternatively, you can run the JAR file:
java -jar target/sr-trading-1.0.0.jarOnce the application starts successfully:
- Backend API: http://localhost:8080/api
- Frontend UI: http://localhost:8080/index.html
GET /api/items- Get all itemsGET /api/items/{id}- Get item by IDPOST /api/items- Create new itemPUT /api/items/{id}- Update itemDELETE /api/items/{id}- Delete item
GET /api/shops- Get all shopsGET /api/shops/{id}- Get shop by IDPOST /api/shops- Create new shopPUT /api/shops/{id}- Update shopDELETE /api/shops/{id}- Delete shop
GET /api/customers- Get all customersGET /api/customers/{id}- Get customer by IDPOST /api/customers- Create new customerPUT /api/customers/{id}- Update customerDELETE /api/customers/{id}- Delete customer
GET /api/purchases- Get all purchasesGET /api/purchases/{id}- Get purchase by IDGET /api/purchases/search?startDate={date}&endDate={date}&shopId={id}- Search purchasesPOST /api/purchases- Create new purchasePUT /api/purchases/{id}- Update purchaseDELETE /api/purchases/{id}- Delete purchase
GET /api/sales- Get all salesGET /api/sales/{id}- Get sales by IDGET /api/sales/search?startDate={date}&endDate={date}&customerId={id}- Search salesPOST /api/sales- Create new sales (automatically updates customer balance)PUT /api/sales/{id}- Update salesDELETE /api/sales/{id}- Delete sales
GET /api/payments- Get all paymentsGET /api/payments/{id}- Get payment by IDGET /api/payments/customer/{customerId}- Get payments by customerPOST /api/payments- Create new payment (automatically deducts from customer balance)PUT /api/payments/{id}- Update paymentDELETE /api/payments/{id}- Delete payment
-
Add Master Data First: Navigate to the "Master Data" tab and add:
- Items (e.g., Rice, Wheat, Sugar)
- Shops (with addresses and contact information)
- Customers (with addresses and contact information)
-
Record Purchases: Go to the "Purchase" tab to record:
- Purchase date
- Shop name
- Items purchased
- Number of bags
- Amount and discount
-
Record Sales: Go to the "Sales" tab to record:
- Sales date
- Item sold
- Customer name
- Number of bags
- Amount (automatically updates customer balance)
-
Manage Payments: Go to the "Payment" tab to:
- View all customer balances
- Record payments made by customers
- View payment history
- All sales and payment operations are transactional
- Customer balance automatically updates when:
- New sales are added (balance increases)
- Payments are made (balance decreases)
- Sales or payments are deleted (balance is adjusted accordingly)
- Date range filtering for purchases and sales
- Filter by shop name for purchases
- Filter by customer name for sales
- Automatic calculation of totals (bags and amounts)
- All forms have required field validation
- Proper foreign key constraints in the database
- Error handling for all operations
- Verify MySQL is running
- Check database credentials in
application.properties - Ensure port 8080 is not in use
- Verify MySQL service is running
- Check if the database
sr_tradingexists - Verify username and password in
application.properties
- Clear browser cache
- Check browser console for JavaScript errors
- Verify the backend is running on port 8080
- The application is configured to accept requests from all origins
- If issues persist, check browser console and network tab
mvn spring-boot:run -Dspring-boot.run.profiles=devmvn clean package -DskipTestsThe application creates the following tables:
item- Stores item informationshop- Stores shop informationcustomer- Stores customer information with balancepurchase- Stores purchase recordssales- Stores sales recordspayment- Stores payment records
All tables have proper foreign key relationships and indexes for optimal performance.
This project is licensed under the MIT License.
For issues and questions, please create an issue in the GitHub repository.
SR Trading Management System Development Team