A Laravel 12 application for uploading and processing CSV files with background job processing, real-time status updates, and idempotent product data management.
- ✅ CSV File Upload - Drag-and-drop or click to upload CSV files (up to 50MB)
- ✅ Background Processing - Redis/Database queue with worker processes CSV files asynchronously
- ✅ Real-time Status Updates - Auto-refreshing UI with color-coded status badges
- ✅ Idempotent Uploads - UPSERT products by
UNIQUE_KEY(no duplicates) - ✅ UTF-8 Cleaning - Automatic cleaning of non-UTF-8 characters
- ✅ API Transformers - Fractal transformers for clean JSON responses
- ✅ Comprehensive Tests - PHPUnit feature and unit tests
- Backend: Laravel 12 (PHP 8.2)
- Database: SQLite
- Queue: Redis (via Predis) or Database driver
- Frontend: TailwindCSS, Vanilla JavaScript
- Testing: PHPUnit
- PHP 8.2+
- Composer
- Docker (for Redis)
- Git
-
Clone the repository
git clone https://github.com/shahswiene/YoPrint_Laravel_Coding_Project.git cd YoPrint_Laravel_Coding_Project -
Install dependencies
composer install
-
Configure environment
cp .env.example .env php artisan key:generate
-
Update
.envfileDB_CONNECTION=sqlite QUEUE_CONNECTION=redis REDIS_CLIENT=predis REDIS_HOST=127.0.0.1 REDIS_PORT=6379
-
Run migrations
php artisan migrate
-
Start Redis (Docker)
docker run -d --name redis -p 6379:6379 redis:alpine
-
Start Laravel server
php artisan serve
-
Start queue worker (in separate terminal)
php artisan queue:work redis --tries=3 --timeout=300
-
Open browser
http://127.0.0.1:8000
Run all tests:
php artisan testRun specific test suite:
# Feature tests
php artisan test --testsuite=Feature
# Unit tests
php artisan test --testsuite=UnitRun with coverage:
php artisan test --coverageThe application expects CSV files with the following columns:
| Column | Description |
|---|---|
| UNIQUE_KEY | Unique identifier for product |
| PRODUCT_TITLE | Product name |
| PRODUCT_DESCRIPTION | Product description |
| STYLE# | Style number |
| SANMAR_MAINFRAME_COLOR | Color code |
| SIZE | Product size |
| COLOR_NAME | Color display name |
| PIECE_PRICE | Product price |
UNIQUE_KEY,PRODUCT_TITLE,PRODUCT_DESCRIPTION,STYLE#,SANMAR_MAINFRAME_COLOR,SIZE,COLOR_NAME,PIECE_PRICE
TEST001,Sample Product,A great product,STY001,Blue,L,Navy Blue,25.99
TEST002,Another Product,Another description,STY002,Red,M,Crimson,19.99
GET /api/uploads/status
Returns JSON with Fractal transformer:
{
"data": [
{
"id": 1,
"filename": "test.csv",
"status": "completed",
"progress": {
"total": 100,
"processed": 100,
"percentage": 100
},
"uploaded_at": "2025-10-28T14:00:00+00:00",
"uploaded_at_human": "5 minutes ago",
"error": null
}
]
}-
UploadControllerTest (Feature)
- Upload page display
- File upload validation
- File type validation
- File size limits
- Idempotent uploads
- Queue job dispatch
- API status endpoint
-
ProcessCsvUploadJobTest (Unit)
- CSV parsing and product creation
- UPSERT by UNIQUE_KEY
- UTF-8 character cleaning
- Empty CSV handling
- Error handling and failed status
# Run upload controller tests
php artisan test --filter=UploadControllerTest
# Run CSV job tests
php artisan test --filter=ProcessCsvUploadJobTestapp/
├── Http/Controllers/
│ └── UploadController.php # Upload handling & API
├── Jobs/
│ └── ProcessCsvUpload.php # Background CSV processing
├── Models/
│ ├── Product.php # Product model
│ └── Upload.php # Upload tracking model
└── Transformers/
└── UploadTransformer.php # API response transformer
tests/
├── Feature/
│ └── UploadControllerTest.php # Feature tests
└── Unit/
└── ProcessCsvUploadJobTest.php # Unit tests
The Laravel framework is open-sourced software licensed under the MIT license.