# ivangfr/spring-webflux-reactive-databases architecture

> Architecture diagram of the GitHub repository ivangfr/spring-webflux-reactive-databases, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ivangfr/spring-webflux-reactive-databases
- Repository: https://github.com/ivangfr/spring-webflux-reactive-databases

## Overview

##### Project Overview
- This is a full-stack reactive microservices application.
- It comprises distinct Spring Boot applications:
- product-api (managing products with MongoDB)
- customer-api (managing customers with Postgres)
- order-api (managing orders with Cassandra and orchestrating calls to customer-api and product-api)
- notification-api (managing notifications with MySQL)
- client-shell (a shell-based client that communicates with all the above APIs)
- The microservices communicate using REST (with WebClient and CompletableFuture in order-api) so that a composite view of an order includes additional data from customer-api and product-api.

##### Main Components and Their Relationships
a. APIs (Microservices):
- product-api: Exposes REST endpoints for product management; uses MongoDB.
- customer-api: Exposes REST endpoints for customer management; uses Postgres.
- order-api: Exposes REST endpoints for order management; uses Cassandra. Also aggregates data by making REST calls to customer-api and product-api.
- notification-api: Exposes REST endpoints for notifications; uses MySQL.
- client-shell: A command-line interface application that invokes commands to interact with the above APIs.
b. Databases:
- MongoDB for product-api.
- Postgres for customer-api.
- Cassandra for order-api.
- MySQL for notification-api.
c. Data Flow and Inter-Service Communication:
- The client-shell communicates with all the APIs to perform functions such as creating orders, fetching details, and creating notifications.
d. Infrastructure and Deployment:
- Use of Docker containerization; scripts exist to build Docker images and manage their lifecycle. While the focus may be on application architecture, you could add a deployment note about these containers.

##### Architectural Patterns & Technologies
- Microservices architecture with each service as an independent Spring Boot application.
- Usage of reactive programming (Spring WebFlux) on both client and server sides.
- Client-side shell (Spring Boot Shell) that provides a command interface.
- Key frameworks and tech include Spring Boot, Spring WebFlux, REST, various databases (MongoDB, Postgres, Cassandra, MySQL) and containerization with Docker.
- Integration pattern where order-api aggregates data from other services, using WebClient and CompletableFuture to asynchronously fetch additional information.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Service Layer
    subgraph "Service Layer"
        pApi["product-api (Spring Boot, MongoDB)"]:::service
        cApi["customer-api (Spring Boot, Postgres)"]:::service
        oApi["order-api (Spring Boot, Cassandra, Aggregates REST)"]:::service
        nApi["notification-api (Spring Boot, MySQL)"]:::service
        client["client-shell (Spring Boot Shell)"]:::service
    end

    %% Data Layer
    subgraph "Data Layer"
        mongo["MongoDB"]:::db
        post["Postgres"]:::db
        cass["Cassandra"]:::db
        mySQL["MySQL"]:::db
    end

    %% Docker Deployment
    subgraph "Docker Deployment"
        build["build-docker-images"]:::docker
        startApis["start-apis"]:::docker
        startShell["start-shell"]:::docker
        stopApis["stop-apis"]:::docker
        remove["remove-docker-images"]:::docker
    end

    %% Service to Database Connections
    pApi -->|"connects"| mongo
    cApi -->|"connects"| post
    oApi -->|"connects"| cass
    nApi -->|"connects"| mySQL

    %% Client-shell to APIs
    client -->|"calls"| pApi
    client -->|"calls"| cApi
    client -->|"calls"| oApi
    client -->|"calls"| nApi

    %% Order API asynchronous inter-service calls (data aggregation)
    oApi -.->|"asyncREST"| pApi
    oApi -.->|"asyncREST"| cApi

    %% Styles
    classDef service fill:#AEDFF7,stroke:#0066CC,stroke-width:2px;
    classDef db fill:#C2F0C2,stroke:#2F7D32,stroke-width:2px;
    classDef docker fill:#FFE599,stroke:#BF9000,stroke-width:2px;

    %% Click Events for Microservices and Docker Scripts
    click pApi "https://github.com/ivangfr/spring-webflux-reactive-databases/tree/master/product-api/"
    click cApi "https://github.com/ivangfr/spring-webflux-reactive-databases/tree/master/customer-api/"
    click oApi "https://github.com/ivangfr/spring-webflux-reactive-databases/tree/master/order-api/"
    click nApi "https://github.com/ivangfr/spring-webflux-reactive-databases/tree/master/notification-api/"
    click client "https://github.com/ivangfr/spring-webflux-reactive-databases/tree/master/client-shell/"
    click build "https://github.com/ivangfr/spring-webflux-reactive-databases/blob/master/build-docker-images.sh"
    click startApis "https://github.com/ivangfr/spring-webflux-reactive-databases/blob/master/start-apis.sh"
    click startShell "https://github.com/ivangfr/spring-webflux-reactive-databases/blob/master/start-shell.sh"
    click stopApis "https://github.com/ivangfr/spring-webflux-reactive-databases/blob/master/stop-apis.sh"
    click remove "https://github.com/ivangfr/spring-webflux-reactive-databases/blob/master/remove-docker-images.sh"
```
