# pedrojose06/storage-rent architecture

> Architecture diagram of the GitHub repository pedrojose06/storage-rent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pedrojose06/storage-rent
- Repository: https://github.com/pedrojose06/storage-rent

## Overview

##### Project Type and Purpose
- This is a small, open-source TypeScript library (Node.js package) whose sole responsibility is to compute a series of storage‐unit rent payments (with proration, scheduled increases/decreases) over a given date range.
- It is not a full-stack app or microservice. Rather, it’s a self-contained algorithmic utility with a test suite.

##### File‐Structure Analysis
- Root:
- package.json / tsconfig.json → build & dependency config
- biome.json → code formatting/lint rules
- README.md → problem statement & usage
- CODEOWNERS, .gitignore → repo governance
- src/StorageRent/StorageRent.ts → core implementation
- test/StorageRent/… → Jest + ts-jest unit tests & mocks

##### Key Insights from README
- Inputs: base rent, lease start, window start/end, due‐day, frequency, change rate
- Outputs: array of `{ rentDueDate, rentAmount, vacancy }`
- Helpers in code for proration, date math, rate application (don’t modify completed helpers)

a. Main Components
- Input Interface: parameters passed into `StorageRent.calculateRentSchedule()`
- Core Module (“StorageRent”):
- Proration Engine
- Due-Date Calculator
- Rent-Change Scheduler
- Output Formatter: rounds to two decimals, attaches vacancy flag
- Test Harness: Jest runner + test cases + mocks
- Build/Toolchain: TypeScript compiler, ts-jest, Biome
b. Relationships & Data Flow
1. User (or consumer code) → invokes Input Interface
2. Input → Core Module → calls:
- Proration Engine (first‐month calculation)
- Due-Date Calculator (monthly schedule)
- Rent-Change Scheduler (applies rate every X months)
3. Core Module → Output Formatter → returns list of payment objects
4. Test Harness → simulates calls to Core Module, uses mocks, asserts results
5. Build/Toolchain compiles src → dist, runs tests in CI
c. Architectural Patterns & Principles
- Functional decomposition: each helper does one thing
- Single Responsibility: core module only schedules rent, tests only validate
- Test-Driven Development: skeleton tests provided, new tests must cover edge cases
d. Technologies & Frameworks
- Node.js runtime, TypeScript language
- Jest + ts-jest for testing
- Biome for linting/formatting
- VS Code (or any TS-compatible editor)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Consumer
    User["Consumer Code / User"]:::external

    %% Source Modules
    InputInterface["Input Interface\n(StorageRent.calculateRentSchedule)"]:::core
    subgraph "Core Module" 
        direction TB
        Proration["Proration Engine"]:::core
        DueDate["Due-Date Calculator"]:::core
        RateScheduler["Rent-Change Scheduler"]:::core
        OutputFormatter["Output Formatter"]:::core
    end

    %% Test Components
    subgraph "Test Harness" 
        direction TB
        TestRunner["Jest Runner & Tests"]:::test
        Mocks["Test Mocks"]:::test
    end

    %% Build & Config
    subgraph "Build & Config" 
        direction TB
        TSCompiler["TypeScript Compiler"]:::config
        TsJest["ts-jest"]:::config
        Biome["Biome Linter/Formatter"]:::config
        PackageJson["package.json"]:::config
        TsConfig["tsconfig.json"]:::config
        BiomeConfig["biome.json"]:::config
        GitIgnore[".gitignore"]:::config
        CODEOWNERS["CODEOWNERS"]:::config
        README["README.md"]:::config
    end

    %% Data Flow
    User -->|"leaseStartDate, baseRent, windowStart/end"| InputInterface
    InputInterface -->|"parameters"| Proration
    Proration -->|"first-month amount"| DueDate
    DueDate -->|"scheduled dates"| RateScheduler
    RateScheduler -->|"adjusted rents"| OutputFormatter
    OutputFormatter -->|"rentDueDates[], rentAmount, vacancy"| User

    %% Test Flow
    TestRunner -->|"mock parameters"| InputInterface
    TestRunner -->|"assert output"| OutputFormatter
    Mocks --> TestRunner

    %% Build Flow
    TSCompiler -->|compiles src → dist| InputInterface
    TsJest -->|runs tests| TestRunner
    Biome -->|formats/lints| InputInterface
    PackageJson -->|defines scripts/deps| TSCompiler
    TsConfig -->|compiler options| TSCompiler
    BiomeConfig -->|lint rules| Biome
    GitIgnore -->|CI ignore rules| TSCompiler
    CODEOWNERS -->|governance| TSCompiler
    README -->|docs| User

    %% Click Events
    click InputInterface "https://github.com/pedrojose06/storage-rent/blob/main/src/StorageRent/StorageRent.ts"
    click Proration "https://github.com/pedrojose06/storage-rent/blob/main/src/StorageRent/StorageRent.ts"
    click DueDate "https://github.com/pedrojose06/storage-rent/blob/main/src/StorageRent/StorageRent.ts"
    click RateScheduler "https://github.com/pedrojose06/storage-rent/blob/main/src/StorageRent/StorageRent.ts"
    click OutputFormatter "https://github.com/pedrojose06/storage-rent/blob/main/src/StorageRent/StorageRent.ts"
    click TestRunner "https://github.com/pedrojose06/storage-rent/blob/main/test/StorageRent/StorageRent.test.ts"
    click Mocks "https://github.com/pedrojose06/storage-rent/blob/main/test/StorageRent/mocks/StorageRent.mock.ts"
    click TsConfig "https://github.com/pedrojose06/storage-rent/blob/main/tsconfig.json"
    click PackageJson "https://github.com/pedrojose06/storage-rent/blob/main/package.json"
    click BiomeConfig "https://github.com/pedrojose06/storage-rent/blob/main/biome.json"
    click GitIgnore "https://github.com/pedrojose06/storage-rent/blob/main/.gitignore"
    click README "https://github.com/pedrojose06/storage-rent/blob/main/README.md"
    click CODEOWNERS "https://github.com/pedrojose06/storage-rent/tree/main/CODEOWNERS"

    %% Styles
    classDef core fill:#e0f7e9,stroke:#2e7d32,stroke-width:2px
    classDef test fill:#e3f2fd,stroke:#1565c0,stroke-width:2px
    classDef config fill:#fff3e0,stroke:#ef6c00,stroke-width:2px
    classDef external fill:#eeeeee,stroke:#9e9e9e,stroke-width:2px,stroke-dasharray: 5 5
```
