Trade Simulator: APIGateway


    This component mainly uses to handle in and out API requests. Trade Simulator has a front-end component to handle the back-end properties. That front-end component does not use by traders who are going to trade. I will explain that component in another article later. To develop the APIGateway component I used Java and Spring Boot. Here I wrote a set of controllers to handle API requests to navigate to other components.  Also, provide user authentication and user validation part.

Trade Simulator: AuthService

    From this component, I used to handle user registration and user logging. Java, Spring Boot, H2 database, and Kafka were used to develop this component. Hibernate was used to store. update and retrieve data from the database. 
    
     H2 is a relational database management system written in Java. It can be embedded in a Java application or run in client-server mode. In my case, H2 was embedded in a Java application. Also, hibernate is a Java framework that simplifies the development of Java applications to interact with the database. It is an open-source, lightweight, ORM (Object Relational Mapping) tool. An ORM tool simplifies data creation, data manipulation, and data access. It is a programming technique that maps the object to the data stored in the database. The ORM tool internally uses the JDBC API to interact with the database.

    Hibernate implements the specifications of JPA (Java Persistence API) for data persistence. JPA provides certain functionality and is slandered to ORM tools. 

Advantages of Hibernate Framework

1. Fast Performance

    Using the cache is internal, making the hibernate framework faster. Use a first-level and second-level cache in hibernate; among them, the first-level cache is enabled by default.

2. Database Independent Query

    HQL (Hibernate Query Language) is the object-oriented version of SQL (Structured Query Language). It generates the database independent queries.

3. Automatic Table Creation

    Hibernate framework provides the facility to create the tables of the database automatically.

4. Simplifies Complex Join

    Fetching data from multiple tables is easy in hibernate framework.

5. Provides Query Statistics and Database Status

    Hibernate supports Query cache and provides statistics about query and database status.

6. Open Source and Lightweight

The Hibernate architecture is categorized into four layers.
    1. Java application layer
    2. Hibernate framework layer
    3. Backend API layer
    4. Database layer

Spring Boot JPA

    Spring Boot JPA is a Java specification for mapping relational data in Java applications. It allows us to access and persist data between Java object/class and relational database. JPA follows ORM. It is a set of interfaces. It also provides a runtime EntityManager API for processing queries and transactions on the objects against the database. It uses a platform-independent object-oriented query language JPQL (Java Persistent Query Language).

    JPA is simpler, cleaner, and less labor-intensive than JDBC, SQL, and hand-written mapping. JPA is suitable for non-performance-oriented complex applications. The main advantage of JPA over JDBC is that, in JPA, data is represented by objects and classes while JDBC data is represented by tables and records. It uses POJO to represent persistent data that simplifies database programming.

This is the end of today's article, I will come back with more details in another article.