This Laravel application parses raw email content and provides a RESTful API for managing successful emails.
- PHP 8.2+
- Composer
- MySQL
-
Clone the repository:
git clone https://github.com/Uziel79/inflektion-assessment cd inflektion-assessment -
Install dependencies:
composer install -
Copy
.env.exampleto.envand configure your database settings:cp .env.example .env -
Generate application key:
php artisan key:generate -
Verify the database credentials:
vim .env -
Run migrations:
php artisan migrate -
(Optional) Seed the database with sample data:
php artisan db:seed -
Run the app:
php artisan serve
The following API endpoints are available:
- GET /api/successful-emails: List all successful emails (paginated)
- POST /api/successful-emails: Create a new successful email
- GET /api/successful-emails/{id}: Get a specific successful email
- PUT /api/successful-emails/{id}: Update a specific successful email
- DELETE /api/successful-emails/{id}: Delete a specific successful email
All endpoints are protected by Laravel Sanctum authentication and RateLimiter.
To parse emails and extract plain text content:
php artisan emails:parse
This command is scheduled to run hourly. To set up the scheduler, add the following Cron entry to your server:
cd /var/www/inflektion-assessment && php artisan schedule:run >> /dev/null 2>&1
When you run locally:
php artisan schedule:work
This API uses Laravel Sanctum for authentication. To authenticate:
-
Create a user (if not already created):
php artisan tinker User::create(['name' => 'Test User', 'email' => 'test@example.com', 'password' => bcrypt('password')]); -
Obtain an API token by making a POST request to
/api/loginwith the user's credentials.{ "email": "test@example.com", "password": "password" } -
Include the token in the
Authorizationheader of your API requests:Authorization: Bearer <your-token>
Run the test suite with:
php artisan test
This project is open-sourced software licensed under the MIT license.