Giter VIP home page Giter VIP logo

bitespeed-backend's Introduction

Bitespeed Backend Task: Identity Reconciliation

This project involves creating a web service for FluxKart.com to identify and link multiple customer contacts using Bitespeed. The service should help track customers who use different contact information across multiple purchases.

Overview

FluxKart.com wants to reward loyal customers by linking different orders made with different contact information to the same person. Bitespeed collects contact details and stores them in a relational database table named Contact.

Tech-stack

**Database: Any SQL database can be used **Backend framework: NodeJs with typescript is preferred but any other framework can also be used.

Requirements

  • Design a web service with an endpoint /identify that will receive HTTP POST requests with JSON body containing email and/or phoneNumber.
  • The service should return the consolidated contact information.

Design

  1. Database Table: Contact

    • id: Unique identifier for each contact.
    • phoneNumber: Phone number of the contact.
    • email: Email address of the contact.
    • linkedId: ID of another contact linked to this one.
    • linkPrecedence: Indicates if the contact is "primary" or "secondary".
    • createdAt: Timestamp when the contact was created.
    • updatedAt: Timestamp when the contact was last updated.
    • deletedAt: Timestamp when the contact was deleted.
  2. API Endpoint: /identify

    • Accepts a POST request with email and/or phoneNumber.
    • Returns the consolidated contact information.

Implementation

Database Schema

Here's the SQL schema for the Contact table:

CREATE TABLE Contact (
    id INT PRIMARY KEY AUTO_INCREMENT,
    phoneNumber VARCHAR(15),
    email VARCHAR(255),
    linkedId INT,
    linkPrecedence ENUM('primary', 'secondary'),
    createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
    updatedAt DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    deletedAt DATETIME
);

API Endpoint

The /identify endpoint will process the incoming request and return the consolidated contact information.

Request:

{
    "email": "[email protected]",
    "phoneNumber": "1234567890"
}

Response:

{
    "contact": {
        "primaryContactId": 1,
        "emails": ["[email protected]", "[email protected]"],
        "phoneNumbers": ["1234567890"],
        "secondaryContactIds": [2, 3]
    }
}

Setup and Run

Prerequisites

  • Node.js
  • SQL Database (e.g., MySQL, PostgreSQL)

Steps

  1. Clone the repository:
git clone https://github.com/Mamta-bisht0522/Bitespeed-Backend.git

2. **Install dependencies:**

```bash
npm install
  1. Configure the database:

Update the database configuration in config/database.js.

  1. Start the server:
npm start

The server will start on http://localhost:3000.

Testing

To test the endpoint, you can use tools like Postman or CURL.

Example CURL request:

curl -X POST http://localhost:3000/identify \
-H "Content-Type: application/json" \
-d '{
    "email": "[email protected]",
    "phoneNumber": "1234567890"
}'

Conclusion

This service enables FluxKart.com to track and link customer identities across multiple purchases, enhancing their customer experience and loyalty rewards program. The design ensures that contacts are linked efficiently and accurately, with the ability to handle new information dynamically.

bitespeed-backend's People

Contributors

mamta-bisht0522 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.