A minimal API project for imaginary products with CRUD operations, built on Laravel + Inertia + Vue starter kit (includes Tailwind CSS), featuring comprehensive API documentation, validation, error handling, and testing.
This project implements a full-stack application for managing products. It includes:
- Product model with fields for name, description, price, stock, and active status
- RESTful API endpoints for CRUD operations (Create, Read, Update, Delete)
- Vue-driven frontend interface for product management
- Validation and error handling on both backend and frontend
- Sample data by using seeders
- Test script for API endpoints
- Comprehensive API and frontend documentation
-
Clone the repository
-
Install dependencies:
composer install npm install -
Set up the environment:
cp .env.example .env php artisan key:generate -
Run migrations and seeders:
php artisan migrate:fresh --seed -
Start the development server:
php artisan serve -
Compile the frontend assets:
npm run dev -
Access the application at
http://localhost:8000 -
For API access, use
http://localhost:8000/api/products -
For the Vue frontend, authenticate via the web interface with the default user credentials (email:
test@example.com, password:password), or create a new user via the registration page. Once authenticated, you can access the product management pages at/products, where you can create, view, edit, and delete products.
The following API endpoints are available:
GET /api/products- List all productsGET /api/products/{id}- Get a specific productPOST /api/products- Create a new productPUT /api/products/{id}- Update a productDELETE /api/products/{id}- Delete a product
For detailed information about request parameters and response formats, see the API Documentation.
The project includes a Vue-driven frontend for product management with the following pages:
/products- List all products/products/create- Create a new product/products/{id}- View a specific product/products/{id}/edit- Edit a product
The frontend is built using Vue 3 with the Composition API and Inertia.js for seamless integration with Laravel.
For detailed information about the Vue implementation, see the Product CRUD Documentation.
To test the API endpoints, you can use tools like Postman. Below are examples of how to interact with the API:
The project includes automated feature tests using Pest:
- Run the tests:
php artisan test
The Pest tests cover all CRUD operations for the Products API:
- Listing all products
- Getting a single product
- Creating a product (including validation)
- Updating a product
- Deleting a product
- Error handling for non-existent products
app/Models/Product.php- Product modelapp/Http/Controllers/Api/ProductController.php- Controller for product API endpointsdatabase/migrations/2025_07_18_065717_create_products_table.php- Migration for products tabledatabase/seeders/ProductSeeder.php- Seeder for sample product dataroutes/api.php- API routestests/Feature/ProductApiTest.php- Pest tests for API endpoints
resources/js/composables/useProducts.ts- Composable for product API operationsresources/js/pages/Products/Index.vue- Product list componentresources/js/pages/Products/Create.vue- Product creation componentresources/js/pages/Products/Show.vue- Product details componentresources/js/pages/Products/Edit.vue- Product edit componentroutes/web.php- Web routes for Vue components
API_DOCUMENTATION.md- Detailed API documentationPRODUCT_CRUD_DOCUMENTATION.md- Detailed Vue frontend implementation documentationPRICE_FORMATTING_FIX.md- Documentation for price formatting fix
- Product Management: Create, read, update, and delete products via API and Vue frontend
- Vue-driven Frontend: Interactive user interface built with Vue 3 and Composition API
- Validation: Input validation for product fields on both backend and frontend
- Error Handling: Proper error responses with meaningful messages on both backend and frontend
- Sample Data: Seeder for creating sample products
- Testing:
- Automated tests using Pest for all CRUD operations
- Documentation:
- Comprehensive API documentation
- Detailed Vue frontend implementation documentation