GithubHelp home page GithubHelp logo

spring-boot-project's Introduction

Spring Boot Project ๐Ÿ‹

โœจ Intro

This application is built to order the investment products

๐Ÿš€ Built with

  • Spring Boot 2.6.0
  • Java 8
  • H2
  • JPA
  • Maven
  • Junit5

๐Ÿ“ฆ Structure

Entity

  • Product
fields : productId, title, totalInvestmentAmt, currentInvestmentAmt, noOfInvestors, status,  startAt, finishAt
  • Order
fields : orderId, userId, productId, title, totalInvestmentAmt, investAmt, createdAt

CRUD API Operations

1. Product
  • Create : Create a Product
  • Get : Fetch Product details
  • Get : Fetch Product details for a specific duration
2. Order
  • Create : Create an Order ๐Ÿšจ HTTP Header : 'X-User-ID'
  • Get : Fetch Order details for a given User ๐Ÿšจ HTTP Header : 'X-User-ID'

๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป Example of Usage

In this project, a sample data set is already included in H2 database

INSERT INTO Product(product_id, title, total_investment_amt, current_investment_amt, no_of_investors, status, start_at, finish_at) VALUES (1, 'annuity', 1000, 100, 10, true, '2021-01-01', '2021-12-31')
INSERT INTO Product(product_id, title, total_investment_amt, current_investment_amt, no_of_investors, status, start_at, finish_at) VALUES (2, 'bond', 2000, 500, 20, true, '2021-05-01', '2021-12-31')
INSERT INTO Product(product_id, title, total_investment_amt, current_investment_amt, no_of_investors, status, start_at, finish_at) VALUES (3, 'saving bond', 5000, 2000, 5, false, '2021-03-01', '2021-05-01')
...

1. Search all the investment products

curl --location --request GET 'http://localhost:8080/api/products/'

2. Order an investment product

curl --location --request POST 'http://localhost:8080/api/order/' \
--header 'X-USER-ID: 1' \
--header 'Content-Type: application/json' \
--data-raw '{
    "productId": "1",
    "investAmt": 100
}'

3. Find my investment orders

curl --location --request GET 'http://localhost:8080/api/order/' \
--header 'X-USER-ID: 1'

๐Ÿค” Thoughts

When a number of users are trying to order investment products at the same time, a huge bottleneck could be an issue about accessing data and reliability of the system.

Synchronized methods is being used as an implicit lock to allow only one thread to execute at any given time. Therefore, when multiple threads executing simultaenously, and access the same resource at the same time, thread-safe can be acheived to resolve inconsistency problems by allowing only one thread at a time.

spring-boot-project's People

Contributors

doyunbk 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.