FinVista-Nexus

Microservices - POC

MIT License

Stars
1
Committers
1

FinVista Nexus Bank Application

Microservices - POC


Technologies Used

  • MySQL
  • Java
  • Docker
  • Kubernetes
  • Kafka
  • Spring Boot
  • RabbitMQ
  • Maven
  • Docker Compose
  • REST API
  • Helm
  • Spring Cloud
  • Grafana
  • Swagger
  • OpenAPI
  • Eureka
  • Spring Cloud Gateway
  • Resilience4j
  • OpenTelemetry
  • OAuth2/OpenID Connect
  • KeyCloak (IAM)
  • Spring Security
  • Spring Cloud Functions
  • Spring Cloud Stream

Project Overview

The FinVista Nexus project is designed to be a scalable and resilient application, utilizing modern technologies to ensure high performance and reliability.

Database

We use MySQL as our primary database to store all persistent data.

Backend

Our backend services are written in Java and built with Spring Boot, leveraging Spring Cloud for service discovery, configuration, and more. Eureka is used for service registration and discovery.

Messaging and Streaming

For messaging, we use RabbitMQ, and for event streaming, we leverage Kafka.

Authentication and Authorization

The project uses OAuth2 for secure authentication and authorization.

Deployment and Containerization

All services are containerized using Docker and managed with Kubernetes. We also use Docker Compose for local development and testing.

API Documentation

APIs are documented using Swagger and OpenAPI for easy testing and integration.

Monitoring and Observability

For monitoring, we use Grafana along with OpenTelemetry for tracing. Resilience4j is implemented to ensure fault tolerance in our services.

API Gateway

Spring Cloud Gateway is used as the API Gateway to route requests to various microservices.

Deployment Tools

We utilize Helm for deploying applications on Kubernetes.


Maven Commands

  • To generate a jar inside target folder w/o running unit tests
mvn clean install -Dmaven.test.skip=true 
  • To run a spring-boot maven project using terminal
mvn spring-boot:run
  • To generate a docker image using BuildPacks (Packeto). No need of Dockerfile
mvn spring-boot:build-image 
  • To generate a docker image using Google Jib. No need of Dockerfile
mvn compile jib:dockerBuild 

Docker & Docker Compose Commands

Docker Commands

  • To generate the docker image using the Dockerfile created
docker build . -t devmayank8/finvistanexus-accounts:1.0.1-SNAPSHOT
  • To run a container with a particular name using that same docker image in detached mode
docker run -d --name fvn-accounts -p 8080:8080 devmayank8/finvistanexus-accounts:1.0.1-SNAPSHOT
  • To run a container with a particular name using that same docker image in detached & debug mode
docker run -d --name fvn-accounts -p 8080:8080 -p 5005:5005 devmayank8/finvistanexus-accounts:1.0.1-SNAPSHOT
docker run -d --name fvn-accounts -p 8090:8090 -p 5010:5010 devmayank8/finvistanexus-loans:1.0.1-SNAPSHOT
docker run -d --name fvn-accounts -p 9000:9000 -p 5015:5015 devmayank8/finvistanexus-cards:1.0.1-SNAPSHOT
  • To run RabbitMQ 3.13 container in detached mode using docker image and default credentials
docker run -d -it --rm --name fvn-rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.13-management
  • To run redis container in detached mode using docker image and default credentials
docker run -d --name fvn-redis -p 6379:6379 -d redis
  • To run Keycloak container in detached mode using docker with default values
docker run -d -p 7080:8080 --name fvn-keycloak -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:25.0.1 start-dev
  • To push the image to docker hub registry (make sure you are logged in using docker cli or docker desktop)
docker image push docker.io/devmayank8/finvistanexus-accounts:1.0.1-SNAPSHOT
  • To pull same the image from docker hub registry
docker pull devmayank8/finvistanexus-accounts:1.0.1-SNAPSHOT
  • To show all the running and stopped containers
docker ps -a
  • To login into the docker hub container registry
docker login -u <username>
  • To logout from the docker hub container registry
docker logout
  • To display the intermediate layers & cmds that were executed when building the image
docker history <image_name>
  • To remove a particular docker image
docker rm <image_id>
  • To follow the log output of a particular container
docker conatiner logs -f <container_id>
  • To open bash inside a running container
docker exec -it <container_name> bash
  • To inspect a particular container
docker conatiner inspect <container_id>
  • To show all the container statistics
docker container stats
  • To remove all the stopped containers
docker conatiner prune
  • To remove all the unused containers, volumes, networks and dangling images
docker system prune

Docker Compose Commands

  • To start the containers using a docker-compose.yml file
docker-compose up -d
  • To stop and delete the containers including volumes
docker-compose down -v
  • To stop the containers including volumes
docker-compose stop

Modifying Run/Debug Configurations using spring profiles

  • NOTE: Priority - CLI arguments > JVM options > Environment Variables

Using CLI Arguments

  • activating prod profile instead of default
--spring.profiles.active=prod
  • activating qa profile instead of default spring profile and changing the value of build.version
--spring.profiles.active=prod --build.version=2.0.1

Using JVM option of passing the arguments

  • activating qa profile instead of default spring profile and changing the value of build.version
-Dspring.profiles.active=qa -Dbuild.version=3.0.1

Using Environment variables

  • activating prod profile instead of default spring profile and changing the value of build.version
SPRING_PROFILES_ACTIVE=prod;BUILD.VERSION=5.1.0;

Apache benchmark cmd for load testing/rate limiter scenario

  • Making 10 requests, with 2 concurrent requests at the given url
ab -n 10 -c 2 -v 3 http://localhost:8072/fvnbank/cards/api/contact-info

Important Links

Setting Up Your Spring Boot Project

1. Create a Spring Boot Project

Kickstart your project using the Spring Initializr. This tool helps you generate a Spring Boot project with the necessary dependencies and configurations.

2. Essential Tools and Dependencies

Designing Your Application

3. Applying Design Patterns

  • DTO Pattern: Simplify data transfer across different parts of your application. Learn more about the DTO Pattern.

4. Mapping and Transformation

5. OpenAPI Integration

Document your APIs with ease using SpringDoc OpenAPI.

Containerization and Deployment

6. Docker and Containerization

7. Kubernetes

Deploy and manage your applications at scale.

Microservices and Messaging

8. Microservices Architecture

9. Messaging and Event-Driven Architecture

Monitoring and Observability

10. Metrics and Monitoring

11. Tracing and Observability

Security

12. Identity and Access Management

Advanced Topics and Best Practices

13. Twelve-Factor App Methodology

Follow modern best practices for building software-as-a-service apps.

14. Event Storming

Design your domain-driven applications efficiently.

Additional Resources

15. Package Management and Build Tools

16. Cloud Platforms

Deploy your applications to the cloud.

17. Service Mesh

Implement service mesh for better microservices management.