🚀 Problem Statement given by Simplify Money For Software engineering inter[Great thanks for selecting me and shotlisting me for this opportunity]
***** Java Backend Assessment ***** Successful Referral [Note : For achiving scalability i have followed the best practice of Spring Boot, Leveraging the Java 8 features like streams and Lambda function are used in this project.]
Problem Description Create an API for user signup with referral code tracking, where a referral is considered successful only after the user completes their profile. For instance, if user A signs up using referral code of user B then successful referral is considered only after user A completes the profile. Expected Output -
- User Signup Endpoint -Allow signup with/without referral code -Generate unique referral code for each user -Validate referral code if provided
- Referral Tracking -Track referral status -Link referrer and referred user -Mark referral as complete upon profile completion
- API Endpoints -Signup API -Profile Completion API -Get Referrals API -Referral Report API (Bonus) Deployment Notes -Deploy on a public server -Share the GitHub repo -Share the curl request -Feel free to pick your choice of tools like NoSQL or SQL DB, choice of cloud provider etc
Coding Guidelines -Write clean, readable code -Add meaningful comments -Create comprehensive README
The Referral System API is a backend service built using Spring Boot and JPA that allows users to sign up using referral codes and track their successful referrals. The system considers a referral "successful" only when the referred user completes their profile.
- Java 17 / 21
- Spring Boot
- Spring Data JPA
- MySQL (or H2 for testing)
- Lombok
- Postman (for API testing)
- ✅ User Registration with Referral Code
- ✅ Check Successful Referrals
- ✅ Get Referral Report
- ✅ RESTful API Design
- ✅ Spring Data JPA Integration
git clone https://github.com/yourusername/referral-system.git
cd referral-systemModify application.properties in src/main/resources/:
spring.datasource.url=jdbc:mysql://localhost:3306/referral_db
spring.datasource.username=root
spring.datasource.password=yourpassword
spring.jpa.hibernate.ddl-auto=updatemvn spring-boot:run📌 POST /api/users/signup
{
"name": "John Doe",
"email": "john@example.com",
"password": "12345",
"referralCode": "abc123"
}{
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"referralCode": "abc123",
"profileCompleted": false
}📌 PUT /api/users/{userId}/complete-profile
{
"message": "Your Profile completed successfully"
}📌 GET /api/users/{userId}/referrals
[
{
"id": 2,
"name": "Jane Doe",
"email": "jane@example.com",
"referralCode": "xyz789",
"profileCompleted": true
}
]📌 GET /api/users/referral-report
[
{
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"referralCode": "abc123",
"successfulReferrals": 1
}
]referral-system/
├── src/main/java/com/backendllm/project/
│ ├── controller/UserController.java
│ ├── entity/User.java
│ ├── repository/UserRepository.java
│ ├── service/UserService.java
├── src/main/resources/application.properties
├── pom.xml
└── README.md
Contributions are welcome! To contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature-name) - Commit your changes (
git commit -m "Added new feature") - Push to GitHub (
git push origin feature-name) - Submit a Pull Request
This project is licensed under the MIT License.
🚀 Happy Coding!