This is a repository demonstrating a backend that is part of a full-stack survey application.
The goal of the survey is to ask for a user's basic information and what kind of loan they are interested in, and then saving that information into a database.
The database used here is a MySQL database. It has been hooked up with a Hibernate ORM, and all the database schemas, definitions, and tables are created programmatically.
An API is exposed with endpoints to access and create the database entities.
Features:
- High extensibility and maintainability.
- Error handling for API requests.
- Supported loan types and currencies defined as enums that are automatically synchronised with the database.
- DAO (Data Access Object), DTO (Data Transfer Object), controllers, converters, and Database model entities for every resource.
- Validation for loan applicants, loans, recurring expenses, and income sources.
- Install MySQL. Ensure that the MySQL service is running.
- Install Java 14. Ensure it has been added to your PATH.
- Install Maven. Ensure it has been added to your PATH.
- Create an
application.propertiesfile insrc/main/resourceswith the following information:- db.host: The host name of MySQL service that is running, e.g.
jdbc:mysql://localhost. - db.port: The port of the MySQL service that is running, e.g.
3306. - db.user: Your MySQL username, e.g.
root. - db.password: Your MySQL password, e.g.
1234. - db.name: The name of the database that will be created, e.g.
loans. - api.host: The host that the API will listen on, e.g.
localhost. - api.port: The port that the API will listen on, e.g.
8080.
- db.host: The host name of MySQL service that is running, e.g.
Example application.properties file:
# Database config
db.host=jdbc:mysql://localhost
db.port=3306
db.username=root
db.password=1234
db.name=loans
# API config
api.host=localhost
api.port=8080To run the application, run the following command in the terminal:
mvn install exec:javaTo ensure that it works, check the logs. An API log saying >> Listening on localhost:8080 (which will change depending
on what values were set in application.properties) indicates that the backend is up and running.
You can test the API using a tool such as Postman. Currently, the following endpoints are exposed:
GET /loanApplicantsGET /loanApplicants/:idPOST /loanApplicantsGET /loansGET /loans/:idPOST /loansGET /currenciesGET /loanTypes