This project is a comprehensive ledger and sales management backend built with Laravel. It includes both a web version (admin panel) and a full-featured API, sharing the same backend codebase.
You can use the web interface for admin/management tasks, or integrate with the API for mobile apps, automation, or third-party tools.
It provides APIs for:
- User authentication and management
- Category and product management
- Sales and expense ledgers
- Transactions and payments (Razorpay integration)
- Dashboard analytics
Note: There is a mobile app that uses this API. For the full mobile source code, check the corresponding repository github.com/pplcallmesatz/finance-ledger-flutter.
- PHP 8.1+
- Composer
- MySQL or MariaDB
- Node.js & npm (for frontend assets)
-
Clone the repository and install dependencies:
git clone https://github.com/pplcallmesatz/finance-ledger-web-api-backend.git cd your-repo composer install npm install
-
Copy and configure your environment:
cp .env.example .env # Edit .env for your DB, mail, etc.
-
Generate app key and migrate database:
php artisan key:generate php artisan migrate --seed
-
Build frontend assets:
npm run dev
-
Serve the app:
php artisan serve
-
Access the API:
- Web URL:
http://localhost:8000/
(or your configured host)
- Web URL:
-
Access the API:
- API base URL:
http://localhost:8000/api
(or your configured host)
- API base URL:
Below is a summary of the main API endpoints and features available in this project:
POST /api/login
— Obtain an access token for API usagePOST /api/logout
— Invalidate the current token
GET /api/users
— List users (paginated)POST /api/users
— Create a new userGET /api/users/{id}
— Get user detailsPUT /api/users/{id}
— Update userDELETE /api/users/{id}
— Delete userGET /api/users/{id}/details
— Get user with sales summary (pending/paid)
GET /api/category-masters
— List categoriesPOST /api/category-masters
— Create categoryGET /api/category-masters/{id}
— Get category detailsPUT /api/category-masters/{id}
— Update categoryDELETE /api/category-masters/{id}
— Delete categoryGET /api/category-masters/{categoryMaster}/product-masters
— List product masters for a categoryGET /api/category-masters/{categoryMaster}/products
— List products for a category
GET /api/products
— List products (with search, category, barcode filters)POST /api/products
— Create productGET /api/products/{id}
— Get product detailsPUT /api/products/{id}
— Update productDELETE /api/products/{id}
— Delete productGET /api/products/search/barcode
— Search product by barcodeGET /api/products/{id}/inventory
— Get product inventory statusGET /api/products/{id}/pricing-history
— Get product pricing historyGET /api/products/{id}/performance
— Get product sales analyticsPOST /api/products/bulk-update-prices
— Bulk update product pricesGET /api/products/low-stock
— List low stock productsPOST /api/products/{id}/generate-barcode
— Generate barcode for product
GET /api/product-masters
— List product masters (with search, category filter)POST /api/product-masters
— Create product masterGET /api/product-masters/{id}
— Get product master detailsPUT /api/product-masters/{id}
— Update product masterDELETE /api/product-masters/{id}
— Delete product master
GET /api/sales-ledgers
— List sales ledgers (with filters)POST /api/sales-ledgers
— Create sales ledger entryGET /api/sales-ledgers/{id}
— Get sales ledger detailsPUT /api/sales-ledgers/{id}
— Update sales ledgerDELETE /api/sales-ledgers/{id}
— Delete sales ledgerGET /api/sales-ledgers/pending
— List all pending sales ledgers and totalPATCH /api/sales-ledgers/{id}/payment-info
— Update payment status/methodPATCH /api/sales-ledgers/{id}/payment-status
— Update payment status onlyPOST /api/sales-ledgers/{id}/payment-link
— Create payment linkGET /api/sales-ledgers/summary
— Get sales summary
GET /api/expense-ledgers
— List expense ledgersPOST /api/expense-ledgers
— Create expense ledgerGET /api/expense-ledgers/{id}
— Get expense ledger detailsPUT /api/expense-ledgers/{id}
— Update expense ledgerDELETE /api/expense-ledgers/{id}
— Delete expense ledger
GET /api/transactions
— List transactionsPOST /api/transactions
— Create transactionGET /api/transactions/{id}
— Get transaction detailsPUT /api/transactions/{id}
— Update transactionDELETE /api/transactions/{id}
— Delete transaction
POST /api/payments/create-order
— Create payment orderPOST /api/payments/verify
— Verify paymentGET /api/payments/status/{salesLedgerId}
— Get payment statusGET /api/payments/history
— Get payment historyPOST /api/payments/refund
— Process refundPOST /api/payments/webhook
— Razorpay webhook endpoint
GET /api/dashboard/overview
— Get business statisticsGET /api/dashboard/product-analysis
— Product/category profit/lossGET /api/dashboard/inventory-status
— Inventory by categoryGET /api/dashboard/sales-trends
— Sales trends (by period)GET /api/dashboard/top-products
— Top productsGET /api/dashboard/customer-analytics
— Customer analytics
You can interact with this API using cURL from the command line. Below are sample requests and typical JSON responses for the main modules.
Request:
curl -X POST "http://localhost:8000/api/login" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "password"
}'
Expected Output:
{
"token": "1|abc123..."
}
List Users
curl -X GET "http://localhost:8000/api/users" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json"
Create User
curl -X POST "http://localhost:8000/api/users" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"email": "john@example.com",
"phone": "9876543210",
"password": "your_password"
}'
Edit User
curl -X PUT "http://localhost:8000/api/users/3" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name": "John Updated",
"email": "john@example.com",
"phone": "9876543210"
}'
Delete User
curl -X DELETE "http://localhost:8000/api/users/3" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json"
Expected Output (for create/edit):
{
"data": {
"id": 3,
"name": "John Updated",
"email": "john@example.com",
"phone": "9876543210"
// ...other fields
}
}
List Categories
curl -X GET "http://localhost:8000/api/category-masters" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json"
Create Category
curl -X POST "http://localhost:8000/api/category-masters" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name": "Electronics",
"description": "Electronic products",
"symbol": "ELEC",
"self_life": "365"
}'
Edit Category
curl -X PUT "http://localhost:8000/api/category-masters/3" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name": "Electronics Updated",
"description": "Updated description",
"symbol": "ELEC",
"self_life": "365"
}'
Delete Category
curl -X DELETE "http://localhost:8000/api/category-masters/3" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json"
Expected Output (for create/edit):
{
"data": {
"id": 3,
"name": "Electronics Updated",
"description": "Updated description",
"symbol": "ELEC",
"self_life": "365"
// ...other fields
}
}
List Product Masters
curl -X GET "http://localhost:8000/api/product-masters" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json"
Create Product Master
curl -X POST "http://localhost:8000/api/product-masters" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name": "Bulk Laptops",
"category_id": 1,
"purchase_price": 50000,
"purchase_date": "2024-01-01",
"manufacturing_date": "2023-12-01",
"transportation_cost": 1000,
"invoice_number": "INV001",
"vendor": "Tech Supplier",
"quantity_purchased": 10,
"expire_date": "2025-12-01",
"total_piece": "10"
}'
Edit Product Master
curl -X PUT "http://localhost:8000/api/product-masters/5" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name": "Bulk Laptops Updated",
"category_id": 1,
"purchase_price": 51000,
"purchase_date": "2024-01-01",
"manufacturing_date": "2023-12-01",
"transportation_cost": 1100,
"invoice_number": "INV001",
"vendor": "Tech Supplier",
"quantity_purchased": 12,
"expire_date": "2025-12-01",
"total_piece": "12"
}'
Delete Product Master
curl -X DELETE "http://localhost:8000/api/product-masters/5" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json"
Expected Output (for create/edit):
{
"data": {
"id": 5,
"name": "Bulk Laptops Updated",
"category_id": 1,
"purchase_price": 51000,
// ...other fields
}
}
List Products
curl -X GET "http://localhost:8000/api/products" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json"
Create Product
curl -X POST "http://localhost:8000/api/products" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name": "Laptop",
"purchase_price": 50000,
"packing_price": 500,
"product_price": 50500,
"selling_price": 60000,
"description": "High-performance laptop",
"category_master_id": 1,
"barcode": "LAP001",
"barcode_vendor": "Vendor A",
"units": 1
}'
Edit Product
curl -X PUT "http://localhost:8000/api/products/10" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name": "Laptop Updated",
"purchase_price": 51000,
"packing_price": 600,
"product_price": 51600,
"selling_price": 61000,
"description": "Updated laptop",
"category_master_id": 1,
"barcode": "LAP001",
"barcode_vendor": "Vendor A",
"units": 1
}'
Delete Product
curl -X DELETE "http://localhost:8000/api/products/10" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json"
Expected Output (for create/edit):
{
"data": {
"id": 10,
"name": "Laptop Updated",
"category_master_id": 1,
"product_price": 51600,
// ...other fields
}
}
List Transactions
curl -X GET "http://localhost:8000/api/transactions" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json"
Create Transaction
curl -X POST "http://localhost:8000/api/transactions" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"bank_balance": 100000,
"cash_in_hand": 50000,
"sales_ledger_id": 1,
"reason": "Sales transaction"
}'
Edit Transaction
curl -X PUT "http://localhost:8000/api/transactions/3" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"bank_balance": 110000,
"cash_in_hand": 60000,
"sales_ledger_id": 1,
"reason": "Updated reason"
}'
Delete Transaction
curl -X DELETE "http://localhost:8000/api/transactions/3" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json"
Expected Output (for create/edit):
{
"data": {
"id": 3,
"bank_balance": 110000,
"cash_in_hand": 60000,
"sales_ledger_id": 1,
"reason": "Updated reason"
// ...other fields
}
}
List Expense Ledgers
curl -X GET "http://localhost:8000/api/expense-ledgers" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json"
Create Expense Ledger
curl -X POST "http://localhost:8000/api/expense-ledgers" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name": "Office Rent",
"description": "Monthly office rent",
"invoice_number": "INV001",
"purchase_price": 50000,
"seller": "Landlord",
"purchase_date": "2024-01-01",
"payment_method": "bank_transfer",
"expense_type": "rent",
"deduct": true
}'
Edit Expense Ledger
curl -X PUT "http://localhost:8000/api/expense-ledgers/5" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name": "Office Rent Updated",
"description": "Updated rent",
"invoice_number": "INV001",
"purchase_price": 51000,
"seller": "Landlord",
"purchase_date": "2024-01-01",
"payment_method": "bank_transfer",
"expense_type": "rent",
"deduct": true
}'
Delete Expense Ledger
curl -X DELETE "http://localhost:8000/api/expense-ledgers/5" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json"
Expected Output (for create/edit):
{
"data": {
"id": 5,
"name": "Office Rent Updated",
"purchase_price": 51000,
// ...other fields
}
}
List Sales Ledgers
curl -X GET "http://localhost:8000/api/sales-ledgers" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json"
Create Sales Ledger
curl -X POST "http://localhost:8000/api/sales-ledgers" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"user_id": 1,
"sales_date": "2024-01-15",
"payment_method": "cash",
"payment_status": "pending",
"remarks": "Customer order",
"products": [
{
"selected": true,
"product_id": 1,
"product_name": "Laptop",
"product_price": 50000,
"selling_price": 60000,
"quantity": 1,
"customer_price": 60000,
"product_master_id": 1
}
]
}'
Edit Sales Ledger
curl -X PUT "http://localhost:8000/api/sales-ledgers/7" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"user_id": 1,
"sales_date": "2024-01-15",
"payment_method": "bank_transfer",
"payment_status": "paid",
"remarks": "Updated order",
"products": [
{
"selected": true,
"product_id": 1,
"product_name": "Laptop",
"product_price": 50000,
"selling_price": 60000,
"quantity": 1,
"customer_price": 60000,
"product_master_id": 1
}
]
}'
Delete Sales Ledger
curl -X DELETE "http://localhost:8000/api/sales-ledgers/7" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json"
Expected Output (for create/edit):
{
"data": {
"id": 7,
"user_id": 1,
"total_customer_price": 60000,
"payment_status": "paid",
// ...other fields
}
}
If you send invalid data or an invalid token, you may get:
{
"message": "Unauthenticated."
}
or
{
"success": false,
"message": "The given data was invalid.",
"errors": {
"field_name": ["The field name field is required."]
}
}
Tip:
Replace YOUR_ACCESS_TOKEN
with your actual Bearer token.
Name: Satheesh Kumar S
Github Profile: github.com/pplcallmesatz
Github Repo: github.com/pplcallmesatz/finance-ledger-web-api-backend
Email: satheeshssk@icloud.com
Instagram: instagram.com/pplcallmesatz
If you find this tool useful, consider supporting me:
This tool is fully generated using AI tools. Issues may be expected.
Please report bugs or contribute via pull requests!