# ciprian-radu/rent-a-car architecture

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

- Interactive diagram: https://gitdiagram.com/ciprian-radu/rent-a-car
- Repository: https://github.com/ciprian-radu/rent-a-car

## Overview

##### Project Type and Purpose
- This is a multi-module Java / Gradle application that implements a car-rental system as a _Proof of Concept_ for Clean Architecture (Ports & Adapters).
- It comprises three Spring Boot apps (OAuth2 Server, REST API, OAuth2 Client UI), a core domain model (entities + use cases), interface adapters (HTTP + JDBC gateways) and external interfaces (databases, REST endpoints, UI).

##### Main Architectural Layers (Clean Architecture)
- Entities (core business rules)
– Module: application/entities
- Use Cases (application-specific business rules)
– Module: application/use-cases
- Interface Adapters (implement ports for external systems)
– HTTP adapters: application/interface-adapters/http
– Database gateways: application/interface-adapters/gateways
- External Interfaces / Frameworks (details)
– REST API service: application/external-interfaces/rest-api
– OAuth2 Server: application/external-interfaces/auth-server
– OAuth2 Client UI: application/external-interfaces/auth-client
– Databases:
- Embedded/H2: application/external-interfaces/databases/h2-embedded
- Local H2: application/external-interfaces/databases/h2-local
- PostgreSQL: application/external-interfaces/databases/postgresql
- DB initializer: application/external-interfaces/databases/initializer

##### Highlighted Design Principles
- Dependency Rule: Outer layers depend on inner layers only via interfaces (ports).
- Ports & Adapters:
- Ports = Use Case input/output ports (interfaces in use-cases module)
- Adapters = HTTP adapters, JDBC gateways, OAuth2 client/server implementations
- Separation of Concerns: Business logic is framework-agnostic.
- Testability: Each layer has its own unit and integration tests (project’s tests/ subprojects).

##### Technologies & Frameworks
- Java 12, Gradle, Spring Boot
- Spring MVC (HTTP controllers), Spring JDBC (gateways)
- OAuth2 (Spring Security) for authentication
- H2 (embedded and local) and PostgreSQL databases

## Diagram (Mermaid)

```mermaid
flowchart TD
  subgraph "Entities Layer"
    Entities["Entities\n(application/entities)"]:::entities
  end

  subgraph "Use Cases Layer"
    UseCases["Use Cases\n(application/use-cases)"]:::usecases
  end

  subgraph "Interface Adapters Layer"
    subgraph "HTTP Adapters"
      HTTPAdapters["HTTP Adapters\n(application/interface-adapters/http)"]:::adapters
    end
    subgraph "JDBC Gateways"
      JDBCGateways["JDBC Gateways\n(application/interface-adapters/gateways)"]:::adapters
    end
  end

  subgraph "External Interfaces Layer"
    RESTAPI["REST API Service\n(application/external-interfaces/rest-api)"]:::external
    AuthServer["OAuth2 Server\n(application/external-interfaces/auth-server)"]:::external
    AuthClient["OAuth2 Client UI\n(application/external-interfaces/auth-client)"]:::external
    H2Embedded["H2 Embedded\n(application/external-interfaces/databases/h2-embedded)"]:::database
    H2Local["H2 Local\n(application/external-interfaces/databases/h2-local)"]:::database
    Postgres["PostgreSQL\n(application/external-interfaces/databases/postgresql)"]:::database
    DBInit["DB Initializer\n(application/external-interfaces/databases/initializer)"]:::external
  end

  AuthClient -->|"HTTP/REST"| RESTAPI
  AuthClient <-->|"OAuth2 API"| AuthServer
  RESTAPI -->|"calls HTTP Adapter"| HTTPAdapters
  HTTPAdapters -->|"invokes Use Case"| UseCases
  UseCases -->|"manipulates Entities"| Entities
  UseCases -->|"uses Gateway (JDBC)"| JDBCGateways
  JDBCGateways -->|"JDBC"| H2Embedded
  JDBCGateways -->|"JDBC"| H2Local
  JDBCGateways -->|"JDBC"| Postgres
  DBInit -.->|"initializes DBs"| H2Embedded
  DBInit -.->|"initializes DBs"| H2Local
  DBInit -.->|"initializes DBs"| Postgres

  click Entities "https://github.com/ciprian-radu/rent-a-car/tree/master/application/entities"
  click UseCases "https://github.com/ciprian-radu/rent-a-car/tree/master/application/use-cases"
  click HTTPAdapters "https://github.com/ciprian-radu/rent-a-car/tree/master/application/interface-adapters/http"
  click JDBCGateways "https://github.com/ciprian-radu/rent-a-car/tree/master/application/interface-adapters/gateways"
  click RESTAPI "https://github.com/ciprian-radu/rent-a-car/tree/master/application/external-interfaces/rest-api"
  click AuthServer "https://github.com/ciprian-radu/rent-a-car/tree/master/application/external-interfaces/auth-server"
  click AuthClient "https://github.com/ciprian-radu/rent-a-car/tree/master/application/external-interfaces/auth-client"
  click H2Embedded "https://github.com/ciprian-radu/rent-a-car/tree/master/application/external-interfaces/databases/h2-embedded"
  click H2Local "https://github.com/ciprian-radu/rent-a-car/tree/master/application/external-interfaces/databases/h2-local"
  click Postgres "https://github.com/ciprian-radu/rent-a-car/tree/master/application/external-interfaces/databases/postgresql"
  click DBInit "https://github.com/ciprian-radu/rent-a-car/tree/master/application/external-interfaces/databases/initializer"

  classDef entities fill:lightyellow,stroke:#333,stroke-width:1px;
  classDef usecases fill:lightgreen,stroke:#333,stroke-width:1px;
  classDef adapters fill:lightblue,stroke:#333,stroke-width:1px;
  classDef external fill:lightgray,stroke:#333,stroke-width:1px;
  classDef database fill:#f9f9f9,stroke:#333,stroke-width:1px,stroke-dasharray:5 5;
```
