This is an project to show the use of Angular 19, Spring Boot 3, H2/Postgresql with Jpa, Liquibase, Kafka and Gradle and a Helm chart for a Kubernetes deployment. The frontend uses D3 for charts. For dynamic queries the frontend uses Drag'n Drop and the Backend Jpa Criteria api and the frontend displays the results in Table/Tree Angular components.
Author: Sven Loesekann
Technologies: Angular, Angular-Cli, Angular-Material, Typescript, Spring Boot, Java, Spring Data Jpa, ArchUnit, Liquibase, Gradle, Docker, H2, Postgresql, Apache Kafka, Tink
The goal is to provide a Portfolio Management Application to compare different portfolios for there quality over time. It is an Angular based Web App with a Jpa backend server. The build tool is Gradle. Apache Kafka can be used for scalable Jwt token revokation.
The project can now serve as an example of howto integrate Angular and Spring Boot with Gradle as a build tool.
The current state of the project is that a multi user portfolio management is implemented and is ready for use.
The project has a System Context Diagram, a Container Diagram and a Component Diagram. The Diagrams have been created with Structurizr. The file runStructurizr.sh contains the commands to use Structurizr and the directory structurizr contains the dsl file.
To use the Portfolio Manager 2 Apikeys are needed for the application and for each user to import the stock quotes and the company information.
That will enable the Portfolio Manager to import the stock quotes for the portfolio each user has to provide Alphavantage/RapidApi keys. The keys are stored with each user and enable the import/update of the quotes by multiple users of the application. The nightly quote import uses the keys to update the quotes.
The Portfolio Manager starts with a H2 in memory database that will lose its content with each application termination. To have persistent data in the database the postgresql support needs to be used. It is activated in the ‘prod’ profile and needs a local postgresql database or an available docker image of the database. The properties to setup the database access are in the application-prod.properties or the application-prod-kafka.properties.
To use the Portfolio Manager for Sec Filings analysis. The data has to be imported first. It can be downloaded(large download) here. Then the ‘path.financial-data=’ property in the application.properties file needs to point to a directory(like ‘/tmp/’) where the application can find/access the zip file. The downloaded file has to be copied in that directory. The Jupyter Notebook to create the data set can be found here.
The Portfolio Manage imports the stock symbols and comparision indexes every night. To trigger the import the ‘Import Symbols’ button in the header can be used. During the import a new Portfolio can be created. The portfolio elements can be added after the symbols import is finished.
The different portfolios are shown in a table with their stocks and perfomance data. A click on the portfolio name in the side bar opens the portfolio statistics component. A click on the table opens the portfolio details component with charts of the portfolio and its stocks with comparison indexes. The company info for each stock is shown after a second click on the portfolio stock.
The SEC Filings analysis can be opened with the ‘To Financial Data’ button. To import the zip file with the financial data the ‘Import Financials’ button can be used. A dialog opens and the name of the file can be entered and the import can be started. The process will take a long time(perhaps an hour but that depends on the Db version and the IO system) due to the large amount of data. The progress/finish is shown in the logs.
After the data import the form for the company query to select a period, symbol or quarter can be used. The items of the filings can be queried with the query items where the ‘concept’ is the query filing name(like ‘revenue’) and the value is the ‘concept’ monetary amount. By default the query items have an ‘and’ relation. Different relations are available if the query items are enclosed with ‘Term Start’ and ‘Term End’ items where ‘Term Start’ item specifies the relation. Adding and removing query items works with Drag and Drop between the boxes. Both queries can be combined.
The results are show next to the query in a table or in a tree component. The results are limited if a large amount of entries match the query. Due to the large amount of data the queries can take long (again depends on Db version and IO system). Be patient with the spinner.
The project has a Docker image that can be deployed on Kubernetes. It has been tested in Minikube. The Helm chart for the deployment can be found in the directory angularportfoliomgr. Commands for the Minikube setup can be found in the minikubeSetup.sh script. The commands for the Helm chart are in the helmCommand.sh script. The Keda install commands are in the helmCommand.sh script and the configuration is in the ‘ScaledObject’ section in the kubTemplate.yaml
The ‘angularportfoliomgr’ Helm chart will deploy Kafka, Zookeeper, Postgresql and the PortfolioMgr. Kafka is used to provide a horizontaly scalable secure logout. The Kafka usage will grow in the future for nightly quote imports and other distributed data. Zookeeper is deployed for Kafka. The Postgresql Database provides persistence for the AngularPortfolio project. Keda is used to provide horizontal scaling for the AngularPortfolioMgr.
The Spring Actuator interface with Prometheus interface can be used as it is described in this article:
Monitoring Spring Boot with Prometheus and Grafana
To test the setup the application has to be started and the Docker Images for Prometheus and Grafana have to be started and configured. The scripts ‘runGraphana.sh’ and ‘runPrometheus.sh’ can be used as a starting point.
A retired R2DBC backend implementation can be found in the R2DBC-Implementation branch.