This repository serves as a task submission at BiteSpeed (Backend). The task involves creating an API for identifying and reconciling customer identities across multiple purchases. The API utilizes Node.js with Express framework for backend development, PostgreSQL for database management, and Docker for containerization.
To set up and run the API locally, follow these steps:
- Clone this repository to your local machine.
- Ensure you have Docker installed.
- Navigate to the root directory of the project.
- Create a
.env
file in the root directory and configure the environment variables based on the providedsampleEnv
file. - Run
docker-compose up
to start the PostgreSQL database and database migrations. - Run
npm install
to install the necessary dependencies. - Run
npm start
to start the API server.
The .env
file contains environment variables used by the application, including database connection details and other configurations.
The API utilizes a PostgreSQL database to store contact information. Database migrations are managed using Flyway.
The docker-compose.yml
file defines the services required for running the application, including the PostgreSQL database and Flyway for handling database migrations.
Once the API server is running, you can interact with it by sending HTTP requests to the defined routes. The API provides endpoints for identity reconciliation and health checks.
- URL:
https://identity-reconciliation-api.mcking.in/identity
- Method: POST
- Description: Identifies and reconciles customer identity based on provided email and phone number.
- Request Body:
{ "email": "lorraine@hillvalley.edu", "phoneNumber": "123456" }
- Response:
{ "contact": { "primaryContactId": "1", "emails": ["lorraine@hillvalley.edu"], "phoneNumbers": ["123456"], "secondaryContactIds": [] } }
- Request Body:
{ "email": "mcfly@hillvalley.edu", "phoneNumber": "123456" }
- Response:
{ "contact": { "primaryContactId": 1, "emails": ["lorraine@hillvalley.edu","mcfly@hillvalley.edu"] "phoneNumbers": ["123456"] "secondaryContactIds": [2] } }
- URL:
https://identity-reconciliation-api.mcking.in/healthcheck
- Method: GET
- Description: Verifies the health status of the API server.
This project is hosted on identity-reconciliation-api.mcking.in.