This is a Gradle project and Intellij IDEA was used for the development purpose.
This project is a Spring Boot application having different endpoints to perform following operations:
- Create a contact record
- Retrieve a contact record
- Update a contact record
- Delete a contact record
- Search for a record by email or phone number
- Retrieve all records from the same state or city
H2 in-memory database is used to store contact records. DDL for CONTACT_INFO table is present in "ContactAPI\src\main\resources\db\schema.sql".
API Specification can be access over "http://localhost:8080/swagger-ui.html" link when application is running. API specification is generated using Swagger API.
Some of important classes description
- ContactApiApplication is the Spring Boot config class,
- ContactController is the controller class with endpoint,
- DataSourceConfig is H2 database config class
- ContactAPIExecptionProcessor handles any exception thrown by application
- ContactService in the business layer interface and ContactServiceImpl is the implementing class
- ContactRepo is the data access layer interface and ContactRepoImpl is the implementing class
- ContactRepoHelper contains all SQL queries
- Contact and Address are the domain object classes
Run the below command:
- java -jar contactapi-1.0.0-RC.war
- From IDE, run the main() method of the ContactApiApplication class
It will start the application on localhost at 8080 port.
Hit "http://localhost:8080/swagger-ui.html" to access the application's swagger documentation. On clicking "contact-conroller" option, it will open application specification along with sample test data. Click on "try it out" of respective endpoints to test the application functionality, clicking "execute" button will perform the action.