# getsentry/sentry-native architecture

> Architecture diagram of the GitHub repository getsentry/sentry-native, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/getsentry/sentry-native
- Repository: https://github.com/getsentry/sentry-native

## Overview

##### Main Components

a. Core Components:
- Sentry Core Engine
- Transport Layer
- Backend Systems
- Integration Layer
- Platform-specific Modules

b. External Dependencies:
- Crashpad
- Breakpad
- libunwindstack-ndk
- Third-party libraries

##### Architectural Layers

**┌─────────────────────────────────────────────────────────────┐**
- Application Layer                         │
- ┬─────────────────────────────────┘

**┌───────────────────────────▼─────────────────────────────────┐**
- Sentry Native SDK                         │
- ┤
- ┌─────────────┐  ┌──────────────┐  ┌────────────────────┐  │
- Integration  │  │   Core SDK    │  │ Platform-specific  │  │
- Layer      │  │              │  │     Modules        │  │
- ┘  └──────────────┘  └────────────────────┘  │

- ┌─────────────┐  ┌──────────────┐  ┌────────────────────┐  │
- Transport  │  │   Backend    │  │     Utilities      │  │
- Layer     │  │   Systems    │  │                    │  │
- ┘  └──────────────┘  └────────────────────┘  │
- ┬─────────────────────────────────┘

**┌────────────────────────▼─────────────────────────────────┐**
- External Dependencies                      │
- ┘

##### Component Details

a. Core SDK:
- Error/Crash Handling
- Event Processing
- Configuration Management
- Session Management
- Scope & Context Management

b. Transport Layer:
- HTTP Transport (curl/winhttp)
- Disk Transport
- Function Transport
- Custom Transport Options

c. Backend Systems:
- Crashpad Backend
- Breakpad Backend
- In-process Backend
- Platform-specific Handlers

**Application → Core SDK → Backend Systems → Transport Layer → Sentry Server**
- ↑          ↕            ↕                   ↕
- ┴────────────┴───────────────────┘
- Error/Crash Data Flow

##### Additional Elements

- Platform Support (Windows/Linux/macOS/Android)
- Build System Integration (CMake)
- Testing Infrastructure
- NDK Integration for Android

##### Implementation Notes

- Cross-platform compatibility
- Multiple backend support
- Flexible transport options
- Integration capabilities
- Error handling flow

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Application Layer"
        APP[Native Application]
    end

    subgraph "Sentry Native SDK"
        subgraph "Core Components"
            CORE[Core SDK Engine]:::core
            CONFIG[Configuration Management]:::core
            SESSION[Session Management]:::core
            SCOPE[Scope Management]:::core
            MEM[Memory Management]:::core
        end

        subgraph "Transport Layer"
            TRANS[Transport System]
            CURL[HTTP Transport]:::transport
            DISK[Disk Transport]:::transport
            FUNC[Function Transport]:::transport
            WINHTTP[Windows HTTP]:::transport
        end

        subgraph "Backend Systems"
            BACK[Backend System]
            CRASH[Crashpad Backend]:::backend
            BREAK[Breakpad Backend]:::backend
            INPROC[In-process Backend]:::backend
        end

        subgraph "Integration Layer"
            INT[Integration System]
            QT[Qt Integration]:::integration
        end

        subgraph "Platform-specific Modules"
            MOD[Module Finder]
            WIN_MOD[Windows Module]:::platform
            LIN_MOD[Linux Module]:::platform
            APP_MOD[Apple Module]:::platform
        end
    end

    subgraph "External Dependencies"
        CRASHPAD[Crashpad]:::external
        BREAKPAD[Breakpad]:::external
        UNWIND[libunwindstack-ndk]:::external
    end

    subgraph "Android NDK Support"
        NDK[NDK Interface]:::android
        JAVA[Java Bridge]:::android
    end

    %% Relationships
    APP --> CORE
    CORE --> CONFIG
    CORE --> SESSION
    CORE --> SCOPE
    CORE --> MEM
    
    CORE --> TRANS
    TRANS --> CURL & DISK & FUNC & WINHTTP
    
    CORE --> BACK
    BACK --> CRASH & BREAK & INPROC
    
    CORE --> INT
    INT --> QT
    
    CORE --> MOD
    MOD --> WIN_MOD & LIN_MOD & APP_MOD
    
    CRASH --> CRASHPAD
    BREAK --> BREAKPAD
    NDK --> UNWIND
    
    CORE --> NDK
    NDK --> JAVA

    %% Click Events
    click CORE "https://github.com/getsentry/sentry-native/blob/master/src/sentry_core.c"
    click CURL "https://github.com/getsentry/sentry-native/blob/master/src/transports/sentry_transport_curl.c"
    click DISK "https://github.com/getsentry/sentry-native/blob/master/src/transports/sentry_disk_transport.c"
    click FUNC "https://github.com/getsentry/sentry-native/blob/master/src/transports/sentry_function_transport.c"
    click WINHTTP "https://github.com/getsentry/sentry-native/blob/master/src/transports/sentry_transport_winhttp.c"
    click CRASH "https://github.com/getsentry/sentry-native/blob/master/src/backends/sentry_backend_crashpad.cpp"
    click BREAK "https://github.com/getsentry/sentry-native/blob/master/src/backends/sentry_backend_breakpad.cpp"
    click INPROC "https://github.com/getsentry/sentry-native/blob/master/src/backends/sentry_backend_inproc.c"
    click QT "https://github.com/getsentry/sentry-native/blob/master/src/integrations/sentry_integration_qt.cpp"
    click WIN_MOD "https://github.com/getsentry/sentry-native/blob/master/src/modulefinder/sentry_modulefinder_windows.c"
    click LIN_MOD "https://github.com/getsentry/sentry-native/blob/master/src/modulefinder/sentry_modulefinder_linux.c"
    click APP_MOD "https://github.com/getsentry/sentry-native/blob/master/src/modulefinder/sentry_modulefinder_apple.c"
    click CRASHPAD "https://github.com/getsentry/sentry-native/tree/master/external/crashpad"
    click BREAKPAD "https://github.com/getsentry/sentry-native/tree/master/external/breakpad"
    click UNWIND "https://github.com/getsentry/sentry-native/tree/master/external/libunwindstack-ndk"
    click NDK "https://github.com/getsentry/sentry-native/blob/master/ndk/lib/src/main/jni/sentry.c"
    click JAVA "https://github.com/getsentry/sentry-native/tree/master/ndk/lib/src/main/java/io/sentry/ndk"
    click MEM "https://github.com/getsentry/sentry-native/blob/master/src/sentry_alloc.c"
    click CONFIG "https://github.com/getsentry/sentry-native/blob/master/src/sentry_options.c"
    click SESSION "https://github.com/getsentry/sentry-native/blob/master/src/sentry_session.c"
    click SCOPE "https://github.com/getsentry/sentry-native/blob/master/src/sentry_scope.c"

    %% Styles
    classDef core fill:#2b5797,color:#fff
    classDef transport fill:#1f9c44,color:#fff
    classDef backend fill:#ff8c00,color:#fff
    classDef integration fill:#8064a2,color:#fff
    classDef platform fill:#4472c4,color:#fff
    classDef external fill:#7f7f7f,color:#fff
    classDef android fill:#ffc000,color:#000
```
