# vectorgrp/xcp-lite architecture

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

- Interactive diagram: https://gitdiagram.com/vectorgrp/xcp-lite
- Repository: https://github.com/vectorgrp/xcp-lite

## Overview

##### Main Components

a) Core Components:
- XCP Server (C/C++ from XCPlite)
- Transport Layer (Ethernet/UDP)
- Protocol Layer
- Rust API Layer
- A2L Generator
- Calibration System
- Measurement System

b) External Components:
- CANape Tool (Client)
- Target Application

**[Transport Layer]**
- ↑↓
**[XCP Protocol Layer]**
- ↑↓
**[Core XCP Server]**
- ↑↓
**[Rust API Layer]**
- ↑↓
**[Application Layer]**

##### Key Elements to Highlight

a) Data Flow Components:
- Measurement Data Path
- Calibration Data Path
- A2L Description Generation
- Event System

b) Thread Management:
- RX/TX Server Threads
- Application Threads
- Thread-safe Calibration Access

##### Specific Implementation Details

**[Xcp Singleton]**
- ↓
**[XcpEvent] ← → [CalSeg<T>]**
- ↓            ↓
**[Measurement] [Calibration]**

##### Implementation Notes

- The separation between C/C++ and Rust components
- Thread-safe calibration access mechanisms
- Event-based measurement system
- A2L generation flow

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External
        CANape["CANape Tool (Client)"]:::external
        TargetApp["Target Application"]:::external
    end

    subgraph Transport
        TL["Transport Layer (Ethernet/UDP)"]:::transport
        TQ["Transport Queue"]:::transport
        PI["Platform Interface"]:::platform
        click TL "https://github.com/vectorgrp/xcp-lite/blob/master/xcplib/src/xcpEthTl.h"
        click TQ "https://github.com/vectorgrp/xcp-lite/blob/master/xcplib/src/xcpTlQueue.h"
        click PI "https://github.com/vectorgrp/xcp-lite/blob/master/xcplib/src/platform.h"
    end

    subgraph Protocol
        PL["Protocol Layer"]:::protocol
        click PL "https://github.com/vectorgrp/xcp-lite/blob/master/xcplib/src/xcp.h"
    end

    subgraph Core
        XS["XCP Server"]:::core
        click XS "https://github.com/vectorgrp/xcp-lite/blob/master/xcplib/src/xcpLite.h"
    end

    subgraph "Rust API"
        RAL["Rust API Layer"]:::rust
        TM["Thread Management"]:::rust
        click RAL "https://github.com/vectorgrp/xcp-lite/blob/master/src/xcp/xcplib_rs.rs"
        click TM "https://github.com/vectorgrp/xcp-lite/blob/master/src/xcp/xcplib.rs"
    end

    subgraph "Application Components"
        A2L["A2L Generator"]:::app
        CS["Calibration System"]:::app
        MS["Measurement System"]:::app
        IDL["IDL Generator"]:::app
        TS["Type System"]:::app
        CI["Client Interface"]:::app
        click A2L "https://github.com/vectorgrp/xcp-lite/blob/master/src/reg/registry/a2l_writer.rs"
        click CS "https://github.com/vectorgrp/xcp-lite/blob/master/src/xcp/cal/cal_seg.rs"
        click MS "https://github.com/vectorgrp/xcp-lite/blob/master/src/xcp/daq/daq_event.rs"
        click IDL "https://github.com/vectorgrp/xcp-lite/blob/master/xcp_idl_generator/src/lib.rs"
        click TS "https://github.com/vectorgrp/xcp-lite/blob/master/xcp_type_description/src/lib.rs"
        click CI "https://github.com/vectorgrp/xcp-lite/blob/master/xcp_client/src/xcp_client.rs"
    end

    %% Connections
    CANape <--> TL
    TL <--> TQ
    TQ <--> PL
    PL <--> XS
    XS <--> RAL
    RAL <--> TM
    TM --> A2L & CS & MS
    PI --- TL & TQ
    CS & MS --> TargetApp
    TS --> A2L & IDL
    CI --> RAL

    %% Styles
    classDef external fill:#FFE5CC,stroke:#FF9933
    classDef transport fill:#CCE5FF,stroke:#3399FF
    classDef protocol fill:#E5CCFF,stroke:#9933FF
    classDef core fill:#FFB3B3,stroke:#FF3333
    classDef rust fill:#CCFFCC,stroke:#33FF33
    classDef app fill:#E5E5E5,stroke:#666666
    classDef platform fill:#FFFFCC,stroke:#FFFF33

    %% Legend
    subgraph Legend
        L1["External Components"]:::external
        L2["Transport Layer"]:::transport
        L3["Protocol Layer"]:::protocol
        L4["Core Components"]:::core
        L5["Rust API"]:::rust
        L6["Application Components"]:::app
        L7["Platform Interface"]:::platform
    end
```
