# jolibrain/deepdetect architecture

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

- Interactive diagram: https://gitdiagram.com/jolibrain/deepdetect
- Repository: https://github.com/jolibrain/deepdetect

## Overview

##### Project Type and Purpose
- DeepDetect is a C++11-based, open-source machine learning server and API.
- It exposes REST/JSON and CLI interfaces for both training and inference, orchestrates data connectors, model generators, and multiple ML backends (Caffe, TensorFlow, PyTorch, XGBoost, etc.), and manages filesystem‐based models, logging, stats, and templates.

##### File-Structure Analysis
- Top‐Level Directories:
- clients/  – Python REST client library
- demo/     – Sample apps (imgdetect, imgsearch, segmentation, etc.)
- docker/   – Dockerfiles & scripts for container builds
- docs/     – Architecture, API, Docker, CI documentation
- examples/ – End-to-end sample configurations
- src/      – Core C++ server code:
– http/, jsonapi/, commandlineapi/ – API layers
– dto/, resources/, service_stats/ – Data types & telemetry
– backends/ – Pluggable ML library adapters
– input/output connector strategies
– generators/, graph/ – Network definition & pipeline
- templates/ – Prebuilt network configurations
- tests/, tools/, ci/ – Unit tests, helper scripts, CI pipelines

##### README Insights
- Emphasizes a high-level, generic API, support for many ML libraries, and JSON communication.
- Mentions key subsystems: Docker, Python/JS clients, Swagger-based docs, model templates, similarity search, various connectors.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Clients"
        PythonClient["Python REST Client"]:::clients
        JSClient["JavaScript Web Client"]:::clients
        CLIClient["CLI Interface"]:::clients
    end

    subgraph "API Layer"
        HTTPServer["HTTP Server Layer"]:::api
        RESTJSONAPI["JSON API Layer"]:::api
        OatppJSONAPI["Oatpp JSON API"]:::api
        CLIAPI["Command-line API"]:::api
    end

    subgraph "Core Engine"
        DeepDetect["DeepDetect Entry Point"]:::core
        ServiceManager["Service Manager / MLService"]:::core
        ChainActions["Chain Actions"]:::core
        GraphBuilder["Graph Builder"]:::core
    end

    subgraph "Connectors & Generators"
        InputConnectors["Input Connector Strategies"]:::connectors
        OutputConnectors["Output Connector Strategies"]:::connectors
        ModelGenerators["Model Generators & Templates"]:::connectors
    end

    subgraph "Backend Plugins"
        MLBackends["ML Backend Plugins"]:::backends
    end

    subgraph "Filesystem & Templates"
        TemplatesStore["Template Store"]:::storage
        ModelStore["Model Store"]:::storage
    end

    subgraph "Resources & Telemetry"
        Logging["Logging (spdlog)"]:::resources
        ServiceStats["Service Stats"]:::resources
    end

    Docker["Docker Containers"]:::infra

    PythonClient -->|Requests| HTTPServer
    JSClient -->|Requests| HTTPServer
    CLIClient -->|CLI Commands| CLIAPI

    HTTPServer -->|calls| DeepDetect
    RESTJSONAPI -->|calls| DeepDetect
    OatppJSONAPI -->|calls| DeepDetect
    CLIAPI -->|calls| DeepDetect

    DeepDetect --> ServiceManager
    ServiceManager --> ChainActions
    ChainActions --> GraphBuilder

    ServiceManager --> InputConnectors
    ServiceManager --> ModelGenerators
    ServiceManager --> MLBackends
    ServiceManager --> OutputConnectors

    InputConnectors --> ModelStore
    ModelGenerators --> TemplatesStore
    MLBackends -->|loads/runtime| Docker
    MLBackends -->|executes| Docker

    ServiceManager --> Logging
    ServiceManager --> ServiceStats
    Logging --> ModelStore
    ServiceStats --> ModelStore

    Docker --> ModelStore

    click PythonClient "https://github.com/jolibrain/deepdetect/tree/master/clients/python/dd_client"
    click JSClient "https://github.com/jolibrain/deepdetect/blob/master/demo/imgdetect/js/main.js"
    click CLIClient "https://github.com/jolibrain/deepdetect/blob/master/src/commandlineapi.cc"
    click HTTPServer "https://github.com/jolibrain/deepdetect/tree/master/src/http/"
    click RESTJSONAPI "https://github.com/jolibrain/deepdetect/blob/master/src/jsonapi.cc"
    click OatppJSONAPI "https://github.com/jolibrain/deepdetect/blob/master/src/oatppjsonapi.cc"
    click CLIAPI "https://github.com/jolibrain/deepdetect/blob/master/src/commandlineapi.cc"
    click DeepDetect "https://github.com/jolibrain/deepdetect/blob/master/src/deepdetect.cc"
    click ServiceManager "https://github.com/jolibrain/deepdetect/blob/master/src/mlservice.h"
    click ChainActions "https://github.com/jolibrain/deepdetect/blob/master/src/chain_actions.cc"
    click GraphBuilder "https://github.com/jolibrain/deepdetect/tree/master/src/graph/"
    click ModelGenerators "https://github.com/jolibrain/deepdetect/tree/master/src/generators/"
    click MLBackends "https://github.com/jolibrain/deepdetect/tree/master/src/backends/"
    click ServiceStats "https://github.com/jolibrain/deepdetect/blob/master/src/service_stats.cc"
    click Logging "https://github.com/jolibrain/deepdetect/blob/master/src/dd_spdlog.h"
    click Docker "https://github.com/jolibrain/deepdetect/tree/master/docker/"

    classDef clients fill:#D6B6E6,stroke:#333,stroke-width:1px;
    classDef api fill:#C6E5B3,stroke:#333,stroke-width:1px;
    classDef core fill:#AED6F1,stroke:#333,stroke-width:1px;
    classDef connectors fill:#9FDAE2,stroke:#333,stroke-width:1px;
    classDef backends fill:#FDBD78,stroke:#333,stroke-width:1px;
    classDef storage fill:#E0E0E0,stroke:#333,stroke-width:1px;
    classDef resources fill:#F7A5A0,stroke:#333,stroke-width:1px;
    classDef infra fill:#D6A77F,stroke:#333,stroke-width:1px;
```
