API PHP 1.1 (CLEAN)
π° Galon Management System v1.0
A simple water gallon business management system with REST API and modern UI.
β¨ Features
- π¦ Product Management (Add, Edit, Delete)
- π° Transaction Tracking
- π Real-time Revenue Dashboard
- π¨ Beautiful Tailwind CSS Interface
- π REST API (GET, POST, PUT, DELETE)
π οΈ Tech Stack
Backend: PHP + MySQL
Frontend: HTML + JavaScript + Tailwind CSS
π Quick Setup
1. Database
CREATE DATABASE galondb;
USE galondb;
CREATE TABLE products (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
price DECIMAL(10, 2) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE transactions (
id INT AUTO_INCREMENT PRIMARY KEY,
product_id INT NOT NULL,
quantity INT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (product_id) REFERENCES products(id) ON DELETE CASCADE
);2. Configure
Update api.php database credentials:
define('DB_NAME', 'galondb');
define('DB_USER', 'root');
define('DB_PASS', '');3. Run
Place in htdocs/ and access:
http://localhost/restapi/index.html
π API Endpoints
GET /api.php?endpoint=products # Get all products
GET /api.php?endpoint=products&id=1 # Get single product
POST /api.php?endpoint=products # Create product
PUT /api.php?endpoint=products&id=1 # Update product
DELETE /api.php?endpoint=products&id=1 # Delete product
GET /api.php?endpoint=transactions # Get all transactions
POST /api.php?endpoint=transactions # Create transaction
PUT /api.php?endpoint=transactions&id=1 # Update transaction
DELETE /api.php?endpoint=transactions&id=1 # Delete transaction
π Example Request
// Create Product
fetch('api.php?endpoint=products', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({name: 'Aqua 19L', price: 20000})
});π Files
restapi/
βββ api.php # REST API
βββ index.html # Frontend UI
βββ README.md
π¨βπ» Author
Syauqi - [@syauqi357](https://github.com/syauqi357)
π License
MIT License
v1.0 - November 2024 β