https://github.com/sreeharshrajan/recipe-tracker-api
A production-ready RESTful API built with Laravel 12 for managing cooking recipes.
https://github.com/sreeharshrajan/recipe-tracker-api
crud interview-project laravel laravel-sanctum php phpunit recipe-tracker rest-api sqlite
Last synced: about 2 months ago
JSON representation
A production-ready RESTful API built with Laravel 12 for managing cooking recipes.
- Host: GitHub
- URL: https://github.com/sreeharshrajan/recipe-tracker-api
- Owner: sreeharshrajan
- Created: 2025-06-18T07:26:07.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-18T17:57:25.000Z (about 1 year ago)
- Last Synced: 2025-06-18T18:46:05.566Z (about 1 year ago)
- Topics: crud, interview-project, laravel, laravel-sanctum, php, phpunit, recipe-tracker, rest-api, sqlite
- Language: PHP
- Homepage:
- Size: 167 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ฝ๏ธ Symmersive Recipe Tracker API
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.
## ๐ Features
- 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
---
## ๐ง Tech Stack
- **Laravel 12**
- **PHP 8.2+**
- **SQLite**
- **Laravel Sanctum**
- **L5-Swagger** for API docs
- **PHPUnit** for testing
- **Laravel Pint** for code linting
---
## ๐ฆ Installation
```bash
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 --seed
```
### Make sure `.env` contains:
```
DB_CONNECTION=sqlite
DB_DATABASE=database/database.sqlite
```
---
## ๐ API Documentation
Access Swagger UI at:
```
http://127.0.0.1:8000/api/documentation
```
---
## ๐ Authentication
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}
```
---
## ๐ API Endpoints
| 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 | โ
|
### Search Example
```
GET /api/recipes/search?ingredients=potatoes,onion,cumin&min_time=20&max_time=30
```
---
## ๐งช Testing
Run all tests using:
```bash
php artisan test
```
Tests cover:
- Recipe CRUD
- Input validation
- 404 handling
- Auth & middleware
- Search feature
---
## ๐ฑ Seeder
Seeder uses the provided `recipe.json` file.
Each Recipe has:
- `name`: string
- `ingredients`: text (comma-separated)
- `prep_time`: integer
- `cook_time`: integer
- `difficulty`: enum (easy, medium, hard)
- `description`: string
---
## โ
Validation Rules
Handled by:
- `StoreRecipeRequest`
- `UpdateRecipeRequest`
Validates required fields, type, enum constraints, and format.
---
## ๐งฉ Laravel API Resource
All API responses are wrapped using `RecipeResource` which also includes:
```php
'total_time' => $prep_time + $cook_time
```
---
## ๐งน Code Quality
```bash
./vendor/bin/pint
```
Applies PSR-12 coding standards using Laravel Pint.
---
## ๐ License
MIT License
---
## ๐ค Author
Sreeharsh Rajan
Full Stack Developer (Laravel)
[LinkedIn](https://linkedin.com/in/sreeharshk) | [GitHub](https://github.com/sreeharshrajan) | [Portfolio](https://sreeharsh.vercel.app/)
---