# openclassrooms-student-center/parkingsystem architecture

> Architecture diagram of the GitHub repository openclassrooms-student-center/parkingsystem, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openclassrooms-student-center/parkingsystem
- Repository: https://github.com/openclassrooms-student-center/parkingsystem

## Overview

##### Main Components
- User Interface & Input: In this case, the UI isn’t a web-based GUI but a command line interface (CLI). This is handled by the InteractiveShell class and its supporting utility, InputReaderUtil.
- Application Core/Services: This includes the business logic for handling parking operations, such as ParkingService and FareCalculatorService.
- Data Persistence Layer (DAO): The data access objects, specifically ParkingSpotDAO and TicketDAO, manage interactions with the MySQL database.
- Configuration: The DataBaseConfig class (in the config package) sets up and manages database connections.
- Domain Models: Represented by objects like ParkingSpot, Ticket, and constants defined in packages like constants.
- Testing Components: Although these aren’t part of the running system, unit tests (e.g. FareCalculatorServiceTest, ParkingServiceTest) and integration tests (e.g. ParkingDataBaseIT) are crucial for understanding how the system is validated.

##### Relationships and Interactions
- The CLI (InteractiveShell) is the entry point (via App.java) and drives application flow by capturing user input.
- Once user actions are received, the UI layer calls the appropriate methods in the service layer (ParkingService, FareCalculatorService) to process business logic.
- The service layer, in turn, uses the DAO layer (ParkingSpotDAO, TicketDAO) to perform CRUD operations on the MySQL DB.
- The DataBaseConfig provides the database connection configuration that integrates the DAO layer with the MySQL server.
- Utility classes (like InputReaderUtil) help in abstracting recurring functions such as reading user input.
- The domain model classes encapsulate the data structures that pass through the various layers.
- The tests (separated into unit and integration) verify the behavior of these components, particularly the interactions between services, DAOs, and the database.

##### Architectural Patterns and Design Principles
- Layered Architecture (separation of concerns) is in play: the system is loosely partitioned into the presentation (CLI), business logic (services), and data access (DAO) layers.
- Dependency inversion is partly visible where configuration (DataBaseConfig) is injected into the DAO.

##### Final Advice for the Principal Software Engineer
- Finally, include a minor note on testing which ensures that the design not only covers production code but also highlights available tests indicating the system’s reliability measures.

## Diagram (Mermaid)

```mermaid
graph TD
    %% CLI / Input Layer
    subgraph "CLI/Input Layer"
        A["App (Entry Point)"]:::cli
        IS["InteractiveShell"]:::cli
        IRU["InputReaderUtil"]:::cli
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        PS["ParkingService"]:::service
        FCS["FareCalculatorService"]:::service
    end

    %% Data Persistence Layer
    subgraph "Data Persistence Layer"
        PSD["ParkingSpotDAO"]:::dao
        TD["TicketDAO"]:::dao
        DBC["DataBaseConfig"]:::config
    end

    %% Domain Models
    subgraph "Domain Models"
        PMS["ParkingSpot"]:::model
        TM["Ticket"]:::model
        CONST["Constants"]:::model
    end

    %% Testing Components
    subgraph "Testing Components"
        FCT["FareCalculatorServiceTest"]:::test
        PST["ParkingServiceTest"]:::test
        PDT["ParkingDataBaseIT"]:::test
        DTC["DataBaseTestConfig"]:::test
        DPS["DataBasePrepareService"]:::test
    end

    %% External Database
    DB["MySQL Database"]:::database

    %% Connections - Flow of control
    A -->|"starts"| IS
    IS -->|"calls"| PS
    IS -->|"calls"| FCS
    PS -->|"invokes"| PSD
    PS -->|"invokes"| TD
    DBC -->|"configures"| PSD
    DBC -->|"configures"| TD
    PSD -->|"CRUD"| DB
    TD -->|"CRUD"| DB
    PS -->|"manages"| PMS
    PS -->|"manages"| TM
    FCS -->|"calculates"| TM

    %% Testing relationships
    FCT -->|"tests"| FCS
    PST -->|"tests"| PS
    PDT -->|"integrates"| PSD
    PDT -->|"integrates"| TD
    DTC -->|"configures"| DPS

    %% Styles
    classDef cli fill:#f9c,stroke:#333,stroke-width:2px;
    classDef service fill:#bbf,stroke:#333,stroke-width:2px;
    classDef dao fill:#bfb,stroke:#333,stroke-width:2px;
    classDef config fill:#ff9,stroke:#333,stroke-width:2px;
    classDef model fill:#fc9,stroke:#333,stroke-width:2px;
    classDef database fill:#f66,stroke:#333,stroke-width:2px;
    classDef test fill:#ccc,stroke:#333,stroke-width:2px;

    %% Click Events for CLI/Input Layer
    click A "https://github.com/openclassrooms-student-center/parkingsystem/blob/master/src/main/java/com/parkit/parkingsystem/App.java"
    click IS "https://github.com/openclassrooms-student-center/parkingsystem/blob/master/src/main/java/com/parkit/parkingsystem/service/InteractiveShell.java"
    click IRU "https://github.com/openclassrooms-student-center/parkingsystem/blob/master/src/main/java/com/parkit/parkingsystem/util/InputReaderUtil.java"

    %% Click Events for Business Logic Layer
    click PS "https://github.com/openclassrooms-student-center/parkingsystem/blob/master/src/main/java/com/parkit/parkingsystem/service/ParkingService.java"
    click FCS "https://github.com/openclassrooms-student-center/parkingsystem/blob/master/src/main/java/com/parkit/parkingsystem/service/FareCalculatorService.java"

    %% Click Events for Data Persistence Layer
    click PSD "https://github.com/openclassrooms-student-center/parkingsystem/blob/master/src/main/java/com/parkit/parkingsystem/dao/ParkingSpotDAO.java"
    click TD "https://github.com/openclassrooms-student-center/parkingsystem/blob/master/src/main/java/com/parkit/parkingsystem/dao/TicketDAO.java"
    click DBC "https://github.com/openclassrooms-student-center/parkingsystem/blob/master/src/main/java/com/parkit/parkingsystem/config/DataBaseConfig.java"

    %% Click Events for Domain Models
    click PMS "https://github.com/openclassrooms-student-center/parkingsystem/blob/master/src/main/java/com/parkit/parkingsystem/model/ParkingSpot.java"
    click TM "https://github.com/openclassrooms-student-center/parkingsystem/blob/master/src/main/java/com/parkit/parkingsystem/model/Ticket.java"
    click CONST "https://github.com/openclassrooms-student-center/parkingsystem/tree/master/src/main/java/com/parkit/parkingsystem/constants"

    %% Click Events for Testing Components
    click FCT "https://github.com/openclassrooms-student-center/parkingsystem/blob/master/src/test/java/com/parkit/parkingsystem/FareCalculatorServiceTest.java"
    click PST "https://github.com/openclassrooms-student-center/parkingsystem/blob/master/src/test/java/com/parkit/parkingsystem/ParkingServiceTest.java"
    click PDT "https://github.com/openclassrooms-student-center/parkingsystem/blob/master/src/test/java/com/parkit/parkingsystem/integration/ParkingDataBaseIT.java"
    click DTC "https://github.com/openclassrooms-student-center/parkingsystem/blob/master/src/test/java/com/parkit/parkingsystem/integration/config/DataBaseTestConfig.java"
    click DPS "https://github.com/openclassrooms-student-center/parkingsystem/blob/master/src/test/java/com/parkit/parkingsystem/integration/service/DataBasePrepareService.java"
```
