This project implements the Identity Reconciliation Service
The service receives a user's email and/or phone number and identifies whether the contact already exists in the system. If multiple records belong to the same person, the system links them together and returns a consolidated identity response.
The API ensures that:
- Duplicate identities are merged
- The oldest contact remains the primary contact
- New information is stored as secondary contacts
- The response contains the full set of linked emails and phone numbers
Deployed on Render:
https://bitespeed-mt8n.onrender.com/identify
{
"email": "string | null",
"phoneNumber": "string | null"
}
At least one field must be provided.
POST /identify
Content-Type: application/json
{
"email": "lorraine@hillvalley.edu",
"phoneNumber": "123456"
}
{
"contact": {
"primaryContactId": 1,
"emails": [
"lorraine@hillvalley.edu",
"mcfly@hillvalley.edu"
],
"phoneNumbers": [
"123456",
"999999"
],
"secondaryContactIds": [2,3]
}
}
The service follows these rules:
- If no matching contacts exist, a new primary contact is created.
- If a matching email or phone number exists, the existing identity is used.
- If a request introduces new information, a secondary contact is created and linked to the primary.
- If two primary contacts later match, the oldest contact becomes the primary, and the other becomes secondary.
- The response returns the complete merged identity graph.
Contact table fields:
| Field | Description |
|---|---|
| id | Unique identifier |
| Email address | |
| phoneNumber | Phone number |
| linkedId | Points to primary contact if secondary |
| linkPrecedence | primary / secondary |
| createdAt | Contact creation timestamp |
| updatedAt | Last updated timestamp |
| deletedAt | Soft delete timestamp |
- Node.js
- Express.js
- TypeScript
- Prisma ORM
- SQLite (for development)
- Render (deployment)
src
├ controllers
│ identify.controller.ts
├ services
│ identity.services.ts
├ repositories
│ contact.repository.ts
├ routes
│ identify.routes.ts
├ utils
│ prisma.ts
│ responseBuilder.ts
└ server.ts
prisma
└ schema.prisma
The system correctly handles:
- Duplicate contact entries
- Multiple emails linked to the same phone
- Multiple phones linked to the same email
- Merging of two previously separate identities
- Requests with only email or only phone
The service is deployed on Render.
Live endpoint:
https://bitespeed-mt8n.onrender.com/identify
Harshil Aggarwal