This project aims to solve the challenge of identity reconciliation for customers making purchases with different contact information on an e-commerce platform. The platform can identify and track customer identities across multiple purchases, even if different emails and phone numbers are used.
- Identify and consolidate customer contact information.
- Link multiple contacts to a primary contact.
- Ensure a personalized customer experience by tracking loyal customers.
The contact information is stored in a relational database table named Contact
:
{
id Int,
phoneNumber String?,
email String?,
linkedId Int?, // the ID of another Contact linked to this one
linkPrecedence "secondary" | "primary", // "primary" if it's the first Contact
createdAt DateTime,
updatedAt DateTime,
deletedAt DateTime?
}
The /identify
endpoint receives HTTP POST requests with a JSON body containing either or both of the following fields:
{
"email": "string",
"phoneNumber": "number"
}
The endpoint returns an HTTP 200 response with a JSON payload containing the consolidated contact information:
{
"contact": {
"primaryContactId": "number",
"emails": ["string"], // first element being email of primary contact
"phoneNumbers": ["string"], // first element being phoneNumber of primary contact
"secondaryContactIds": ["number"] // Array of all Contact IDs that are "secondary"
}
}
{
"email": "mcfly@hillvalley.edu",
"phoneNumber": "123456"
}
{
"contact": {
"primaryContactId": 1,
"emails": ["lorraine@hillvalley.edu", "mcfly@hillvalley.edu"],
"phoneNumbers": ["123456"],
"secondaryContactIds": [23]
}
}
If there are no existing contacts matching the incoming request, a new Contact
row is created with linkPrecedence="primary"
.
If an incoming request has either a phone number or email common to an existing contact but contains new information, a new secondary
Contact row is created and linked to the primary contact.
If a new contact links two existing contacts, one of them will become a secondary
contact. The database will update accordingly.
- Database: My SQL
- Backend Framework: Node.js with TypeScript
The application is hosted online, and the endpoint can be accessed at: https://identity-reconciliation-wjcz.onrender.com/identify
[POST Request]
- Clone the repository from GitHub.
- Install dependencies using
npm install
. - Set up your database and configure the connection settings.
- Run the application using
npm start
.