# dann41/simuloc architecture

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

- Interactive diagram: https://gitdiagram.com/dann41/simuloc
- Repository: https://github.com/dann41/simuloc

## Overview

##### Main Components
- Domain Layer: At the heart of the system you have a rich domain model representing Trips, Steps, Positions, and various StepCalculators (e.g., Straight, Standstill, Sinusoidal, Route). This layer includes business objects such as Trip, Step, Coordinates, and value objects like CreationDate, Name, etc.
- Application Layer: This contains the application services like TripCreator, TripRenamer, and ReactiveTripPlayer which coordinate interactions between the UI/console, domain logic, and external interfaces.
- Infrastructure Layer: This supports the Domain with persistence and other side concerns. For example, the InMemoryTripRepository provides an in-memory implementation of TripRepository. There are also shared validations and additional utilities.
- Presentation/Console Layer: Located in the “console” directory, this module acts as an entry point (ConsoleApplication) and has components like the ConsoleTripPlayerListener to interact with and display simulation events (trip progress and positions).

##### Relationships and Interactions
- The Application Layer interacts with the Domain Layer: for instance, TripCreator uses domain entities (Trip, Step, etc.) to aggregate a trip.
- The domain objects (e.g., StepCalculators) define the simulation logic for the movement between geographic positions.
- The Application Layer components (like ReactiveTripPlayer) emit simulated positions which are then fed to Domain players (TripPlayer, TripPlayerObservable) through listener interfaces (ReactiveTripPlayerListener, TripPlayerListener).
- The Infrastructure Layer supports the Domain by acting as a persistence or state management mechanism (e.g., InMemoryTripRepository).
- The Console Application acts as the user interface in a non-web context, wiring up the application services and listeners for live simulation output.

##### Architectural Patterns and Design Principles
- Layered/Hexagonal Architecture: You have a clear separation between Domain, Application, Infrastructure, and Presentation. These layers interact with each other typically via well-defined interfaces.
- Domain-Driven Design (DDD): The domain model defines ubiquitous language concepts described in the README (Trip, Step, Position, etc.) and is central to the simulation logic.
- Observer/Reactive Pattern: With classes like ReactiveTripPlayer and corresponding listeners, the system uses event/listener patterns to propagate position updates.

##### Relevant Technologies, Frameworks, and Tools
- Java as the programming language.
- Gradle for building and dependency management (see build.gradle files in the “app” and “console” directories).
- External Continuous Integration tools (Travis CI, Codecov) are also signaled via configuration files.
- The test suite is well organized under app/src/test indicating a strong testing culture supporting the design.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Domain Layer
    subgraph "Domain Layer"
        DomainEntities["Domain Entities (Trip, Step, Position, Value Objects)"]:::domain
        StepCalculators["Step Calculators (Straight, Standstill, Sinusoidal, Route)"]:::domain
    end

    %% Application Layer
    subgraph "Application Layer"
        TripCreator["TripCreator Service"]:::application
        TripRenamer["TripRenamer Service"]:::application
        ReactivePlayer["ReactiveTripPlayer Service"]:::application
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        InMemRepo["Trip Repository (InMemory)"]:::infrastructure
        SharedValidations["Shared Validations & Utilities"]:::infrastructure
    end

    %% Presentation/Console Layer
    subgraph "Presentation/Console Layer"
        ConsoleApp["Console Application Entry Point"]:::presentation
        ConsoleListener["Console Trip Player Listener"]:::presentation
    end

    %% Relationships
    ConsoleApp -->|"triggers"| TripCreator
    ConsoleApp -->|"triggers"| ReactivePlayer
    ReactivePlayer -->|"emits"| ConsoleListener
    TripCreator -->|"creates"| DomainEntities
    TripRenamer -->|"updates"| DomainEntities
    DomainEntities -->|"persists"| InMemRepo
    DomainEntities -->|"validates"| SharedValidations
    StepCalculators -->|"calculates"| DomainEntities

    %% Click Events
    click DomainEntities "https://github.com/dann41/simuloc/tree/main/app/src/main/java/com/dglapps/simuloc/domain"
    click StepCalculators "https://github.com/dann41/simuloc/tree/main/app/src/main/java/com/dglapps/simuloc/domain/stepcalculator"
    click TripCreator "https://github.com/dann41/simuloc/blob/main/app/src/main/java/com/dglapps/simuloc/application/tripcreator/TripCreator.java"
    click TripRenamer "https://github.com/dann41/simuloc/blob/main/app/src/main/java/com/dglapps/simuloc/application/triprename/TripRenamer.java"
    click ReactivePlayer "https://github.com/dann41/simuloc/blob/main/app/src/main/java/com/dglapps/simuloc/application/player/ReactiveTripPlayer.java"
    click InMemRepo "https://github.com/dann41/simuloc/blob/main/app/src/main/java/com/dglapps/simuloc/infrastructure/repository/InMemoryTripRepository.java"
    click SharedValidations "https://github.com/dann41/simuloc/tree/main/app/src/main/java/com/dglapps/simuloc/shared/validation"
    click ConsoleApp "https://github.com/dann41/simuloc/blob/main/console/src/main/java/com/dglapps/simuloc/consoleapp/ConsoleApplication.java"
    click ConsoleListener "https://github.com/dann41/simuloc/blob/main/console/src/main/java/com/dglapps/simuloc/consoleapp/infrastructure/player/listener/ConsoleTripPlayerListener.java"

    %% Styles
    classDef domain fill:#e3f2fd,stroke:#1e88e5,stroke-width:2px;
    classDef application fill:#e8f5e9,stroke:#43a047,stroke-width:2px;
    classDef infrastructure fill:#f5f5f5,stroke:#9e9e9e,stroke-width:2px;
    classDef presentation fill:#fff3e0,stroke:#fb8c00,stroke-width:2px;
```
