feat: finalize lease documents and IRL revisions

This commit is contained in:
nessar committed 2026-08-17 14:18:16 +02:00
1 parent f127c69a28
commit 1bf6a3449c
196 files changed
+20564 -666

No files matched your search

@@ -7,15 +7,18 @@ The application manages sensitive tenant files (identity cards, tax notices, pay
## Decisions
### 1. Automated Server-Side Image Optimization
All uploaded photos (for property condition reports) are compressed and resized on the backend before write:
- Target resolution: maximum 1920x1080 pixels.
- Format: converted to WebP.
- Compression quality factor: 75-80%.
This reduces average photo size from ~6.0 MB (raw smartphone camera) to ~250 KB (95.8% reduction).
This reduces average photo size from ~6.0 MB (raw smartphone camera) to ~250 KB (95.8% reduction).
### 2. GDPR Retention and Purging Cycle
- **Rejected Applicants**: Complete deletion of all submitted documents (payslips, identity documents) exactly 30 days after rejection.
- **Archived Leases**:
- **Archived Leases**:
- Upon lease termination, the lease transitions to an `Archived` state.
- Personal identity documents and income proofs of the former tenants are permanently purged 3 years after lease termination (matching the 3-year French statute of limitations for residential tenancy disputes).
- General inspection photos are purged 5 years after lease termination.
@@ -29,26 +32,28 @@ Assuming an average lease turnover rate of 2 years (i.e., 1.5 lease cycles per y
### Unit Data Footprints
| Data Type | Unoptimized Size | Optimized Size | Purge Trigger |
| :--- | :--- | :--- | :--- |
| **MongoDB Text Records** | ~10 KB / year | ~10 KB / year | Never (10-year archive) |
| **Tenant Personal Dossier** | ~5.0 MB (PDF/Images) | ~5.0 MB | Purged 3 years after lease end |
| **Inspection Photos (In/Out)** | ~360 MB (60 raw photos) | ~15 MB (WebP 1080p) | Purged 5 years after lease end |
| **Invoices & Receipts / year** | ~20 MB (Raw scans) | ~5 MB (Compressed PDFs) | Never (10-year archive) |
| Data Type | Unoptimized Size | Optimized Size | Purge Trigger |
| :----------------------------- | :---------------------- | :---------------------- | :----------------------------- |
| **MongoDB Text Records** | ~10 KB / year | ~10 KB / year | Never (10-year archive) |
| **Tenant Personal Dossier** | ~5.0 MB (PDF/Images) | ~5.0 MB | Purged 3 years after lease end |
| **Inspection Photos (In/Out)** | ~360 MB (60 raw photos) | ~15 MB (WebP 1080p) | Purged 5 years after lease end |
| **Invoices & Receipts / year** | ~20 MB (Raw scans) | ~5 MB (Compressed PDFs) | Never (10-year archive) |
### 10-Year Cumulative Footprint Comparison
#### Scenario A: Unoptimized & No Purge (Default Strategy)
- **Year 1**: 3 * (22 MB tenant docs + 360 MB photos) + 67 MB operational files = **1,213 MB (~1.2 GB)**.
- **Yearly Growth**: 67 MB (ops) + 1.5 * (22 MB tenant docs + 720 MB in/out photos) = **1,180 MB / year**.
- **Year 10 Cumulative Footprint**: **~11.8 GB** (Continuous, compounding growth).
#### Scenario B: Optimized & Purged (Our Design)
- **Year 1**: 3 * (5 MB tenant docs + 15 MB photos) + 15 MB operational files = **75 MB**.
- **Yearly Growth (Before Purges)**: 15 MB (ops) + 1.5 * (5 MB tenant docs + 30 MB in/out photos) = **67.5 MB / year**.
- **Purging Offsets**:
- *From Year 4 onwards*: Purge of tenant dossiers of expired leases saves **7.5 MB / year** (1.5 leases * 5 MB).
- *From Year 6 onwards*: Purge of inspection photos of expired leases saves **45.0 MB / year** (1.5 leases * 30 MB).
- _From Year 4 onwards_: Purge of tenant dossiers of expired leases saves **7.5 MB / year** (1.5 leases * 5 MB).
- _From Year 6 onwards_: Purge of inspection photos of expired leases saves **45.0 MB / year** (1.5 leases * 30 MB).
- **Year 10 Cumulative Footprint**: **~345 MB** (Stabilizes and plates out around 350 MB due to continuous purges).
This architecture saves over **97% of server disk space** over a 10-year lifecycle compared to a naive storage strategy, while strictly respecting French GDPR constraints.
+7
View File
@@ -42,23 +42,28 @@ A containerized web application comprising a Java 25 / Spring Boot 4 backend and
## Implementation Decisions
### Technical Stack
- **Backend**: Java 25 LTS, Spring Boot 4, Spring Security OAuth2. Exposes REST APIs documented using OpenAPI/Swagger.
- **Frontend**: Angular 22, SPA built using modern vanilla CSS stylesheets. Interactive charts implemented via `ngx-echarts` (optimized custom bundle). Built and packaged using Bun. The user interface must be fully responsive, adopting a fluid mobile-first design suitable for smartphones, tablets, and desktop displays.
- **Database**: MongoDB (latest stable version).
- **Authentication**: OpenID Connect (OIDC) dynamically configured to plug into `voidAuth` for both development and production.
### Data Model & Multi-Tenancy preparedness (ADR-0001)
- The database schema binds all core entities (apartments, leases, loans, events) to a `BailleurId`. Initially, the app is deployed in single-portfolio mode with a single default `Bailleur` record, but the schema remains ready for future SaaS/multi-tenant partitioning.
### Attachment Storage & Optimization (ADR-0003, ADR-0006)
- Binary files (PDFs, photos) are stored on the server's local file system (mounted via persistent Docker volumes). The MongoDB database holds file metadata (`Attachment`).
- Uploaded photos are compressed backend-side: resized to a maximum of 1920x1080 and converted to WebP with 75-80% quality (reducing size to ~250 KB per photo).
### GDPR & Archiving Automated Schedules (ADR-0006)
- Candidates' documents are permanently deleted 30 days after application rejection/selection.
- Terminated leases transition to an `Archived` state. Identity documents and payslips of former tenants are purged 3 years after lease end. Property condition photos are purged 5 years after lease end. Financial/rent ledgers are archived and kept for 10 years to comply with commercial tax auditing codes.
### Tax Calculations & Automation
- **Expense Classification**: Expenses under 500 € HT or belonging to operations categories (insurance, tax) are categorized as Deductible Expenses (`Charge déductible`). Renovation or furniture expenses over 500 € HT are categorized as Capitalized Assets (`CapitalizedAsset`) and trigger an amortization line.
- **Component Amortization**: Pre-filled template configurations for property components (Terrain, Gros œuvre, Toiture, Équipements). Land Share (`Quote-part de terrain`) is excluded from depreciation.
- **Carry-Forwards**: Automatically calculates and rolls over Tax Loss Carryforwards (`Déficit reportable`) and Deferred Amortizations (`Amortissement différé`) at fiscal year closure.
@@ -66,9 +71,11 @@ A containerized web application comprising a Java 25 / Spring Boot 4 backend and
## Testing Decisions
### Code Coverage Rule
- A minimum code coverage threshold of **80%** will be strictly enforced on both the backend (JUnit/JaCoCo) and frontend (Karma/Jest/Istanbul) testing pipelines. Builds with coverage under 80% must fail the GitLab CI test stage.
### Testing Seams
- **Backend Seam (API Layer)**: Integration tests using `@SpringBootTest` and `MockMvc` to hit REST endpoints, verify controller behaviors, model validations, and security configurations. A test MongoDB profile (using Testcontainers) will be used. OIDC token validation will be mocked.
- **Frontend Seam (Component/Service Layer)**: Angular component and service testing via `TestBed` and `HttpTestingController` to mock HTTP interactions and verify form inputs, component state updates, and calendar/tax rendering.
- **End-to-End Seam (Playwright)**: Full browser automated testing covering OIDC login flows, guided Property Condition photo captures, and Tax Declaration Form simulations.