Life ConnectLife Connect
Wiki index
Architecture
Services
Concepts
Runbooks
Infra
Swagger Docs
GitHub
Wiki index
Architecture
Services
Concepts
Runbooks
Infra
Swagger Docs
GitHub
  • Backend (Java / Spring Boot)

    • adb
    • adb-persons
    • adb-parts
    • adb-contracts
    • adb-accounting
    • adb-files
    • adb-utilities
    • adb-aggregates
    • adb-views
    • adb-reports
  • Frontend

    • adb-ui
    • adb-web
  • Infrastructure & tooling

    • adb-charts
    • adb-infrastructure
    • adb-tests-artillery
    • adb-doc
  • External services (out-of-monorepo)

    • adb-tickets
    • adb-notes
    • adb-graph
Last updated 2026-05-06

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

ItemValue
Spring Boot3.1.3
Java18
Port8084
DatabaseMongoDB Atlas — database adb-contracts
AuthKeycloak (resource server)
Reactive stackSpring WebFlux + Reactive MongoDB
State machinesSpring Statemachine 2.2.3
PDFhtml2pdf 4.0.2 + iTextPDF
TemplatingFreeMarker
StorageAWS S3 (templates)
Version0.48.0-SNAPSHOT
Main classfr.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)

ControllerPathRole
ContractController/contractsGeneric contract CRUD
BankContractController/contracts/banksOwner / tenant bank account details
InsuranceContractController/contracts/insurancesInsurance contracts (GLI)
GuaranteeContractController/contracts/guaranteeGuarantee contracts
RentalAllowanceContractController/contracts/rental-allowancesHousing allowances
SepaMandateContractController/contracts/sepa-mandatesSEPA mandates
DirectDebitController/contracts/direct-debitDirect debits
DocumentController/contracts/documentsDocuments (PDF) attached to contracts
DunningController/contracts/dunningsDunning notices
ContractEventsController/contractsContract events (call-for-rent, ...)
ContractAccountingController/contractsAccounting view of a contract
ContractPersonsController/contractsPersons linked to the contract
ContractPartsController/contracts/partsParts linked to the contract
TemplateValuesController–Values injected into templates
ErrorDebugController/contracts/errorsDebug

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 machineContract type
RentalContractStateMachineRental Contract (RC)
RentalDelegateContractStateMachineRental Delegate Contract (RDC)
GuaranteeContractStateMachineGuarantee contracts
InsuranceContractStateMachineInsurance contracts (GLI)
RentalAllowanceContractStateMachineRental allowance contracts
SepaMandateContractStateMachineSEPA 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 a contracts document is written
  • onContractUpdated — fired on contract state transitions
  • onDirectDebitProcessed — fired when a direct debit is processed
  • dunningNoticeSent — fired when a dunning notice is sent

Consumed (SQS Listeners)

  • onPartModified (from adb-parts)
  • onPersonModified (from adb-persons)
  • onFileMetaDataModified (from adb-files)
  • onIndexPublished (from adb-utilities) → re-indexing of rents
  • onAccountingEventModified (from adb-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

VariableRole
MONGO_DB_URIMongoDB connection string
SECURITY_ISSUER_URI / SECURITY_TOKEN_URIKeycloak
CLIENT_ID / CLIENT_SECRETOAuth2
AWS_REGION / AWS_ACCESS_KEY / AWS_SECRET_KEYAWS
BUCKET_TEMPLATESS3 templates bucket
CONTRACTS_*_QUEUEURLs of consumed SQS queues
TWILIO_SENDGRID_API_KEYEmail 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/
Edit this page
Last Updated:
Contributors: Yevhenii Khudolii
Prev
adb-parts
Next
adb-accounting