Skip to content

API PHP 1.1 (CLEAN)

Choose a tag to compare

@syauqi357 syauqi357 released this 23 Nov 19:06
· 1 commit to master since this release

🚰 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 βœ