Skip to content

abbasfisal/blog-app-code-challenge

Repository files navigation

PHP Technical Coding Task: Blog Application

Welcome Candidate!

This document outlines the task specifications for your coding assessment. Your goal is to create a simple blog application using Laravel. This task will test your technical, analytical, and problem-solving skills. Please read the requirements carefully and follow the guidelines to the best of your ability.


General Instructions

  • Framework: Use Laravel to implement the backend and REST API.
  • Composer Integration: Leverage Composer to manage dependencies.
  • Time Management: You might not complete all tasks within the given time. Focus on demonstrating a good balance between quality and functionality.
  • Questions: Feel free to ask if anything is unclear. Someone will be available to assist.

We value your efforts and look forward to seeing your implementation. Good luck!


Application Requirements

Backend: Database and Data Model

  • Use MySQL as your database.
  • Design and implement a relational data model to meet the blog’s requirements.
  • Use Laravel's Eloquent ORM for database interaction.

REST API: Features

General Endpoints

  • Provide RESTful API endpoints to manage articles.
  • Use appropriate HTTP methods (GET, POST, PUT, DELETE) for each operation.

Article Management

  1. Create an Article:

    • Endpoint: POST /api/articles
    • Accepts JSON payload with title and content.
    • Saves the article to the database with the current timestamp.
  2. Edit an Article:

    • Endpoint: PUT /api/articles/{id}
    • Accepts JSON payload with updated title and/or content.
    • Updates the article in the database.
  3. Delete an Article:

    • Endpoint: DELETE /api/articles/{id}
    • Deletes the article from the database by its ID.
    • Confirms deletion with a success message in the response.
  4. View an Article:

    • Endpoint: GET /api/articles/{id}
    • Returns the full content of the article, including its metadata.
  5. List Articles:

    • Endpoint: GET /api/articles
    • Returns a paginated list of articles with their IDs, titles, and creation dates.
    • Supports query parameters for pagination (e.g., ?page=1&limit=3) and sorting (e.g., ?sort=date).

Extra Features

  1. Search Functionality:

    • Endpoint: GET /api/articles/search
    • Accepts query parameters q to filter articles by keywords in the title or content.
  2. Rate Limiting:

    • Implement rate limiting to prevent abuse of endpoints.

Additional Considerations

1. Security

  • Sanitize and validate all user inputs to prevent SQL injection and other vulnerabilities.
  • Use Laravel's validation rules for input validation.
  • Implement token-based authentication (e.g., Laravel Sanctum) for secure access to create, edit, and delete operations.

2. Code Structure and Readability

  • Follow Laravel’s conventions for controllers, models, and routes.
  • Write clean, modular, and well-documented code.
  • Ensure your variable and function names are descriptive and in English.

3. Performance

  • Optimize database queries using Eloquent’s advanced features, such as eager loading.
  • Use caching strategies for frequently accessed data (e.g., Laravel Cache).

Framework-Specific Suggestions

  • Use Laravel’s Resource Classes to transform API responses.
  • Use Route Model Binding to simplify fetching models in your controllers.
  • Take advantage of Laravel’s built-in pagination for listing articles.

Running the Application

We recommend using Docker to simplify the setup of your Laravel application and MySQL database. If you're familiar with Docker, set up containers for Laravel and MySQL for ease of development and testing.


Thank you for participating in this assessment. We look forward to reviewing your work!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published