A RESTful API-only Laravel application for managing cooking recipes. Developed as an interview project, this application supports recipe CRUD operations, advanced search by ingredients and cook time, authentication via Laravel Sanctum, and robust documentation with Swagger.
- Full CRUD for recipes
- JSON responses with proper HTTP status codes
- SQLite file-based development database
- Authentication via Laravel Sanctum
- Input validation using Form Request classes
- Swagger documentation (OpenAPI) via L5-Swagger
- Filter recipes by difficulty
- Advanced search by ingredients and total cook time
- Custom Resource classes with calculated
total_time - Unit & feature tests using PHPUnit
- PSR-12 linting applied via Laravel Pint
- Laravel 12
- PHP 8.2+
- SQLite
- Laravel Sanctum
- L5-Swagger for API docs
- PHPUnit for testing
- Laravel Pint for code linting
git clone https://github.com/sreeharshrajan/recipe-tracker-api.git
cd recipe-tracker-api
composer install
cp .env.example .env
touch database/database.sqlite
php artisan key:generate
php artisan migrate --seedDB_CONNECTION=sqlite
DB_DATABASE=database/database.sqlite
Access Swagger UI at:
http://127.0.0.1:8000/api/documentation
Laravel Sanctum is used for secure API authentication.
Register
POST /api/register
Login
POST /api/login
Use the token in headers:
Authorization: Bearer {your_token}
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/recipes | List all recipes | ✅ |
| POST | /api/recipes | Create a new recipe | ✅ |
| GET | /api/recipes/{id} | Show a specific recipe | ✅ |
| PUT | /api/recipes/{id} | Update a recipe | ✅ |
| DELETE | /api/recipes/{id} | Delete a recipe | ✅ |
| GET | /api/recipes/difficulty/{level} | Filter recipes by difficulty | ✅ |
| GET | /api/recipes/search | Search by ingredients + time | ✅ |
GET /api/recipes/search?ingredients=potatoes,onion,cumin&min_time=20&max_time=30
Run all tests using:
php artisan testTests cover:
- Recipe CRUD
- Input validation
- 404 handling
- Auth & middleware
- Search feature
Seeder uses the provided recipe.json file.
Each Recipe has:
name: stringingredients: text (comma-separated)prep_time: integercook_time: integerdifficulty: enum (easy, medium, hard)description: string
Handled by:
StoreRecipeRequestUpdateRecipeRequest
Validates required fields, type, enum constraints, and format.
All API responses are wrapped using RecipeResource which also includes:
'total_time' => $prep_time + $cook_time./vendor/bin/pintApplies PSR-12 coding standards using Laravel Pint.
MIT License
Sreeharsh Rajan
Full Stack Developer (Laravel)
LinkedIn | GitHub | Portfolio