This service manages user contact information by linking multiple email and phone combinations to a single user identity. It provides a /identify endpoint that consolidates and retrieves associated contact information.
- Create new primary and secondary contact entries.
- Link multiple email and phone numbers.
- Seamlessly transform primary contacts into secondary when new data overlaps.
- Error handling with meaningful responses.
- Spring Boot
- Java
- MongoDB
- Clone the repository:
git clone <repository-url> cd emotorad_spring
- Set up the necessary environment variables in
application.properties:server.port=8080 spring.data.mongodb.uri=mongodb+srv://<username>:<password>@cluster.mongodb.net/dbname
- Build the application:
./mvnw clean install
- Run the application:
java -jar target/contact-management-service-0.0.1-SNAPSHOT.jar
{
"email": "user@example.com",
"phone": "1234567890",
"product": "Product Name"
}{
"primaryContactId": "60f7b2c5e3b1a9cde0e6b77d",
"contactPairs": [
{ "email": "user@example.com", "phone": "1234567890" }
],
"secondaryContactIds": ["60f7b2c5e3b1a9cde0e6b77e"],
"createdAt": "2025-01-07T10:30:00Z",
"updatedAt": "2025-01-07T10:30:00Z",
"deletedAt": null
}The application can be deployed using any cloud service that supports Spring Boot applications. A typical deployment approach is to use Docker for containerization.
- Create a
Dockerfile:FROM openjdk:17-jdk-slim ARG JAR_FILE=target/contact-management-service-0.0.1-SNAPSHOT.jar COPY ${JAR_FILE} app.jar ENTRYPOINT ["java", "-jar", "/app.jar"]
- Build the Docker image:
docker build -t contact-management-service . - Run the Docker container:
docker run -p 8080:8080 contact-management-service
- Run unit tests using Maven:
./mvnw test