# matheusfcorocher/simple_rental_service architecture

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

- Interactive diagram: https://gitdiagram.com/matheusfcorocher/simple_rental_service
- Repository: https://github.com/matheusfcorocher/simple_rental_service

## Overview

##### Main Components

A. Application Layer (Top Level)
- Console Application Interface
- REST API Interface

B. Core Components (Middle Layer)
- Controllers Package
- Presenters Package
- Assemblers Package

C. Domain Layer (Core Business Logic)
- Rental Ecosystem Package
- Entities (Rental, Renter, Vehicle)
- Use Cases
- Storage Interfaces

D. Infrastructure Layer (Bottom Level)
- SQLite Database
- Storage Implementations
- Utilities Package

**┌─ Application Layer ─────────────────────┐**
- ┌─────────────┐        ┌────────────┐  │
- Console   │        │  REST API  │  │
- ┘        └────────────┘  │
- ┬──────────────────────┘
- ↓
**┌─ Core Components ─────────────────────────┐**
- ┌─────────────┐  ┌──────────┐  ┌─────┐  │
- Controllers │←→│Presenters│←→│ DTOs │  │
- ┘  └──────────┘  └─────┘  │
- ┬──────────────────────┘
- ↓
**┌─ Domain Layer ────────────────────────────┐**
- ┌─────────┐    ┌──────────┐             │
- Entities │←→  │Use Cases │             │
- ┘    └──────────┘             │
- ┌─────────────────────────┐             │
- Storage Interfaces   │             │
- ┘             │
- ┬──────────────────────┘
- ↓
**┌─ Infrastructure Layer ──────────────────┐**
- ┌─────────────┐    ┌───────────────┐  │
- SQLite    │←→  │Storage Impls  │  │
- ┘    └───────────────┘  │
- ┘

##### Important Elements to Highlight

a. Entity Relationships:
- Connections between Rental, Renter, and Vehicle entities
- CRUD operations flow

b. Use Case Flow:
- Demonstrate how requests flow from interfaces through controllers
- How use cases interact with storage interfaces

c. Storage Pattern:
- Implementation of storage interfaces
- Database connectivity

##### Specific Implementation Details

- How the assemblers package connects components
- Exception handling flow
- Demonstrate how presenters format output for different interfaces
- System response handling patterns

##### Technical Stack Indicators

- Free Pascal Compiler
- Lazarus IDE integration
- SQLite database
- Docker containerization

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef application fill:#d0e8ff,stroke:#333
    classDef core fill:#d0ffd0,stroke:#333
    classDef domain fill:#fff3d0,stroke:#333
    classDef infrastructure fill:#e0e0e0,stroke:#333
    classDef interface fill:#fff,stroke:#333,stroke-dasharray: 5 5
    
    %% Application Layer
    subgraph AppLayer["Application Layer"]
        Console["Console Application"]:::application
        RestAPI["REST API Interface"]:::application
    end
    
    %% Core Components Layer
    subgraph CoreLayer["Core Components"]
        Controllers["Controllers"]:::core
        Presenters["Presenters"]:::core
        Assemblers["Assemblers"]:::core
        DTOs["Entity DTOs"]:::core
    end
    
    %% Domain Layer
    subgraph DomainLayer["Domain Layer"]
        subgraph Entities["Domain Entities"]
            Rental["Rental Entity"]:::domain
            Renter["Renter Entity"]:::domain
            Vehicle["Vehicle Entity"]:::domain
        end
        UseCases["Use Cases"]:::domain
        StorageInterfaces["Storage Interfaces"]:::interface
    end
    
    %% Infrastructure Layer
    subgraph InfraLayer["Infrastructure Layer"]
        SQLite["SQLite Database"]:::infrastructure
        StorageImpl["Storage Implementations"]:::infrastructure
        Utils["Utilities"]:::infrastructure
        Exceptions["Exception Handling"]:::infrastructure
        SysResponses["System Responses"]:::infrastructure
    end
    
    %% Relationships
    Console --> Controllers
    RestAPI --> Controllers
    Controllers <--> Presenters
    Presenters <--> DTOs
    Controllers <--> Assemblers
    Assemblers <--> DTOs
    DTOs <--> Entities
    UseCases --> StorageInterfaces
    UseCases --> Entities
    StorageInterfaces --> StorageImpl
    StorageImpl --> SQLite
    StorageImpl --> Utils
    Utils --> Exceptions
    Utils --> SysResponses
    
    %% Click Events
    click Console "https://github.com/matheusfcorocher/simple_rental_service/tree/main/src/applications/console/"
    click RestAPI "https://github.com/matheusfcorocher/simple_rental_service/tree/main/src/applications/rest_api/"
    click Controllers "https://github.com/matheusfcorocher/simple_rental_service/tree/main/src/controllers/"
    click Presenters "https://github.com/matheusfcorocher/simple_rental_service/tree/main/src/presenters/"
    click Assemblers "https://github.com/matheusfcorocher/simple_rental_service/tree/main/src/assemblers/"
    click DTOs "https://github.com/matheusfcorocher/simple_rental_service/blob/main/src/rental_ecosystem/entities/rental/rentaldtounit.pas"
    click Rental "https://github.com/matheusfcorocher/simple_rental_service/tree/main/src/rental_ecosystem/entities/"
    click Renter "https://github.com/matheusfcorocher/simple_rental_service/tree/main/src/rental_ecosystem/entities/"
    click Vehicle "https://github.com/matheusfcorocher/simple_rental_service/tree/main/src/rental_ecosystem/entities/"
    click UseCases "https://github.com/matheusfcorocher/simple_rental_service/tree/main/src/rental_ecosystem/use_cases/"
    click StorageInterfaces "https://github.com/matheusfcorocher/simple_rental_service/tree/main/src/rental_ecosystem/storages/"
    click SQLite "https://github.com/matheusfcorocher/simple_rental_service/tree/main/src/infrastructure/databases/sqlite/"
    click StorageImpl "https://github.com/matheusfcorocher/simple_rental_service/tree/main/src/infrastructure/storages/"
    click Utils "https://github.com/matheusfcorocher/simple_rental_service/tree/main/src/utils/"
    click Exceptions "https://github.com/matheusfcorocher/simple_rental_service/tree/main/src/utils/exceptions/"
    click SysResponses "https://github.com/matheusfcorocher/simple_rental_service/tree/main/src/utils/system_responses/"
```
