Skip to content

Coding test project untuk Bina Area Persada (BAP). Dibuat dengan Laravel12 + Livewire, menampilkan fitur CRUD User sederhana dengan UUID, pagination, pencarian.

Notifications You must be signed in to change notification settings

zoelabbb/ct-bap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Laravel 12 User CRUD Management System

Sistem manajemen user dengan fitur CRUD lengkap menggunakan Laravel 12, Livewire, dan TailwindCSS

Laravel Livewire TailwindCSS SQLite

๐Ÿ“‹ Deskripsi Project

Aplikasi web modern untuk manajemen user dengan fitur CRUD (Create, Read, Update, Delete). Dibangun menggunakan Laravel 12 dengan performa dan user experience yang optimal.

Daftar User

โœจ Key Features

  • ๐Ÿ” Advanced Search - Pencarian real-time dengan debounce
  • ๐Ÿ“„ Smart Pagination - 5 item per halaman dengan query string persistence
  • โšก Performance Monitoring - Real-time query speed display
  • ๐Ÿ›ก๏ธ Business Logic - Validasi khusus untuk operasi delete
  • ๐Ÿ“ฑ Responsive Design - Mobile-friendly dengan TailwindCSS
  • ๐Ÿ” UUID Primary Keys - Modern database design
  • ๐Ÿ“Š Database Indexing - Optimized untuk ribuan data

๐Ÿ—๏ธ Tech Stack

Backend

  • Laravel 12.20.0 - PHP Framework terbaru
  • Livewire 3.x - Full-stack framework untuk Laravel
  • MySql - Database
  • Eloquent ORM - Database abstraction layer

Frontend

  • TailwindCSS 3.x - Utility-first CSS framework
  • Alpine.js - Lightweight JavaScript framework
  • Vite - Fast build tool
  • Blade Templates - Laravel templating engine

Development Tools

  • Laravel Artisan - Command line interface
  • Laravel Tinker - Interactive shell
  • Composer - Dependency management
  • NPM - Package management

๐Ÿ“Š Database Schema

Users Table

Column          Type        Constraints
-----------------------------------------
id              UUID        PRIMARY KEY
name            VARCHAR     NOT NULL (min: 3 chars)
address         VARCHAR     NOT NULL (min: 3 chars)
email           VARCHAR     UNIQUE
password        VARCHAR     HASHED
created_at      TIMESTAMP   INDEXED
updated_at      TIMESTAMP

Database Indexes

-- Performance optimization indexes
idx_users_name              (name)
idx_users_created_at        (created_at)
idx_users_name_created_at   (name, created_at)

๐ŸŽฏ Business Logic

Validation Rules

  • Name: Minimum 3 characters, required
  • Address: Minimum 3 characters, required
  • UUID: Auto-generated untuk setiap user baru

Delete Protection

// Users dengan nama mengandung huruf "a" atau "A" tidak dapat dihapus
if (stripos($user->name, 'a') !== false) {
    throw new BusinessException('Cannot delete user with "a" in name');
}

๐Ÿš€ Installation & Setup

Prerequisites

  • PHP 8.2+
  • Composer
  • Node.js & NPM
  • MySql

1. Clone & Install

git clone https://github.com/zoelabbb/ct-bap.git
cd ct-bap
composer install
npm install

2. Environment Setup

cp .env.example .env
php artisan key:generate

3. Database Setup

# Create MySql database
import db_ct-bap.sql

# Run migrations with indexes
php artisan migrate

# Seed with 1000 sample users
php artisan db:seed

4. Build Assets

# Development
npm run dev

# Production
npm run build

5. Start Server

php artisan serve

Aplikasi akan tersedia di: http://127.0.0.1:8000

๐ŸŽฎ Usage Guide

User Management Routes

GET  /users              // List all users with search & pagination
GET  /users/create       // Create new user form
GET  /users/{user}/edit  // Edit existing user form

Search & Filter

  • Real-time Search: Ketik di search box untuk filter berdasarkan nama
  • URL Persistence: Search terms dan halaman tersimpan di URL
  • Performance: Query speed ditampilkan real-time

CRUD Operations

Create User

  1. Klik "Tambah User"
  2. Isi form (nama & alamat minimum 3 karakter)
  3. UUID akan auto-generate
  4. Submit untuk simpan

Search Users

  1. Gunakan search box di halaman utama
  2. Hasil filter otomatis dengan debounce 300ms
  3. Pagination reset ke halaman 1 saat search baru

Edit User

  1. Klik "Edit" pada user yang diinginkan
  2. Form ter-populate dengan data existing
  3. Update dan submit

Delete User

  1. Klik "Hapus" pada user
  2. Konfirmasi dengan popup
  3. Sistem cek business logic (nama dengan "a/A" tidak bisa dihapus)
  4. Flash message untuk feedback

โšก Performance Optimization

Query Optimization

  • Select Specific Columns: Hanya ambil kolom yang diperlukan
  • Strategic Indexing: 3 index untuk pattern query yang sering digunakan
  • Efficient Pagination: LIMIT/OFFSET dengan index support
  • Conditional Queries: Avoid unnecessary WHERE clause

Performance Metrics

With 1,000+ users:
- Normal pagination: ~5ms (EXCELLENT)
- Search pagination: ~35ms (VERY GOOD)
- Memory usage: Optimized with pagination
- Database size: Efficiently indexed

๐Ÿ—๏ธ Architecture

MVC Pattern

โ”œโ”€โ”€ Models/
โ”‚   โ””โ”€โ”€ User.php                 # Eloquent model with UUID
โ”œโ”€โ”€ Controllers/
โ”‚   โ””โ”€โ”€ Livewire/
โ”‚       โ”œโ”€โ”€ UserIndex.php        # List, search, delete
โ”‚       โ””โ”€โ”€ UserForm.php         # Create & edit
โ”œโ”€โ”€ Views/
โ”‚   โ”œโ”€โ”€ livewire/
โ”‚   โ”‚   โ”œโ”€โ”€ user-index.blade.php
โ”‚   โ”‚   โ””โ”€โ”€ user-form.blade.php
โ”‚   โ””โ”€โ”€ components/layouts/
โ”‚       โ””โ”€โ”€ user.blade.php       # Layout template
โ””โ”€โ”€ Routes/
    โ””โ”€โ”€ web.php                  # Public routes (no auth required)

Database Layer

โ”œโ”€โ”€ Migrations/
โ”‚   โ”œโ”€โ”€ create_users_table.php   # Main table structure
โ”‚   โ””โ”€โ”€ add_indexes_to_users_table.php  # Performance indexes
โ”œโ”€โ”€ Factories/
โ”‚   โ””โ”€โ”€ UserFactory.php          # Test data generation
โ””โ”€โ”€ Seeders/
    โ”œโ”€โ”€ UserSeeder.php           # 1000 sample users
    โ””โ”€โ”€ DatabaseSeeder.php       # Master seeder

๐Ÿ”ง Configuration

Sample Data

  • 1000 Users dengan Faker data
  • Berbagai nama untuk testing search
  • Mixed data untuk testing business logic

๐Ÿ“ˆ Scalability

Database Performance

  • โœ… 1,000 users: <10ms queries
  • โœ… 10,000 users: <50ms queries
  • โœ… 100,000 users: <100ms queries
  • โš ๏ธ 1M+ users: Perlu additional optimization

Optimization Recommendations

  • Redis Caching untuk frequently accessed data
  • Database Partitioning untuk million+ records
  • CDN untuk static assets
  • Load Balancing untuk high traffic

๐Ÿ›ก๏ธ Security Features

Input Validation

  • Server-side validation dengan Laravel rules
  • XSS Protection dengan Blade escaping
  • SQL Injection Prevention dengan Eloquent ORM
  • CSRF Protection dengan Laravel tokens

Data Protection

  • Mass Assignment Protection dengan fillable
  • Password Hashing dengan bcrypt
  • UUID Primary Keys mencegah enumeration attacks

๐Ÿ“ Development Notes

Code Quality

  • PSR Standards untuk PHP code style
  • Single Responsibility principle
  • DRY (Don't Repeat Yourself) pattern
  • Clean Code practices

Best Practices Applied

  • โœ… Database Indexing untuk performance
  • โœ… Query Optimization untuk scalability
  • โœ… Component Reusability untuk maintainability
  • โœ… Error Handling untuk reliability
  • โœ… Performance Monitoring untuk optimization

๐Ÿ“ž Support

Developer Contact

  • Project: Laravel User CRUD System - CT BAP
  • Author: Alif Ryuu
  • Email: [email protected]
  • Version: 1.0.0
  • Created: July 2025
  • Laravel Version: 12.20.0

Documentation


Built with โค๏ธ using Laravel 12 + Livewire + TailwindCSS

"Clean code, optimal performance, modern architecture"

About

Coding test project untuk Bina Area Persada (BAP). Dibuat dengan Laravel12 + Livewire, menampilkan fitur CRUD User sederhana dengan UUID, pagination, pencarian.

Topics

Resources

Stars

Watchers

Forks

Languages