Simple loyalty API for users, achievements, and badges.
- PHP
8.3+ - Composer
2+ - MySQL or MariaDB
git clone <your-repo-url>
cd loyalty-app
git checkout backendcomposer installcp .env.example .env
php artisan key:generateDefault .env values:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=loyalty_app
DB_USERNAME=root
DB_PASSWORD=Create the DB:
CREATE DATABASE loyalty_app CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;php artisan migrate --seedSeeded data includes:
- achievements
- badges
- users
php artisan serveAPI base URL: http://127.0.0.1:8000/api
-
GET /api/users
Paginated users, wrapped in Laravel resource response. -
POST /api/users/{user}/purchase
Request body:{ "amount": 1500 }Response:
201with{"data":[]}. -
GET /api/users/{user}/achievements
Response includes:unlocked_achievementsnext_available_achievementscurrent_badgenext_badgeremaining_to_unlock_next_badge