# nvidia-ai-iot/deepstream_python_apps architecture

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

- Interactive diagram: https://gitdiagram.com/nvidia-ai-iot/deepstream_python_apps
- Repository: https://github.com/nvidia-ai-iot/deepstream_python_apps

## Overview

Based on your provided file tree and README, this repository is clearly an open‐source “DeepStream Python Apps” project. It primarily offers Python bindings (using Pybind11) for the NVIDIA DeepStream SDK and a variety of sample applications that demonstrate how to build DeepStream pipelines using Python and gstreamer. The design both exposes a bindings layer (in the “bindings” directory) that wraps DeepStream data structures and a set of example “apps” that cover a range of use cases (e.g., RTSP streaming, object detection, optical flow, analytics, segmentation, etc.).

##### Main Components Identification
- Python Bindings Layer:
- Located in the “bindings” directory and its associated documentation.
- Uses Pybind11 to expose DeepStream metadata structures and functions to Python.
- Acts as a bridge between DeepStream C/C++ code and Python applications.
- Sample Application Layer:
- Found in the “apps” directory, which contains numerous subdirectories (e.g., deepstream-test1, deepstream-test2, deepstream-ssd-parser, deepstream-opticalflow, etc.).
- Each subdirectory is a self-contained DeepStream pipeline application.
- Contains configuration files, pipeline scripts, and sometimes custom binding tests.
- Common Utilities:
- “apps/common” holds shared modules (e.g., FPS measurement, utility functions, platform info, bus call helpers) to be used across test applications.
- Documentation and Guides:
- “docs” explains the Python API and deep details about the bindings.
- HOWTO and FAQ files in the project root offer guidance on running and extending the apps.
- Testing Infrastructure:
- The “tests” directory, including integration tests and common test utilities, is meant to ensure pipelines work correctly.

##### Relationships and Interactions Between Components
- The Python bindings are used by every sample application: they translate lower-level DeepStream SDK functionalities into Python callable functions.
- The sample applications build different GStreamer pipelines (via gstreamer’s gst-python). They then incorporate the bindings layer functions to process metadata like object detection, tracking, segmentation, or other analytics.
- The “apps/common” utilities provide shared support (e.g., logging, performance measurements) which are integrated within many individual pipeline applications.
- Documentation and tests interact with the rest of the project by guiding usage and verifying correct pipeline behavior.

##### Architectural Patterns & Design Principles
- Layered Architecture:
- At the bottom, the native DeepStream SDK (external dependency) runs the heavy lifting.
- Next, the bindings layer encapsulates low-level interactions with the SDK in a Python-friendly manner.
- Above that, multiple sample application pipelines (each with its pipeline-specific configurations) demonstrate a higher-level orchestration.
- Modularity:
- Each sample application is designed as a standalone module, illustrating a plug-and-play approach.
- The common utilities further exemplify code reuse.
- Extensibility:
- The presence of custom binding tests and guides for creating new bindings shows that the design is meant to be extended for custom use cases.

##### Relevant Technologies and Frameworks
- NVIDIA DeepStream SDK (the core engine driving pipelines)
- GStreamer via gst-python (for building and executing media pipelines)
- Pybind11 (for creating Python bindings)
- Python 3.10 (for DS7.1 support) and associated configuration elements
- External inference servers such as Triton (used by deepstream-test3 and deepstream-ssd-parser)

##### Essential Elements
- Python Bindings (highlighting layers like custom binding test, core binding library)
- Sample Pipeline Applications (each as a separate component or a grouped container if detailing common functionalities)
- Shared Utilities/ Common Modules
- Testing and Documentation Modules
- Additionally, show how configuration files (as seen in various apps) feed into pipeline construction.
- Notation for External Services:
- External dependencies such as the DeepStream SDK version 7.1 and, where applicable, inference servers (e.g., Triton).
- Text Labels:
- Optional Visuals:

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Sample Application Layer"
        DS1["DeepStream Test 1 (Object Detection Pipeline)"]:::apps
        RTSP["RTSP Streaming App"]:::apps
        SSD["DeepStream SSD Parser (Inference Pipeline)"]:::apps
    end

    subgraph "Bindings & API Layer"
        Bindings["Python Bindings (Pybind11)"]:::bindings
    end

    subgraph "Support Components"
        Common["Common Utilities"]:::support
        Docs["Documentation & Guides"]:::support
        Tests["Testing Infrastructure"]:::support
    end

    subgraph "External Dependencies"
        DeepStreamSDK["DeepStream SDK 7.1"]:::external
        Triton["Triton Inference Server"]:::external
    end

    %% Application Layer calls Bindings
    DS1 -->|"calls"| Bindings
    RTSP -->|"calls"| Bindings
    SSD -->|"calls"| Bindings

    %% Bindings use the native SDK
    Bindings -->|"uses"| DeepStreamSDK

    %% SSD also interacts with external inference server
    SSD -->|"requests"| Triton

    %% Sample Apps use common utilities
    DS1 -->|"uses"| Common
    RTSP -->|"uses"| Common
    SSD -->|"uses"| Common

    %% Documentation guides the Sample Apps
    Docs -->|"guides"| DS1
    Docs -->|"guides"| RTSP
    Docs -->|"guides"| SSD

    %% Testing verifies the Sample Apps
    Tests -->|"verifies"| DS1
    Tests -->|"verifies"| RTSP
    Tests -->|"verifies"| SSD

    %% Click Events
    click Bindings "https://github.com/nvidia-ai-iot/deepstream_python_apps/tree/master/bindings/"
    click DS1 "https://github.com/nvidia-ai-iot/deepstream_python_apps/tree/master/apps/deepstream-test1"
    click RTSP "https://github.com/nvidia-ai-iot/deepstream_python_apps/tree/master/apps/deepstream-rtsp-in-rtsp-out"
    click SSD "https://github.com/nvidia-ai-iot/deepstream_python_apps/tree/master/apps/deepstream-ssd-parser"
    click Common "https://github.com/nvidia-ai-iot/deepstream_python_apps/tree/master/apps/common/"
    click Docs "https://github.com/nvidia-ai-iot/deepstream_python_apps/tree/master/docs/"
    click Tests "https://github.com/nvidia-ai-iot/deepstream_python_apps/tree/master/tests/"

    %% Styles
    classDef apps fill:#c3f3c3,stroke:#333,stroke-width:2px;
    classDef bindings fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef external fill:#F9DAD0,stroke:#333,stroke-width:2px;
    classDef support fill:#FFE4B5,stroke:#333,stroke-width:2px;
```
