Giter Site home page Giter Site logo

loan_calculator-backend's Introduction

LOAN CALCULATOR

Loan Calculator is a Java-based backend project that handles loan calculations based on user input from the Loan Calculator frontend application. It exposes RESTful APIs for receiving loan details, performing calculations, and providing Equated Monthly Instalment (EMI) information.

(EMI) is getting calculated based on below formula

$𝐸𝑀𝐼 = \frac{(𝑃 π‘₯ 𝑅 π‘₯ (1 + 𝑅)^N )}{((1 + 𝑅)^N βˆ’ 1)}$

  • β€œP” is the loan amount
  • β€œN” is tenure in months
  • β€œR” is the monthly interest rate.

Project Structure

The project follows the Maven standard directory structure. Key components include:

  • src/main/java: Contains the Java source code.
  • src/main/resources: Contains application properties and configurations.
  • src/test: Contains test classes.

Getting Started

To run the project locally, follow these steps:

  1. Ensure that Java 17 is installed on your machine. You can download it from here.
  2. Clone this repository:
    git clone https://github.com/MURATKAYMAZ56/loan_calculator-backend.git
  1. Navigate to the project directory:
    cd loan_calculator-backend
  1. Build the project:
    ./mvnw clean install
  1. Run the application:
    ./mvnw spring-boot:run
  1. The backend application will be accesiable at http://localhost:8080

Integration with Loan Calculator Frontend application

Loan Calculate backend is designed to work seamlessly with the Loan Calculate frontend React application. The integration is achieved through RESTful APIs. The frontend sends loan details to backend, and backend responds with calculated EMI information.

You can either run frontend project by following its configuration steps or use postman as below to calculate emi.

Making API Calls via Postman

You can use Postman to make API calls to the backend. Follow these steps:

  1. Open Postman and create a new request.

  2. Set the request type to POST.

  3. Enter the API endpoint: http://localhost:8080/api/loans

  4. Set the request headers: Content-Type: application/json

  5. In the request body, provide a JSON payload with loan details. For example:

{
  "amount": 1000,
  "instalment": 11,
  "interestRate": 2.4,
  "email": "[email protected]"
}


  1. Click the "Send" button to make the API call. Then you should see api response as below.
{
    "emi": 231.11
}
  1. Review the response in H2 console (See below for H2 console) to see the calculated EMI information.

Accessing H2 Console

The Loan Calculator backend uses an H2 in-memory database, and you can access the H2 Console to view and query the data.

  1. Open your browser and go to http://localhost:8080/h2-console.
  2. In the login page, set the following values:
    JDBC URL: jdbc:h2:mem:testdb
    User Name: sa
    Password: pwd

3.Click the "Connect" button. 4. You will be redirected to the H2 Console. Here, you can view and execute SQL queries against the in-memory database. 5. To see data Click on LOAN_ENTITY table and run below script

    SELECT * FROM LOAN_ENTITY 

Running Tests

To run tests, execute the following command:

    ./mvnw test

loan_calculator-backend's People

Contributors

muratkaymaz56 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.