Identity Reconciliation is an Express-based API designed to consolidate contact information for customers of FluxKart.com. It allows you to unify customer data even when they use different email addresses or phone numbers during their purchases.
- Clone the repository from GitHub.
- Install the required dependencies by running the following command in the project directory:
npm install
To get the API up and running, follow these steps:
- Ensure you have Node.js and npm installed on your system.
- Create a
.env
file in the root directory of the project and define the following environment variables:PORT=5000 DB_USERNAME=your_database_username DB_PASSWORD=your_database_password DB_HOST=your_database_host DB_NAME=your_database_name
- Replace
your_database_username
,your_database_password
,your_database_host
, andyour_database_name
with your actual database credentials. - Start the server by running the following command:
npm start
- The server will start running on
http://localhost:3000
(or on the specified port in the.env
file).
config/
: Contains the database connection configuration (db.js
).model/
: Defines the database model for theContact
entity.routes/
: Contains the API route handlers, specificallyidentifyRoutes.js
.index.js
: The main entry point of the application.
This project uses a relational database to store contact information. The database credentials are provided via environment variables in the .env
file.
The Contact
model in model/contactModel.js
represents the structure of the contacts
table in the database.
URL: http://localhost:3000/api/identify
Endpoint URL: http://localhost:3000/api/identify Method: POST
{
"email": "jisu@gmail.com",
"phoneNumber": "123456789"
}
The response will be in the following format:
{
"contact": {
"primaryContatctId": 1,
"emails": [
"jisu@gmail.com"
],
"phoneNumbers": [
"123456789"
],
"secondaryContactIds": []
}
}
{
"email": "jisu@gmail.com",
"phoneNumber": "8609124483"
}
{
"contact": {
"primaryContatctId": 1,
"emails": [
"jisu@gmail.com",
"jisu@gmail.com"
],
"phoneNumbers": [
"123456789",
"8609124483"
],
"secondaryContactIds": [
2
]
}
}