Skip to content

susanta09/Insurance_Policy_Management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Insurance Management API


Index

  1. Problem
  2. Tools and Resources
  3. Models/Entities
  4. Entities RelationShip
  5. Sample code For Relation
  6. DTO and Validation Code Sample
  7. File Structure of Project
  8. Access the Functionalities
  9. Features of Project
  10. How to Run Local Server
  11. Use Postman(API testing)
  12. My Details

Problem :-


Assignment:- Create an Insurance Management Platform with Spring Boot and Java .

Objective:- Build an insurance management platform that allows users to manage insurance policies, clients, and claims using Spring Boot and Java.

Tools and Resources:-


  • Java 8, Spring Web, Spring Data JPA, Rest API, Spring Boot version 2.7.10 .
  • Spring Initializr (https://start.spring.io/), STS(Spring Tool Suite), MySQL Server(SQLyog), Postman and Windows .
  • Spring-boot Maven Dependencies:-
    • spring-boot-starter-data-jpa
    • spring-boot-starter-validation
    • spring-boot-starter-web
    • mysql-connector-j
    • spring-boot-starter-test

Models/Entities :-


As par Project requirement we take three Entities which are given below---
  1. Client Entity
    1. Name (Property)
    2. Date Of Birth (Property)
    3. Address (Property)
    4. contact information (Property)
  2. Insurance Policy Entity
    1. policy number (Property)
    2. type (Property)
    3. coverage amount (Property)
    4. premium (Property)
    5. start date (Property)
    6. end date (Property)
  3. Claim Entity
    1. claim number (Property)
    2. description (Property)
    3. claim date (Property)
    4. claim status (Property)

Entities RelationShip


In project i created two relationship----
  1. I build the relationship Many To Many relationship between Claim Entity and Insurance Policy Entity because A Client have many Insurance Policy and Insurance Policy have many Client.
  2. And another relationship which is build between Insurance Policy Entity and Claim Entity.The relationship is Many to One relationship because of a policy can have many claim in different stages.

I showing the image of relationship of entities:--

relationship

Sample code For Relation


//==================InsurancePolicy==========
@Entity
public class InsurancePolicy {
	@Id
	@GeneratedValue
	private Integer policy_No;
	private String policy_Type;
	private Double Coverage_Amount;
	private Double premium;
	private String start_Time;
	private String end_Time;
	
	@OneToMany(targetEntity = Claim.class,cascade = CascadeType.REMOVE)
	@JoinColumn(name = "policy_No" )
	private List<Claim> claims;
	
	@ManyToMany(cascade = CascadeType.ALL)
	@JoinTable(
			name = "policy_addTo_Client",
			joinColumns = {@JoinColumn(name="policy_No")},
			inverseJoinColumns = {@JoinColumn(name="client_No")}
			)
	private List<Client> clients;
}
//================== Client =================
@Entity
@Table(name = "client")
public class Client {
	@Id
	@GeneratedValue
	private Long client_No;
	private String name;
	private String dob;
	private String phoneNo;
	@Embedded
	private Address address;
	@ManyToMany(cascade = CascadeType.ALL)
	@JoinTable(
			name = "policy_addTo_Client",
			joinColumns = {@JoinColumn(name="client_No")},
			inverseJoinColumns = {@JoinColumn(name="policy_No")}
			)
	private List<InsurancePolicy> policy;
}
//=================== Address ===============
@Embeddable
public class Address {
	private String city;
	private String state;
	private String country;
}
//==================== Claim ================
@Entity
public class Claim {
	@Id
	private Integer claim_No;
	private String description;
	private String claim_Date;
	private String claim_Status;
}

DTO and Validation Code Sample


//==================== Claim dto ================
public class Claim_dto {
	@NotNull(message = "claim_No your claim it not be null")
	private Integer claim_No;
	@NotNull(message = "Plese describe your claim it not be null")
	private String description;
	@NotNull
	@Pattern(regexp = "^(3[01]|[12][0-9]|00|0[1-9])/(1[0-2]|00|0[1-9])/([0-9]{4})$",message = "date formate dd/mm/yy")
	private String claim_Date;
	@NotNull(message = "status can not be null")
	private String claim_Status;
}
//================== Client ================
public class Client_dto {
	private Long client_Id;
	@NotNull(message = "name can not be null")
	@Pattern(regexp = "^[A-Z][a-z]+\\W[A-Z][a-z]+$",
			  message ="First letter of String Must be capital.Take a space between two string")
	private String name;
	@NotNull(message = "date of birth can not be null")
	@Pattern(regexp = "^(3[01]|[12][0-9]|00|0[1-9])/(1[0-2]|00|0[1-9])/([0-9]{4})$",
			  message = "date formate dd/mm/yy")
	private String dob;
	@NotNull(message = "Phone number can not be null")
	@Pattern(regexp = "^(0|91)?[7-9][0-9]{9}$",
			  message ="Enter the valid phone number.first 0 or 91 optional but actual number must be 10 digits" )
	private String phoneNo;
	
	@NotNull(message = "Address can not be null")
	@Valid
	private Address address;
	private List<Integer> policy_No;
}
//==================InsurancePolicy==========
public class InsurancePolicy_dto {
	private Integer policy_No;
	@NotEmpty(message ="policy_Type can not be null")
	private String policy_Type;
	@NotNull(message = "Coverage_Amount can not be null")
	private Double Coverage_Amount;
	@NotNull(message = "premium can not be null")
	private Double premium;
	@NotNull
	@Pattern(regexp = "^(3[01]|[12][0-9]|00|0[1-9])/(1[0-2]|00|0[1-9])/([0-9]{4})$",message = "valid date in valid formate dd/mm/yy")
	private String start_Time;
	@NotNull
	@Pattern(regexp = "^(3[01]|[12][0-9]|00|0[1-9])/(1[0-2]|00|0[1-9])/([0-9]{4})$",message = "valid date in valid formate dd/mm/yy")
	private String end_Time;
	private List<Integer> claimsN;
}

File Structure of Project


Project Folder Structure is given below-----

Screenshot (411)

Screenshot (413)

Access the Functionalities


  • For Client :-
Link url
POST http://localhost:9090/api/clients
GET http://localhost:9090/api/clients
GET http://localhost:9090/api/clients/{id}
UPDATE http://localhost:9090/api/clients/{id}
DELETE http://localhost:9090/api/clients/{id}
  • For Insurance Policy :-
Link url
POST http://localhost:9090/api/policies
GET http://localhost:9090/api/policies
GET http://localhost:9090/api/policies/{id}
UPDATE http://localhost:9090/api/policies/{id}
DELETE http://localhost:9090/api/policies/{id}
  • For Claim :-
Link url
POST http://localhost:9090/api/claims
GET http://localhost:9090/api/claims
GET http://localhost:9090/api/claims/{id}
UPDATE http://localhost:9090/api/claims/{id}
DELETE http://localhost:9090/api/claims/{id}

Features of Project


The main Features of that project Data
Integrity Exception Handling and Data validation

How to Run Local Server


  1. Goto my GitHub link--" https://github.com/susanta09/Insurance_Policy_Management.git"
  2. Then goto code Option then click.
  3. then click Download ZIP for download ZIP file for Project.
  4. Create a folder with any name Extract the downloaded ZIP file.
  5. Open STS tool and import the file insurance_policy
  6. Open Mysql server (SQLyog or MySQL Workbench) And create "apolicy" database.
    spring.datasource.url=jdbc:mysql://localhost:3306/apolicy
    
  7. Then goto the project and open resources file .
  8. open the application.properties file and chang the username and password as par your mysql server
  9. also provide unique port number
    spring.datasource.username=root
    spring.datasource.password=admin
    server.port=9090
    

Note:- Problem: If get error like----- error Solution: Then you must be add tomcat-embed-jasper dependency

	  <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>provided</scope>
    </dependency>

Use Postman(API testing)


Here i provide structure of entities in Json formate for working in Postman tool.

  • Json Client :-
{
    "client_Id": 3,
    "name": "Susanta Barman",
    "dob": "23/07/2009",
    "phoneNo": "8768316572",
    "address": {
        "city": "herosima",
        "state": "cocoham",
        "country": "japan"
    },
    "policy_No": []
}
  • json for Insurance policy :-
 {
        "policy_No": 1,
        "policy_Type": "type1",
        "premium": 3000,
        "start_Time": "23/09/2000",
        "end_Time": "21/03/2014",
        "claimsN": [],
        "coverage_Amount": 15000
    }
  • json for claim
 {
        "claim_No": 1005,
        "description": "hghghj",
        "claim_Date": "10/08/2005",
        "claim_Status": "not clear"
    }

I provide few sample Postman Screenshot images--- Screenshot (423) Screenshot (424) Screenshot (425) Screenshot (427) Screenshot (428) Screenshot (429) Screenshot (430) Screenshot (432)

My Details


Name:- Susanta Barman

Email:- ssbarmant107@gmail.com Phone No:- 8768316572

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages