Your task is to continue, and possibly complete, a partially built Laravel application.
The application models marketing campaigns for restaurant brands. Each campaign has data related to Impressions, Interactions, and Conversions.
Currently, the application has a campaign index page that lists all campaigns, but it has some missing functionality:
- It should be possible to filter by Brand using the Brand dropdown.
- It should be possible to sort and order each of the columns by clicking them (or the arrows).
- The table should show the number of Impressions, Interactions and Conversions in their associated columns.
- The number of impressions, interactions and conversions should be correct for the date range filtered (default is last 7 days).
- The page should load be performant and load quickly, regardless of page, filters and sorting.
Your task is to enhance this page to rectify these issues and ensure that the page is performant and loads quickly.
- You will be working with three main models: Impression, Interaction, and Conversion. Each of these is associated with both a Campaign and a Brand.
- The application will be seeded with the following data:
- 10 Restaurant Brands
- 10 Campaigns per brand
- Each campaign will have:
- Several hundred thousand Impressions over 30 days
- About ~27,000 Interactions over 30 days
- About ~2,700 Conversions over 30 days
- The list view should include the following columns:
- Campaign Name
- Brand Name
- Impressions
- Interactions
- Conversions
- Conversion Rate (calculated as Conversions ÷ Interactions)
- The view should be optimised to handle large datasets efficiently, even with filters and ordering applied.
- Code Quality: Is the code well-organised and easy to understand?
- Performance: Does the view load in under 300ms when filtered and sorted?
- Functionality: Does the application meet the requirements, including filtering, ordering, and date range adjustment?
- Best Practices: Are Laravel and PHP best practices followed (e.g., query optimisation, use of Eloquent relationships, Blade templating, Unit/Integration/E2E Testing)?
- Docker: Ensure that Docker is installed and running on your system.
- Composer: Ensure Composer is installed (https://getcomposer.org/).
-
Fork & Clone the repository:
git clone <repository_url> cd <repository_directory>
-
Install dependencies:
composer install
-
Setup environment variables: Copy the
.env.examplefile and create a new.envfile.cp .env.example .env
-
Update .env: Set up the necessary environment variables such as database connection and Laravel Sail settings.
-
Start Laravel Sail:
./vendor/bin/sail up
-
Generate an application key:
./vendor/bin/sail artisan key:generate
-
Run the database migrations:
./vendor/bin/sail artisan migrate
-
Seed the database: The seeder will populate the database with 10 restaurant brands, each with 10 campaigns, along with impressions, interactions, and conversions data.
This will take some time due to the large volume of data being generated. Approximately 10 minutes. Boil the kettle and make a cup of tea or coffee while you wait. If you're feeling adventurous, you can try to optimise the seeder to run faster.
./vendor/bin/sail artisan db:seed
-
Access the application: Once the Sail container is running, you should be able to access the application at
http://localhost.
-
Functional Requirements:
- The Blade view should be able to display all campaigns with correct metrics.
- The list should update based on the selected date range and restaurant brand filter.
- The data should be sortable by Campaign Name, Brand Name, Impressions, Interactions, Conversions, and Conversion Rate.
- The number of Impressions, Interactions, and Conversions should be correct for the date range filtered.
- The Conversion Rate should be calculated as Conversions ÷ Impressions.
- The view should be optimised to handle large datasets efficiently.
-
Performance:
- The view should load in less than 300ms despite the large dataset.
- Optimised querying and indexing strategies should be implemented where necessary.
-
Code Review:
- We will review your code for clarity, structure, and adherence to Laravel best practices.
- Efficient use of Eloquent, relationships, and query optimisation will be critical.
-
Bonus Points:
- Regular commits with clear commit messages, demonstrating your thought process and approach.
- Any additional improvements that enhance the performance or functionality beyond the brief will be appreciated.
-
Submission:
- Once you have completed the task, please commit your changes and push them to a forked repository and share the link with us.
- We'll then arrange a follow-up call to discuss your solution and answer any questions you may have.
- The Sail install includes Redis, feel free to use it for caching or any other purpose.
- The database is seeded with a large volume of data, so you may need to optimise your queries and indexing strategies.
Good luck, and happy coding!
