Skip to content

bharatagra1607/campaign-app

Repository files navigation

Email Campaign Application

This project is a mini email campaign application designed to simplify the process of creating and managing email campaigns. Users can sign up, log in, create campaigns, upload CSV files with contact details, and send bulk emails using their uploaded HTML templates. The system is optimized for performance, using Laravel's queue system to handle large batches of emails efficiently and notifies the user at various stages of the campaign.

Features

  • User Authentication: Secure user authentication powered by Laravel Breeze, allowing users to sign up and log in.
  • Campaign Creation: Users can create email campaigns by assigning a category and selecting an email template.
  • CSV Upload for Bulk Emails: Users can upload a CSV file containing email addresses and related contact details, which are validated before being stored in the database.
  • Custom HTML Templates: Users can upload their custom HTML email templates, ensuring each campaign is tailored to their specific needs.
  • Campaign Progress and Notifications: The system notifies users upon completion of each stage, including CSV file validation, bulk email storage, and campaign execution.
  • Queue System for Email Delivery: Laravel Queues are used to efficiently process email campaigns in chunks, ensuring smooth handling of large datasets.
  • Real-Time Notifications: Pusher is integrated for real-time notifications, keeping users informed about the status of their campaigns.
  • Reports: Users can access detailed statistics on the number of successfully sent emails as well as any failed deliveries, ensuring clear insights into the overall performance of their campaigns.

Built With

  • Frontend: Vue.js 3, PrimeVue (for UI components), Tailwind CSS (for styling)
  • Backend: PHP 8.1+ and Laravel 10
  • Database: MySQL
  • State Management: Pinia
  • Notifications: Pusher
  • Queue Management: Laravel Queues
  • Authentication: Laravel Breeze

Installation

To set up the project locally, follow these instructions:

Prerequisites

Ensure you have the following installed on your system:

  • Composer
  • PHP 8.1+
  • MySQL
  • Node.js (v18.12.1 or higher)
  • npm
  • Laravel Installer

Setup Instructions

  1. Clone the repository:

    git clone https://github.com/bharatagra1607/campaign-app.git
    cd campaign-app
  2. Install PHP dependencies:

    composer install
  3. Install JavaScript dependencies:

    npm install
  4. Set up environment variables:

    Copy the provided .env.example to a new .env file:

    cp .env.example .env

    Configure your .env file with your database and email server settings:

    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=campaign_app
    DB_USERNAME=root
    DB_PASSWORD=
    
    MAIL_MAILER=smtp
    MAIL_HOST=smtp.mailtrap.io
    MAIL_PORT=2525
    MAIL_USERNAME=null
    MAIL_PASSWORD=null
    MAIL_ENCRYPTION=null
  5. Generate the application key:

    php artisan key:generate
  6. Run database migrations:

    Set up the database schema by running:

    php artisan migrate
  7. Create symbolic links for file storage:

    This links your storage folder to public/storage:

    php artisan storage:link
  8. Run the application:

    Start the Laravel development server:

    php artisan serve
  9. Build frontend assets:

    Build and compile the Vue.js frontend for development or production:

    • For development:

      npm run dev
    • For production:

      npm run build
  10. Run WebSockets server:

    To handle real-time notifications with Pusher:

    php artisan websockets:serve
  11. Queue Setup:

    Start the Laravel Queue worker to process email jobs:

    php artisan queue:listen
  12. Optional commands for permissions and optimization:

    Ensure correct file permissions and optimize the application:

    chmod -R 775 ./storage
    chmod -R 775 ./bootstrap/cache
    chmod -R 775 ./public
    php artisan optimize:clear

Usage

1. User Registration & Login

  • Register an account or log in using Laravel Breeze's built-in authentication.

2. Create a Category

  • Before creating a campaign, users must create a category that will be associated with the uploaded email list.

3. Upload Emails via CSV

  • Upload a CSV file containing the necessary fields (name, email, etc.). The system validates the CSV file for proper formatting and content before storing the emails in the database.

4. Upload an HTML Email Template

  • Upload a custom HTML template that will be used to send the emails.

5. Create a Campaign

  • Create a campaign by specifying the campaign name and associating it with a category and an email template.

6. CSV Validation

  • Upon uploading, the CSV file undergoes validation. If validation fails, you will be notified of the errors.

7. Save Emails to Database

  • Once validated, the emails from the CSV file are automatically saved to the database in bulk, and you will receive a notification when the process is complete.

8. Campaign Processing

  • Campaigns are processed in chunks using Laravel's queue system to ensure scalability. Users receive notifications at different stages of the campaign.

9. Notifications

  • Get notified about the following:
    • CSV validation failures or successes
    • Completion of email storage in the database
    • Campaign status, including how many emails were successfully sent and how many failed.

Project Structure

The project follows Laravel's standard structure, with some Vue.js integration for the frontend:

/campaign-app
├── app/                 # Contains application logic (models, controllers, services)
├── bootstrap/           # Bootstrap files for Laravel
├── config/              # Configuration files
├── database/            # Database migrations and seeders
├── public/              # Public-facing files
├── resources/           # Views, emails, and frontend assets
├── routes/              # API and web routes
├── tests/               # Unit and feature tests
├── node_modules/        # npm dependencies
├── webpack.mix.js       # Laravel Mix for frontend asset compilation
└── vendor/              # Composer dependencies

Testing

To ensure the system works correctly, unit and feature tests are provided. To run the tests, execute:

vendor/bin/pest

or

vendor/bin/phpunit

Contributing

Contributions are welcome! Please adhere to SOLID principles and ensure that all code changes are well-documented and thoroughly tested. To contribute:

  1. Fork the repository.
  2. Create a new feature branch.
  3. Submit a pull request with your changes.

License

This project is licensed under the MIT License - see the LICENSE file for more details.


This version provides a deeper overview and adds more detailed steps for setting up, using, and maintaining the application. Let me know if you need further modifications!