Campaign Tool Backend

Project Setup

Prerequisites

  • Docker
  • Docker Compose
  • Git

Tech Stack

  • Laravel 11.x
  • MySQL

Entity Relationship Diagram

---
title: Campaign Management Tool ERD
---
erDiagram
    User ||--o{ Campaign : creates
    Campaign ||--o{ Payout : has
    
    User {
        id integer PK
        name varchar
        email varchar
        password varchar
        remember_token varchar
        email_verified_at timestamp
        created_at timestamp
        updated_at timestamp
    }
    Campaign {
        id integer PK
        user_id integer FK
        title varchar
        landing_page_url varchar
        activity_status enum
        created_at timestamp
        updated_at timestamp
    }
    Payout {
        id integer PK
        campaign_id integer FK
        country enum
        payout_value decimal
        created_at timestamp
        updated_at timestamp
    }
Loading

Setup Instructions

  1. Clone the repository then navigate to the project directory
cd campaign-tool-backend
  1. Create environment file
cp .env.example .env
  1. Start the application
docker compose up -d
  1. Install dependencies using Docker
docker compose exec laravel.test composer install
  1. Generate application key
docker compose exec laravel.test php artisan key:generate
  1. Run database migrations
docker compose exec laravel.test php artisan migrate
  1. Restart docker containers
docker compose restart

Now if you open the browser and navigate to http://localhost/api, you should see {"message":"Hello World"}

Project was setup using Laravel Sail After initial intall you can start using sail commands as well

./vendor/bin/sail up
./vendor/bin/sail down
./vendor/bin/sail logs -f
./vendor/bin/sail artisan <command>
./vendor/bin/sail composer <command>
./vendor/bin/sail artisan test
./vendor/bin/sail down --volumes --rmi all

You can add seed data by running the following command

./vendor/bin/sail artisan db:seed

Available Services

Useful Commands

# Start application
docker compose up -d

# Stop application
docker compose down

# View logs
docker compose logs -f

# Run artisan commands
docker compose exec laravel.test php artisan <command>

# Run composer commands
docker compose exec laravel.test composer <command>

# Run tests
docker compose exec laravel.test php artisan test

# Clean all containers and volumes (useful for fresh start)
docker compose down --volumes --rmi all

Development

The application code is mounted into the container, so any changes you make to your local files will be reflected immediately in the container.

Testing

Run tests using the following command:

docker compose exec laravel.test php artisan test

or

./vendor/bin/sail artisan test