Backend • Final Project

Backend Final Project

Saatnya bikin project backend nyata: Mini E-Commerce Backend System dengan PHP + MySQL + REST API. Ini project yang bikin skill backend kamu naik level dan siap jadi bahan portfolio 😈🔥

Estimasi: 8 - 12 Jam
Tools: PHP + MySQL
Output: Backend Portfolio Project
Video Referensi

Video ini referensi, tapi sistem database + fitur harus kamu build sendiri biar paham alurnya.

1. Project Brief

Kamu akan membangun backend sistem mini e-commerce yang mampu mengelola produk, kategori, dan user admin. Backend ini akan menyediakan REST API yang bisa diakses oleh frontend.

Anggap ini backend untuk toko online sederhana. Kalau ini kelar, kamu udah masuk level "backend ready".

2. Fitur Wajib

  • Database MySQL (products, categories, users)
  • CRUD Products
  • CRUD Categories
  • Admin Authentication (Login + Session)
  • REST API output JSON
  • Search product by keyword
  • Filter product by category
  • Validation + Security (prepared statement)
  • Optional: upload image product
Kalau semua fitur ini jalan, backend kamu udah layak jadi project portfolio.

3. Struktur Database

Gunakan database dengan nama:

codexshop_db

Buat 3 table utama:

1. users
2. categories
3. products
📌 Table users
CREATE TABLE users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  username VARCHAR(100) UNIQUE,
  password VARCHAR(255),
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
📌 Table categories
CREATE TABLE categories (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(120),
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
📌 Table products
CREATE TABLE products (
  id INT AUTO_INCREMENT PRIMARY KEY,
  category_id INT,
  name VARCHAR(150),
  price INT,
  stock INT,
  description TEXT,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

  FOREIGN KEY (category_id) REFERENCES categories(id)
);

4. Endpoint REST API

Endpoint yang harus kamu buat:

Method Endpoint Fungsi
GET /api/products Ambil semua produk
GET /api/products?id=1 Ambil detail produk
POST /api/products/create Tambah produk baru
POST /api/products/update Update produk
POST /api/products/delete Hapus produk
GET /api/categories Ambil kategori
Output API harus JSON, bukan HTML.

5. Struktur Folder Project

codexshop-backend/
 ├── config/
 │    └── database.php
 ├── api/
 │    ├── products/
 │    │    ├── index.php
 │    │    ├── create.php
 │    │    ├── update.php
 │    │    └── delete.php
 │    └── categories/
 │         └── index.php
 ├── admin/
 │    ├── login.php
 │    ├── dashboard.php
 │    └── logout.php
 └── README.md
Struktur folder rapih = project keliatan profesional dan gampang dikembangin.

6. Step-by-Step Build

  • Step 1: Buat database + table (users, categories, products)
  • Step 2: Setup file koneksi database (PDO)
  • Step 3: Buat API GET products (output JSON)
  • Step 4: Buat API POST create product
  • Step 5: Buat API update product
  • Step 6: Buat API delete product
  • Step 7: Buat API categories
  • Step 8: Buat admin login session
  • Step 9: Tambahkan search + filter endpoint
  • Step 10: Testing API pakai Postman
  • Step 11: Hubungkan ke frontend pakai Fetch API
  • Step 12: Rapihin project + buat README.md
🔥 Tips Real Backend Dev

Jangan coding random. Mulai dari database dulu, baru API, baru auth. Backend itu urutannya wajib rapih.

7. Testing API (Postman)

Kamu wajib test API sebelum dihubungkan ke frontend. Cara testing:

  • Install Postman
  • Coba GET endpoint products
  • Coba POST create product
  • Pastikan output JSON valid
  • Cek error response (500 / 404)
Kalau API belum stabil, frontend gak bakal bisa jalan mulus.

8. Connect ke Frontend

Setelah API siap, hubungkan ke frontend (Mini E-Commerce UI) menggunakan Fetch API. Contoh fetch:

fetch("http://localhost/codexshop-backend/api/products")
  .then(res => res.json())
  .then(data => console.log(data));
Ini momen dimana project kamu jadi fullstack beneran 😈🔥

9. Checklist Final

✅ Final Checklist
  • Database jalan tanpa error
  • CRUD products sukses
  • CRUD categories sukses
  • Output JSON valid
  • Search & filter endpoint berjalan
  • Admin login session berjalan
  • API sudah di test Postman
  • Frontend berhasil fetch data dari backend
  • Project rapih + README.md ada