Coder Social home page Coder Social logo

sammsulhoq / mailsync-engine Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 24 KB

A core system for an email client with essential functionalities. This system will connect with user email accounts (initially focusing on Outlook) and manage email data efficiently.

Dockerfile 4.96% TypeScript 95.04%

mailsync-engine's Introduction

MailSync Engine

MailSync Engine is a backend application that synchronizes email data from Outlook using OAuth2 authentication and stores it in MongoDB. The application is built with TypeScript, Node.js, and Express, and uses Docker for containerization.

Features

  • OAuth2 authentication with Outlook.
  • Synchronizes email data from Outlook to MongoDB.
  • RESTful API endpoints for authentication and email synchronization.

Requirements

  • Node.js
  • Docker
  • Docker Compose
  • Outlook OAuth2 credentials

Setup and Installation

1. Setup

Clone the repo from the following:

git clone https://github.com/sammsulhoq/mailsync-engine
cd mailsync-engine

Create a .env file in the root directory with the following content:

PORT=5000
OUTLOOK_CLIENT_ID=your_outlook_client_id
OUTLOOK_CLIENT_SECRET=your_outlook_client_secret
CALLBACK_URL=http://localhost:5000/api/auth/callback
MONGO_URI=mongodb://mongo:27017/mailsync

Replace your_outlook_client_id and your_outlook_client_secret with your actual Outlook OAuth client ID and client secret.

2. Build and Start the Application

Use Docker Compose to build and start the application:

docker-compose up --build

This command will:

  • Build the Node.js application and compile TypeScript files.
  • Start the Node.js application and MongoDB services.

3. Access the Application

Once the containers are up and running, you can access the application at http://localhost:5000

API Endpoints

1. POST /api/auth/login

Initiates the OAuth2 login process and generates a URL for users to log in with their Outlook account.

POST /api/auth/login

Response: Redirects to the Outlook login page.

2. GET /api/auth/callback

Handles the callback from Outlook after a successful login, saves user details and access token, and returns a JSON response.

GET /api/auth/callback?code=<auth_code>

Response:

{
  "message": "Authentication successful",
  "user": {
    "email": "[email protected]",
    "outlookId": "outlook_id",
    "localId": "local_id"
  }
}

3. POST /api/sync/emails

Synchronizes email data from Outlook to the local MongoDB database for the authenticated user.

Request:

POST /api/sync/emails
{
  "userId": "local_user_id"
}

Response:

200 OK
Email data synchronized successfully

Running Locally

If you prefer running the application locally without Docker, follow these steps:

  • Install Dependencies: npm install
  • Compile TypeScript: npm run build
  • Start Application: npm start

Make sure you have a running MongoDB instance and update the MONGO_URI in the .env file accordingly.

Testing the Application

You can use tools like Postman or cURL to test the API endpoints.

mailsync-engine's People

Contributors

sammsulhoq avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.