Skip to content

A backend service for intelligent identity reconciliation using email and phone numbers. Built with Node.js, Express, Prisma, and MySQL โ€” designed to deduplicate user records and return consolidated contact information. ๐Ÿš€

Notifications You must be signed in to change notification settings

bharani-coder-27/Identity-Reconciliation-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ” Identity Reconciliation Backend

This backend service helps intelligently reconcile user identities (email & phone number) to identify whether multiple contact records belong to the same person.


๐Ÿš€ Features

  • Match users by email, phone number, or both
  • Automatically merges multiple identities
  • Handles complex overlap scenarios (merge logic)
  • Returns consolidated contact info
  • Organized in clean architecture: routes, controllers, services, models

๐Ÿง  Use Case

Suppose a user (like "Doc") uses different emails and phone numbers while placing orders. This service ensures all those contacts are reconciled and linked to a single primary identity.


๐Ÿงฐ Tech Stack

Layer Tech Used
Language Node.js (ES Modules)
Framework Express
ORM Prisma
Database PostgreSQL
Dev Tools Nodemon, dotenv
API Testing Postman
Folder Design MVC-style architecture

๐Ÿ“ Folder Structure

identity-reconciliation-backend/
โ”œโ”€โ”€ prisma/                 # Prisma schema and DB migrations
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ controllers/        # Route handlers
โ”‚   โ”œโ”€โ”€ routes/             # Express route definitions
โ”‚   โ”œโ”€โ”€ services/           # Core logic (merge & insert)
โ”‚   โ”œโ”€โ”€ models/             # Prisma client config
โ”‚   โ””โ”€โ”€ index.js            # Entry point
โ”œโ”€โ”€ .env                    # Environment variables (not committed)
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ README.md

โš™๏ธ Setup Instructions

โœ… Prerequisites


๐Ÿงช Step-by-Step Setup

1๏ธโƒฃ Clone the Repository

git clone https://github.com/bharani-coder-27/Identity-Reconciliation-Backend
cd identity-reconciliation-backend

2๏ธโƒฃ Install Dependencies

npm install

3๏ธโƒฃ Configure .env

Create a file named .env in the root directory:

DATABASE_URL="postgresql://<username>:<password>@localhost:5432/<your_database>"
PORT=3000

Replace <username>, <password>, and <your_database> with your PostgreSQL credentials.


4๏ธโƒฃ Run Database Migration

This will create the Contact table in your DB:

npx prisma migrate dev --name init

5๏ธโƒฃ Start the Server

npm run dev

๐Ÿ“ Server will run at: http://localhost:3000


๐Ÿ“ฎ API Endpoint

๐Ÿ”น POST /identify

โœ… Request Example

{
  "email": "doc@example.com",
  "phoneNumber": "1234567890"
}

๐Ÿ” Response Example

{
  "primaryContactId": 1,
  "emails": ["doc@example.com", "doc@x.com"],
  "phoneNumbers": ["1234567890", "9876543210"],
  "secondaryContactIds": [2, 3]
}
```

---

## ๐Ÿงช Testing the API

You can test the API using:

- [Postman](https://www.postman.com/)
- [Thunder Client](https://www.thunderclient.com/) (VS Code extension)

---

## โœ… Bonus Tips

- Use `npx prisma studio` to open Prisma GUI and manage data.
- Use seed scripts to insert test cases.
- Add more endpoints like `/contacts`, `/delete`, etc. for admin access.

---

## โœ๏ธ Author

**Bharanidharan G**  
[GitHub](https://github.com/bharani-coder-27)

---

## ๐Ÿ“„ License

This project is open-source under the MIT License.


## ๐Ÿ”– Tags

`Node.js` `Express` `Prisma` `PostgreSQL` `Backend API` `Identity Resolution` `REST API`

About

A backend service for intelligent identity reconciliation using email and phone numbers. Built with Node.js, Express, Prisma, and MySQL โ€” designed to deduplicate user records and return consolidated contact information. ๐Ÿš€

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published