adb-contracts
AI-generated content
This document was generated by an AI assistant. Verify accuracy before relying on the details.
Role
Service that manages the lifecycle of contracts attached to an asset. Supported contract types:
- Rental Contract (RC) — standard rental agreement between owner and tenant
- Rental Delegate Contract (RDC) — delegated rental management contract
- Owner Contract (OC) — contract between the agency and the property owner
- Bank Contract (BC) — owner or tenant bank account details (used for direct debit)
Beyond contract management, the service covers:
- SEPA mandate management — creation and lifecycle of ISO 20022 PAIN.008 mandates
- Direct debit — scheduling and processing of direct debit operations
- Call for rent management — periodic (monthly / quarterly / annual) tenant charging process: triggers invoice creation, drives money flow, and coordinates related accounting entries in
adb-accounting - Dunning notice management — reminders and escalation for unpaid items
- Insurance management (GLI) — rental guarantee insurance contracts
- Rental allowance contract management — housing allowance (APL/ALS) contracts
- INSEE index management — rent revision indices (IRL, ILC, ILAT) applied to RCs
- Guarantee contracts — surety and deposit guarantees
- Document generation — PDF contracts, mandates, notices via FreeMarker + html2pdf
Tech stack
| Item | Value |
|---|---|
| Spring Boot | 3.1.3 |
| Java | 18 |
| Port | 8084 |
| Database | MongoDB Atlas — database adb-contracts |
| Auth | Keycloak (resource server) |
| Reactive stack | Spring WebFlux + Reactive MongoDB |
| State machines | Spring Statemachine 2.2.3 |
| html2pdf 4.0.2 + iTextPDF | |
| Templating | FreeMarker |
| Storage | AWS S3 (templates) |
| Version | 0.48.0-SNAPSHOT |
| Main class | fr.lifeconnect.adb.contract.AdbContractApplication |
Internal architecture
flowchart TB
subgraph Controllers["15 Controllers"]
CC[ContractController]
BCC[BankContractController]
ICC[InsuranceContractController]
GCC[GuaranteeContractController]
RACC[RentalAllowanceContractController]
SMCC[SepaMandateContractController]
DDC[DirectDebitController]
DC[DocumentController]
DnC[DunningController]
CEC[ContractEventsController]
CACC[ContractAccountingController]
CPC[ContractPersonsController]
CPaC[ContractPartsController]
TVC[TemplateValuesController]
end
subgraph StateMachines
RCSM[RentalContract SM]
RDCSM[RentalDelegateContract SM]
GCSM[GuaranteeContract SM]
ICSM[InsuranceContract SM]
RACSM[RentalAllowanceContract SM]
SMCSM[SepaMandateContract SM]
SMM[StateMachineManager]
end
subgraph Listeners["SQS Listeners"]
L1[PartFunction → onPartModified]
L2[PersonFunction → onPersonModified]
L3[FileFunction → onFileMetaDataModified]
L4[IndexFunction → onIndexPublished]
L5[ContractFunction]
L6[AccountingFunction]
L7[DunningFunction]
end
subgraph External
Mongo[(adb-contracts)]
S3[(S3 templates)]
AtlasTrigger[Atlas Trigger]
EB[EventBridge]
SQS[SQS queues]
SNS["SNS (DLQ router)"]
end
Controllers --> StateMachines
Controllers --> Mongo
DC --> S3
Listeners --> Mongo
Mongo -.entity change.-> AtlasTrigger
AtlasTrigger -.-> EB
EB -.-> SQS
Listeners -.failed msg.-> SNS
SNS -.routes to DLQ.-> SQS
Endpoints (15 controllers)
| Controller | Path | Role |
|---|---|---|
ContractController | /contracts | Generic contract CRUD |
BankContractController | /contracts/banks | Owner / tenant bank account details |
InsuranceContractController | /contracts/insurances | Insurance contracts (GLI) |
GuaranteeContractController | /contracts/guarantee | Guarantee contracts |
RentalAllowanceContractController | /contracts/rental-allowances | Housing allowances |
SepaMandateContractController | /contracts/sepa-mandates | SEPA mandates |
DirectDebitController | /contracts/direct-debit | Direct debits |
DocumentController | /contracts/documents | Documents (PDF) attached to contracts |
DunningController | /contracts/dunnings | Dunning notices |
ContractEventsController | /contracts | Contract events (call-for-rent, ...) |
ContractAccountingController | /contracts | Accounting view of a contract |
ContractPersonsController | /contracts | Persons linked to the contract |
ContractPartsController | /contracts/parts | Parts linked to the contract |
TemplateValuesController | – | Values injected into templates |
ErrorDebugController | /contracts/errors | Debug |
Data model
erDiagram
ContractEntity ||--o{ ContractPartEntry : "covers"
ContractEntity ||--|| DirectDebitEntity : "direct debit"
ContractEntity ||--o{ TemplateValuesEntity : "generates"
ContractEntity ||--o{ ProposeContractEntity : "draft of"
ContractEntity {
string _id
string type "RC / RDC / OC / BC (bank details) / insurance / guarantee / sepa"
string state "DRAFT / ACTIVE / TERMINATED"
date startDate
date endDate
array partIds
array personIds
}
DirectDebitEntity {
string _id
string contractId
string mandateId
number amount
}
TemplateValuesEntity {
string _id
string contractId
object values
}
ProposeContractEntity {
string _id
string contractId
object proposal
}
Collections: contracts, propose_contracts, direct_debits, template_values.
State machines
Pool size: 1000 (config state-machine.pool.size). Typical states: DRAFT, PROPOSED, SIGNED, ACTIVE, TERMINATED, CANCELLED. Events: UPDATE, SIGN, CANCEL, TERMINATE, RENEW.
| State machine | Contract type |
|---|---|
RentalContractStateMachine | Rental Contract (RC) |
RentalDelegateContractStateMachine | Rental Delegate Contract (RDC) |
GuaranteeContractStateMachine | Guarantee contracts |
InsuranceContractStateMachine | Insurance contracts (GLI) |
RentalAllowanceContractStateMachine | Rental allowance contracts |
SepaMandateContractStateMachine | SEPA mandates |
Events
Emitted (MongoDB Atlas Trigger → EventBridge → SQS)
Events are not published by the Spring service directly. MongoDB Atlas triggers fire on entity changes and push notifications through AWS EventBridge, which delivers them to the relevant SQS queues:
onContractModified— fired when acontractsdocument is writtenonContractUpdated— fired on contract state transitionsonDirectDebitProcessed— fired when a direct debit is processeddunningNoticeSent— fired when a dunning notice is sent
Consumed (SQS Listeners)
onPartModified(fromadb-parts)onPersonModified(fromadb-persons)onFileMetaDataModified(fromadb-files)onIndexPublished(fromadb-utilities) → re-indexing of rentsonAccountingEventModified(fromadb-accounting)dunningNoticeSent(self-listening for orchestration)ContractsAuxiliaryAccountBalanceUpdated
Dead-letter (SNS → SQS DLQ)
When a listener fails to process a message, the failed message is published to the CONTRACTS_DLQ_TOPIC SNS topic, which routes it to the contracts SQS DLQ.
Inter-service dependencies
flowchart LR
contracts[adb-contracts]
persons[adb-persons]
parts[adb-parts]
files[adb-files]
accounting[adb-accounting]
utilities[adb-utilities]
contracts -->|GET /persons| persons
contracts -->|GET /parts| parts
contracts -->|GET /files,<br/>POST /files| files
contracts -->|GET /accounting/balances,<br/>POST /accounting/entries| accounting
contracts -->|GET /utilities/i18n| utilities
parts2[adb-parts] -->|GET /contracts/sellPart| contracts
accounting2[adb-accounting] -->|GET /contracts| contracts
aggregates[adb-aggregates] -->|GET /contracts| contracts
views[adb-views] -->|GET /contracts| contracts
reports[adb-reports] -.via aggregates.-> contracts
External integrations
- AWS S3 (
BUCKET_TEMPLATES): storage of FreeMarker templates for PDFs. - AWS SQS/SNS: numerous queues
${CONTRACTS_*_QUEUE}and DLQ topic. - Twilio SendGrid: email delivery (SEPA mandates, dunning) —
TWILIO_SENDGRID_API_KEY. - JAXB + ISO 20022: XML serialization of PAIN.008 files for banks.
- html2pdf: HTML → PDF conversion for signed contracts.
Configuration / deployment
Key environment variables
| Variable | Role |
|---|---|
MONGO_DB_URI | MongoDB connection string |
SECURITY_ISSUER_URI / SECURITY_TOKEN_URI | Keycloak |
CLIENT_ID / CLIENT_SECRET | OAuth2 |
AWS_REGION / AWS_ACCESS_KEY / AWS_SECRET_KEY | AWS |
BUCKET_TEMPLATES | S3 templates bucket |
CONTRACTS_*_QUEUE | URLs of consumed SQS queues |
TWILIO_SENDGRID_API_KEY | Email delivery |
Helm chart
Deprecated — Helm charts are no longer maintained. Infrastructure is managed via Pulumi (
infra/).
adb-charts/charts/services/templates/adb-contracts.yaml. Image: lifeconnect/adb-contracts.
Links
- Code:
adb-contracts/ - State machine config:
adb-contracts/src/main/java/fr/lifeconnect/adb/contract/ - Functional docs:
technical-epics/contracts/