Work

Email JSON Extracter API - Project Showcase

NestJS
Jest
E2E Testing
Hexagonal Architecture
Microservices-Ready

My Email JSON Extracter API utilizes email templates uploaded to the server to extract the JSON information attached to those emails and return it to the user. Built with NestJS and following hexagonal architecture, it's a robust solution for email parsing needs.

NestJS.jpg

📧 Email JSON Extractor 🔍

🎥 Quick Video Demo

Check out this short video rundown of the project: Email JSON Extractor Demo

🚀 Features

  • 📎 Extract JSON from email attachments
  • 🔗 Parse JSON from links in email body
  • 🌐 Fetch and parse JSON from webpage links found in emails
  • 🛡️ Robust error handling and logging

🏗️ Architecture

This project uses a hexagonal architecture (also known as ports and adapters) to separate concerns and improve maintainability. The architecture is divided into three main layers:

  1. Domain 🧠: Contains business logic and entities
  2. Application 🖥️: Houses use cases and DTOs
  3. Infrastructure 🏗️: Implements adapters for external services and repositories

🤔 Why Hexagonal Architecture?

  1. Separation of concerns 🧩: Business logic is isolated from external dependencies.
  2. Testability 🧪: Core business logic can be tested without external dependencies.
  3. Flexibility 🤸: Easy to swap out external implementations.
  4. Maintainability 🔧: Changes in one layer don’t affect others.

🔗 Relation to Microservices

While this project is a monolithic application, its hexagonal architecture makes it well-suited for potential migration to a microservices architecture:

  1. Clear boundaries 🧱: Easy extraction of functionalities into separate services.
  2. Dependency inversion 🔄: Use of interfaces (ports) for easy adaptation across services.
  3. Scalability 📈: Individual components can be scaled independently.

🚀 Running the Application

To start the application in development mode:

  1. yarn install
  2. yarn start:dev

🧪 Testing

To run the tests:

  1. yarn test:e2e
  2. yarn jest

📚 API Documentation

Parse Email Endpoint

  • GET /email-parser/parse
  • Query Parameters:
    • path: The path to the email file to be parsed.
  • Example Request:
    GET /email-parser/parse?path=test/test_attachment.eml
  • Example Response:
    {
      "jsonContent": {
        "name": "John Doe",
        "age": 30,
        "city": "New York"
      }
    }

🙏 Acknowledgments

Special thanks to the NestJS community for their support and resources. You rock! 🎸

Stay tuned for more updates and features! 🚀