This backend service helps intelligently reconcile user identities (email & phone number) to identify whether multiple contact records belong to the same person.
- 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 
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.
| 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 | 
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
- Node.js installed
 - PostgreSQL installed
 - pgAdmin (optional GUI for DB)
 - GitHub account
 
git clone https://github.com/bharani-coder-27/Identity-Reconciliation-Backend
cd identity-reconciliation-backendnpm installCreate a file named .env in the root directory:
DATABASE_URL="postgresql://<username>:<password>@localhost:5432/<your_database>"
PORT=3000Replace
<username>,<password>, and<your_database>with your PostgreSQL credentials.
This will create the Contact table in your DB:
npx prisma migrate dev --name initnpm run dev๐ Server will run at: http://localhost:3000
{
  "email": "doc@example.com",
  "phoneNumber": "1234567890"
}{
  "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`