# bryan-arrivasplata-rojas/hub-cobranza-fineract-bian architecture

> Architecture diagram of the GitHub repository bryan-arrivasplata-rojas/hub-cobranza-fineract-bian, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian
- Repository: https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian

## Overview

Collection Hub is a Java/Spring WebFlux service that synchronizes loan repayment schedules from Apache Fineract into local, idempotent collection orders. The main workflow is: a user initiates synchronization through the API or demo UI; the service fetches loan schedules, filters installments by horizon and outstanding balance, updates a billing batch and orders, then exposes batch and order queries. PostgreSQL stores the Hub’s local records; Fineract remains the source of loan and repayment data. The UI’s internal request details and some persistence wiring were not sampled, so those links are documented or left unverified.

Main entry points: [`collection-hub/src/main/java/com/bank/collectionhub/service/CustomerBillingService.java`](https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/service/CustomerBillingService.java) (Billing workflow), [`collection-hub/src/main/java/com/bank/collectionhub/adapter/CustomerBillingController.java`](https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/adapter/CustomerBillingController.java) (Billing API), [`collection-hub/src/main/java/com/bank/collectionhub/adapter/BatchRepository.java`](https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/adapter/BatchRepository.java) (Batch repository), [`collection-hub/src/main/java/com/bank/collectionhub/adapter/OrderRepository.java`](https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/adapter/OrderRepository.java) (Order repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User access"]
  node_ui["Demo UI<br/>[index.html]"]
  node_api["Billing API"]
end

subgraph group_hub["Billing service"]
  node_service["Billing workflow"]
  node_client["Fineract client"]
  node_config["Fineract HTTP config"]
end

subgraph group_storage["Local persistence"]
  node_batchrepo["Batch repository"]
  node_orderrepo["Order repository"]
  node_batch["Billing batch<br/>[BillingBatch.java]"]
  node_order["Collection order"]
  node_status["Order status<br/>[OrderStatus.java]"]
  node_postgres[("Hub PostgreSQL")]
end

subgraph group_core["Loan system"]
  node_fineract["Apache Fineract"]
end

node_user(("Operator"))

node_user -->|"uses"| node_ui
node_user -->|"invokes"| node_api
node_ui -.->|"requests"| node_api
node_api -->|"delegates"| node_service
node_service -->|"fetches schedules"| node_client
node_client -->|"reads loan data"| node_fineract
node_config -->|"configures HTTP"| node_client
node_service -->|"saves batches"| node_batchrepo
node_service -->|"upserts and searches"| node_orderrepo
node_batchrepo -->|"persists"| node_batch
node_orderrepo -->|"persists"| node_order
node_service -->|"resolves state"| node_status
node_batchrepo -.->|"stores records"| node_postgres
node_orderrepo -.->|"stores records"| node_postgres
node_api -->|"returns results"| node_user

click node_ui "https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub-ui/index.html"
click node_api "https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/adapter/CustomerBillingController.java"
click node_service "https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/service/CustomerBillingService.java"
click node_client "https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/adapter/FineractClient.java"
click node_config "https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/config/FineractConfig.java"
click node_batchrepo "https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/adapter/BatchRepository.java"
click node_orderrepo "https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/adapter/OrderRepository.java"
click node_batch "https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/model/BillingBatch.java"
click node_order "https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/model/CollectionOrder.java"
click node_status "https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/model/OrderStatus.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ui,node_api toneBlue
class node_service,node_client,node_config toneAmber
class node_batchrepo,node_orderrepo,node_batch,node_order,node_status,node_postgres toneMint
class node_fineract toneRose
class node_user toneIndigo
```

## Components

### User access

- [Demo UI](https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub-ui/index.html): `collection-hub-ui/index.html`
- [Billing API](https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/adapter/CustomerBillingController.java): `collection-hub/src/main/java/com/bank/collectionhub/adapter/CustomerBillingController.java`

### Billing service

- [Billing workflow](https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/service/CustomerBillingService.java): `collection-hub/src/main/java/com/bank/collectionhub/service/CustomerBillingService.java`
- [Fineract client](https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/adapter/FineractClient.java): `collection-hub/src/main/java/com/bank/collectionhub/adapter/FineractClient.java`
- [Fineract HTTP config](https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/config/FineractConfig.java): `collection-hub/src/main/java/com/bank/collectionhub/config/FineractConfig.java`

### Local persistence

- [Batch repository](https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/adapter/BatchRepository.java): `collection-hub/src/main/java/com/bank/collectionhub/adapter/BatchRepository.java`
- [Order repository](https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/adapter/OrderRepository.java): `collection-hub/src/main/java/com/bank/collectionhub/adapter/OrderRepository.java`
- [Billing batch](https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/model/BillingBatch.java): `collection-hub/src/main/java/com/bank/collectionhub/model/BillingBatch.java`
- [Collection order](https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/model/CollectionOrder.java): `collection-hub/src/main/java/com/bank/collectionhub/model/CollectionOrder.java`
- [Order status](https://github.com/bryan-arrivasplata-rojas/hub-cobranza-fineract-bian/blob/main/collection-hub/src/main/java/com/bank/collectionhub/model/OrderStatus.java): `collection-hub/src/main/java/com/bank/collectionhub/model/OrderStatus.java`
- **Hub PostgreSQL**

### Loan system

- **Apache Fineract**

### Other components

- **Operator**

## Connections

- Operator → Demo UI: uses (evidence: `README.md`)
- Operator → Billing API: invokes (evidence: `README.md`)
- Demo UI → Billing API: requests
- Billing API → Billing workflow: delegates (evidence: `collection-hub/src/main/java/com/bank/collectionhub/adapter/CustomerBillingController.java`)
- Billing workflow → Fineract client: fetches schedules (evidence: `collection-hub/src/main/java/com/bank/collectionhub/service/CustomerBillingService.java`)
- Fineract client → Apache Fineract: reads loan data (evidence: `collection-hub/src/main/java/com/bank/collectionhub/adapter/FineractClient.java`)
- Fineract HTTP config → Fineract client: configures HTTP (evidence: `collection-hub/src/main/java/com/bank/collectionhub/config/FineractConfig.java`)
- Billing workflow → Batch repository: saves batches (evidence: `collection-hub/src/main/java/com/bank/collectionhub/service/CustomerBillingService.java`)
- Billing workflow → Order repository: upserts and searches (evidence: `collection-hub/src/main/java/com/bank/collectionhub/service/CustomerBillingService.java`)
- Batch repository → Billing batch: persists (evidence: `collection-hub/src/main/java/com/bank/collectionhub/adapter/BatchRepository.java`)
- Order repository → Collection order: persists (evidence: `collection-hub/src/main/java/com/bank/collectionhub/adapter/OrderRepository.java`)
- Billing workflow → Order status: resolves state (evidence: `collection-hub/src/main/java/com/bank/collectionhub/service/CustomerBillingService.java`)
- Batch repository → Hub PostgreSQL: stores records
- Order repository → Hub PostgreSQL: stores records
- Billing API → Operator: returns results (evidence: `collection-hub/src/main/java/com/bank/collectionhub/adapter/CustomerBillingController.java`)
