Skip to content

jacobmind/email-parser

Repository files navigation

Backend Engineering Assessment – Submission

✔ What I Did

  • Connected to the provided MySQL emails database on the server
  • Built a Laravel app with:
    • Artisan command to parse emailraw_text (plain text only)
    • RESTful API (Store, Get, Update, Delete, List)
    • Token-based auth middleware
  • Parsing uses php-mime-mail-parser/php-mime-mail-parser (no external services)
  • Skips already processed rows
  • API and parsing logic tested and working

📂 Server Info

  • Project path: /var/www/html/email-parser
  • DB used: emails (loaded via successful_emails.sql)

How to install locally

  • I've prepared a Docker setup for local development. You can run the following command to start the containers:
    docker-compose up -d
  • Run the following command to install the dependencies:
    docker-compose exec app composer install
  • Copy the .env.example file to .env and set your database credentials:
      cp .env.example .env
  • Generate the application key:
    docker-compose exec app php artisan key:generate
  • Run the migrations:
      docker-compose exec app php artisan migrate
    • Create a user using php artisan tinker for API authentication:
      docker-compose exec app php artisan tinker
    $user = \App\Models\User::create([
    'name' => 'Your Name',
    'email' => 'your_email@example.com',
    'password' => bcrypt('your_password'),
    ]);
    echo $user->createToken('API Token')->plainTextToken;

🧪 How to Test

  • Run parser manually: php artisan emails:parse
  • API: use Authorization: Bearer {TOKEN} header
  • Create token by running php artisan tinker and executing the following:
    $user = \App\Models\User::find(1); // Replace 1 with the user ID
    echo $user->createToken('API Token')->plainTextToken;    
  • Use the token in your API requests. Select Bearer Token in Postman and paste the token in the field.

✅ To-Do List for Backend Engineering Assessment

Setup

  • Log into the server and verify database access
  • Clone project to /var/www/email-parser
  • Set up .env with correct DB credentials
  • Run composer install and php artisan key:generate

Email Parsing

  • Create emails:parse Artisan command
  • Use php-mime-mail-parser/php-mime-mail-parser to extract plain text
  • Strip HTML and headers
  • Keep only printable characters and \n
  • Skip already processed records
  • Limit batch size for safety
  • Test parsing on real data

Scheduler

  • Register the command
  • Run Laravel scheduler via schedule:work or cron

RESTful API

  • Create POST /api/emails to store and auto-parse
  • Create GET /api/emails/{id} to fetch by ID
  • Create PUT /api/emails/{id} to update
  • Create GET /api/emails to list
  • Create DELETE /api/emails/{id}
  • Add token-based authentication middleware

Finalization

  • Parse all existing unprocessed records
  • Write README with setup and API instructions
  • [ x Email submission with:
    • GitHub repo link
    • Server path: /var/www/html/email-parser
    • Confirmation that everything is working

✅ My Deployment Tasks

  • Import existing email data into the newly migrated Laravel database on the server
  • Ensure the imported data matches the structure expected by Laravel
  • Create a user using php artisan tinker for API authentication
  • Generate and assign an API token or notification key for the user
  • Set up and confirm that cron is running the parsing job on the server
  • Test the entire setup directly on the server to make sure everything works as expected

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages