An open API service indexing awesome lists of open source software.

https://github.com/souzafcharles/invest-portfolio-microservices

๐Ÿ— Demonstration of Microservices with RabbitMQ (Includes CloudAMQP) managing investment portfolios in the financial sector
https://github.com/souzafcharles/invest-portfolio-microservices

cloudamqp jpa jpa-hibernate microservices postgresql rabbitmq rabbitmq-consumer rabbitmq-producer spring spring-boot spring-mvc spring-web sql

Last synced: 2 months ago
JSON representation

๐Ÿ— Demonstration of Microservices with RabbitMQ (Includes CloudAMQP) managing investment portfolios in the financial sector

Awesome Lists containing this project

README

        

![GitHub language count](https://img.shields.io/github/languages/count/souzafcharles/Invest-Portfolio-Microservices)
![GitHub top language](https://img.shields.io/github/languages/top/souzafcharles/Invest-Portfolio-Microservices)
![GitHub](https://img.shields.io/github/license/souzafcharles/Invest-Portfolio-Microservices)
![GitHub last commit](https://img.shields.io/github/last-commit/souzafcharles/Invest-Portfolio-Microservices)

# Demonstration of Microservices with RabbitMQ (Includes CloudAMQP) managing investment portfolios in the financial sector

## System Overview:


This report presents the development of a distributed system designed to manage investment portfolios in the financial industry. The system is comprised of two independent microservicesโ€”Portfolio and Processโ€”developed using the Java Spring framework. It facilitates the creation, organisation, and processing of portfolios, ensuring scalability and modularity through event-driven communication powered by RabbitMQ. By leveraging key technologies, such as Spring Boot, Spring Data JPA, and MongoDB, the architecture ensures robustness, efficiency, and flexibility for financial operations.


The Portfolio microservice serves as the backbone of the application, handling the creation and persistence of portfolio entities in a PostgreSQL database. Each portfolio, represented by the Portfolio class, consists of a title and an associated list of assets. These assets, defined by the Asset class, contain details such as name and quantity, capturing the composition of the investment portfolio with precision. This microservice exposes RESTful endpoints for portfolio management and incorporates message brokering capabilities. Upon portfolio creation, it serialises relevant data into JSON format and publishes it to the messaging queue configured in RabbitMQ, utilising the Jackson2JsonMessageConverter.


The Process microservice complements the Portfolio microservice by consuming messages asynchronously from the RabbitMQ queue. It listens for incoming portfolio data, deserialises it into PortfolioRequestDTO, and processes the information as required. The architecture ensures loose coupling between the microservices, enhancing scalability and maintainability. The Process microservice is equipped with a MongoDB database connection, supporting further operations or storage needs.


This distributed system harnesses the advantages of the Java Spring framework and event-driven design to offer an efficient solution for managing investment portfolios. With its modular architecture, the system is built to ensure high reliability, extensibility, and seamless integration with financial systems. The inclusion of PostgreSQL for persistent portfolio storage and MongoDB for dynamic processing demonstrates the strategic choice of technologies for scalability and performance. The RabbitMQ messaging broker serves as the linchpin for communication between microservices, supporting asynchronous processing and enhancing overall system reliability.

***
## Project Microservice Architecture:

![Microservice Architecture](https://github.com/souzafcharles/Invest-Portfolio-Microservices/blob/main/Microservice-Architecture.png)

The architecture comprises the following key components:

* **Client Apps:**
* Represents client devices (e.g., desktops, mobile phones) that interact with the system via the Portfolio API.

* [Portfolio Microservice:](https://github.com/souzafcharles/Invest-Portfolio-Microservices/tree/main/portfolio)
* Provides RESTful APIs for creating, retrieving, and managing investment portfolios;
* Stores portfolio and asset data in a PostgreSQL database;
* Publishes portfolio creation events to RabbitMQ for asynchronous processing;
* Operates on port 8081.

* **RabbitMQ (Broker):**
* Serves as the messaging broker for communication between microservices;
* Includes an exchange (`exchange.process`) to route messages to the appropriate queue;
* Manages a queue (`portfolio.process.queue`) to hold messages for processing.

* [Process Microservice:](https://github.com/souzafcharles/Invest-Portfolio-Microservices/tree/main/process)
* Consumes messages from the RabbitMQ queue asynchronously;
* Deserialises messages into `PortfolioRequestDTO` for processing;
* Operates on port 8082;
* Connects to MongoDB for dynamic storage and further operations.

* **Persistence and Messaging:**
* Utilises PostgreSQL for storing persistent portfolio data in the Portfolio microservice;
* Utilises MongoDB for dynamic storage in the Process microservice;
* RabbitMQ enables decoupled, event-driven communication between the Portfolio and Process microservices.

* **Technology Stack:**
* Employs the Java Spring framework, incorporating Spring Boot, Spring Data JPA, and RabbitMQ integration;
* Utilises Jackson2JsonMessageConverter to serialise and deserialise JSON messages seamlessly.

## Project Stack:

| Technology | Version | Description |
|-------------------|------------|----------------------------------------------------------------------------------|
| ๐Ÿ“ IntelliJ IDEA | `2024.3` | Integrated Development Environment (IDE) |
| โ˜• Java | `21` | Backend programming language |
| ๐ŸŒฑ Spring Boot | `3.4.4` | Framework for creating Spring applications |
| ๐Ÿฆ Maven | `3.9.9` | Build automation and dependency management tool |
| ๐Ÿ˜ PostgreSQL | `15.4` | Open-source relational database management system used in Portfolio Microservice |
| ๐Ÿƒ MongoDB | `8.0` | NoSQL document-oriented database used in Process Microservice |
| ๐Ÿ‡ RabbitMQ | `3.12.1` | Open-source message broker used for asynchronous communication |
| โ˜๏ธ CloudAMQP | `4.0` | Hosted RabbitMQ service (via CloudAMQP) used for asynchronous message brokering |
| ๐Ÿ‘ฉโ€๐Ÿš€ Postman | `11.19` | API testing and development tool |

***

## Dependencies:

| Dependency | Category | Description |
|--------------------------------------|------------------|---------------------------------------------------------------------------------------------|
| ๐ŸŒ Spring Web | Web | Builds web applications, including RESTful APIs using Spring MVC |
| ๐Ÿ’พ Spring Data JPA | SQL | Simplifies database interactions using JPA with Spring Data and Hibernate |
| ๐Ÿ˜ PostgreSQL Driver | SQL | Provides connectivity between Java applications and PostgreSQL databases |
| ๐Ÿƒ Spring Data MongoDB | NoSQL | Integrates with MongoDB, enabling reactive as well as blocking data access |
| ๐Ÿ‡ Spring AMQP | Messaging | Provides integration with RabbitMQ for message-driven architecture; utilised with CloudAMQP |
| ๐Ÿ› ๏ธ Spring Boot Devtools | Developer Tools | Offers development-time tools for application restart and debugging |