# vehicle-telematics-control-unit/backend-gateway-service architecture

> Architecture diagram of the GitHub repository vehicle-telematics-control-unit/backend-gateway-service, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vehicle-telematics-control-unit/backend-gateway-service
- Repository: https://github.com/vehicle-telematics-control-unit/backend-gateway-service

## Overview

##### Project Type and Purpose
- This is a containerized backend gateway service written in C++.
- Its purpose is to communicate directly with a back-end server using the VSOME/IP protocol for service discovery/communication, while leveraging an HTTP-Builder module to generate HTTP requests.
- The README and the repository structure indicate that the service is intended to run in Docker containers, built with CMake, and supports multiple platforms.

##### Key Components
a. Container Environment:
– The Docker container built via the provided Dockerfile and boost_build/dockerfile.
– Indicate multi-platform build support (linux/amd64, linux/arm64).

b. Application Core:
– Source code under build_src/src (including main.cpp, Authenticator.hpp, Internetconnectivity.hpp, servicesId.hpp).
– Illustrate the “core” application that initializes and orchestrates the VSOME/IP client service and HTTP Builder modules.

c. Dependencies and Modules:
– HTTP Client Module:
- Located under build_src/dependencies/http_client/
- Components like GetRequestClient, PostRequestClient, PutRequestClient, HttpRequest, and HttpRequestBuilder.
- Builder pattern applied in generating HTTP requests.
– VSOME/IP Service Module:
- Located under build_src/dependencies/someipService/
- Contains ServiceManagerAdapter to interact with the VSOME/IP API.
– JSON Support:
- Provided via the nlohmann/json.hpp dependency for handling JSON (likely used in HTTP payloads or configurations).

d. Build and Configuration Elements:
– CMakeLists.txt files for build orchestration (both at the project level in build_src and for individual dependencies).
– Additional assets such as private_key.der and certificates (ChainedCertficate.cer) used for secure communications.

##### Relationships and Data Flow
- The core application (main.cpp) acts as the entry point and ties together the dependencies.
- It uses the HTTP Client module (via HTTP Request Builder) to create and send HTTP requests to the backend server.
- Simultaneously, the VSOME/IP client (through ServiceManagerAdapter) handles protocol-specific communication.
– Initialization flow from main.cpp to HTTP client builder routines.
– Interaction flow from the VSOME/IP service to the backend server.
– Possible feedback loops if response handling is integrated.

##### Architectural Patterns and Design Principles
- Containerization: Emphasize how the entire application is packaged as a Docker container for consistent deployment.
- Builder Pattern: Used in creating complex HTTP requests via the HTTP Request Builder.
- Modular Design: Clear separation between HTTP communication (HTTP client dependency) and protocol-specific handling (VSOME/IP service dependency) suggests decoupled modules.
- Build Automation: Use of CMake for configuring and building the C++ modules and Docker for containerization.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Docker Container Environment and its internal components
    subgraph "Docker Container"
        D1["Docker Container"]:::container
        subgraph "Core Application"
            A["C++ Core Application"]:::core
        end
        subgraph "Modules"
            H["HTTP Client Module (Builder Pattern)"]:::module
            S["VSOME/IP Service Module"]:::module
        end
        subgraph "Security"
            SK["private_key.der"]:::security
            SC["ChainedCertficate.cer"]:::security
        end
        D1 --> A
        A -->|"initializes"| H
        A -->|"initializes"| S
    end

    %% External Back-end Server handling outgoing communications
    B["Back-end Server"]:::external
    A -->|"HTTP_requests"| B
    S -->|"VSOME/IP_calls"| B

    %% Additional Dependencies and Build Elements
    J["JSON Library"]:::library
    A -.->|"Uses"| J

    C["Build Automation (CMake)"]:::build
    D1 -.->|"Built_with"| C

    %% Click Events for component mapping
    click D1 "https://github.com/vehicle-telematics-control-unit/backend-gateway-service/tree/main/Dockerfile"
    click D1 "https://github.com/vehicle-telematics-control-unit/backend-gateway-service/tree/main/boost_build/dockerfile"
    click A "https://github.com/vehicle-telematics-control-unit/backend-gateway-service/tree/main/build_src/src"
    click H "https://github.com/vehicle-telematics-control-unit/backend-gateway-service/tree/main/build_src/dependencies/http_client"
    click S "https://github.com/vehicle-telematics-control-unit/backend-gateway-service/tree/main/build_src/dependencies/someipService"
    click J "https://github.com/vehicle-telematics-control-unit/backend-gateway-service/blob/main/build_src/dependencies/nlohmann/json.hpp"
    click C "https://github.com/vehicle-telematics-control-unit/backend-gateway-service/blob/main/build_src/CMakeLists.txt"
    click SK "https://github.com/vehicle-telematics-control-unit/backend-gateway-service/blob/main/build_src/private_key.der"
    click SC "https://github.com/vehicle-telematics-control-unit/backend-gateway-service/blob/main/build_src/ChainedCertficate.cer"

    %% Styles for visual differentiation
    classDef container fill:#f9f,stroke:#333,stroke-width:2px;
    classDef core fill:#9f6,stroke:#333,stroke-width:2px;
    classDef module fill:#6cf,stroke:#333,stroke-width:2px;
    classDef external fill:#fc9,stroke:#333,stroke-width:2px;
    classDef library fill:#cf9,stroke:#333,stroke-width:2px;
    classDef build fill:#ffc,stroke:#333,stroke-width:2px;
    classDef security fill:#f99,stroke:#333,stroke-width:2px;
```
