This project implements an achievement system in Laravel, designed to track user activities like writing comments and watching lessons. Using an event-driven approach and the repository design pattern, the system provides a robust, scalable, and modular architecture. Additional features include Docker support via Laravel Sail and an integrated mail service.
- Achievement Tracking: Monitors user activities and unlocks achievements based on predefined criteria.
- Badge System: Awards badges to users based on the number of achievements unlocked.
- Event-Driven Architecture: Utilizes Laravel events to handle achievement unlocking and badge awarding.
- Repository Design Pattern: Offers flexibility and modularity, making future expansions more manageable.
- Docker Support: Simplifies local setup and ensures consistency across different environments using Laravel Sail.
- Mail Service Integration: Verifies that mail-related events are triggered and handled correctly.
- Docker and Docker Compose
- PHP >= 8.0
- Composer
-
Clone the Repository:
git clone https://github.com/your-repository-url.git cd your-repository-directory -
Start Laravel Sail: Laravel Sail is a light-weight command-line interface for interacting with Laravel's default Docker development environment. To start the Docker containers for the application, run:
./vendor/bin/sail up
-
Install Dependencies: While the Docker container is running, install the PHP dependencies:
./vendor/bin/sail composer install
-
Run Migrations: Set up the database by running the migrations:
./vendor/bin/sail artisan migrate
-
Seed the Database (Optional): Populate the database with initial data (if seeders are provided):
./vendor/bin/sail artisan db:seed --class=SEEDERCLASSNAME
-
Access the Application: The application should now be running on
http://localhost.
To ensure the reliability of the application, a suite of tests has been provided. Run these tests to verify that all components of the system are functioning as expected:
./vendor/bin/sail artisan test- AchievementUnlocked Event: Fired when a user unlocks an achievement. Payload includes
achievement_nameanduser. - BadgeUnlocked Event: Fired when a user earns a new badge. Payload includes
badge_nameanduser.
- GET
users/{user}/achievements: Returns user achievements and badges, including:unlocked_achievements: Array of unlocked achievements by name.next_available_achievements: Next achievable milestones.current_badge: User's current badge.next_badge: Next badge achievable.remaining_to_unlock_next_badge: Achievements needed for the next badge.
- Integrated mail notifications confirm the correct functioning of achievement-related events.
- Enhances maintainability and scalability.
- Facilitates collaborative development.
- Ensures a consistent development environment.
- Simplifies the setup process.
This project adheres to best practices in Laravel development, offering a robust and scalable solution for achievement tracking.