This is a Spring Boot-based Referral System API that uses MongoDB as the database. It provides functionalities for user registration, referral tracking, and user profile management.
- Backend: Spring Boot, Java
- Database: MongoDB
- Frameworks/Libraries: Spring Data MongoDB, Spring Web
- Tools: Maven
| HTTP Method | Endpoint | Description |
|---|---|---|
GET |
/track |
Fetch successful and pending users of a particular referral code of a particular user |
GET |
/download |
Download all referrals as a CSV file |
| HTTP Method | Endpoint | Description |
|---|---|---|
POST |
/sign-up |
Create a new user with an optional referral code and also verify the provided referral code is valid or not and generate new referral entry in referral table |
GET |
/login |
Log in a user |
GET |
/logout |
Log out the current user |
| HTTP Method | Endpoint | Description |
|---|---|---|
POST |
/new |
Create a user profile and update referral records accordingly |
User: Represents a user entity.Referral: Tracks referrals and their statuses.UserProfile: Stores user profile details.
UserInterface: Handles user-related operations.ReferralInterface: Manages referral logic.UserProfileInterface: Manages user profiles.
UserSession: Maintains user session data such as user's object id and have functionality to set and clear user's object id data from system.
Ensure you have the following installed:
- Java 17+
- Maven
- MongoDB
- Clone the repository
git clone https://github.com/Samratakgec/referralAPI.git cd referralAPI - Run Mongo db
Run following command in cmd (open it as administrator)
mongod --dbpath "C:\data\db" - Run Server Navigate to referralAPI\src\main\java\com\samrat\referralAPI and run ReferralApiApplication.java. file
This document provides example request bodies for testing the Referral API using Postman.
{
"email" : "abc@gmail.com",
"password" : "sbc",
"refGain" : "67e4f199bb0b6959a5b0f2e3"
}{
"email" : "abc@gmail.com",
"password" : "sbc"
}{
"name" : "Samrat" ,
"phoneNumber" : "920887423",
"bio" : "i am a Java backend developer"
}GET http://localhost:8080/api/referral/download
Make sure to hit this endpoint in a browser, so the CSV file gets downloaded to your system.