# radarlabs/radar-sdk-ios architecture

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

- Interactive diagram: https://gitdiagram.com/radarlabs/radar-sdk-ios
- Repository: https://github.com/radarlabs/radar-sdk-ios

## Overview

##### Project Type and Purpose
This is a native iOS SDK project that provides location services, geofencing, and tracking capabilities. It's designed to be integrated into other iOS applications as a dependency.

##### Main Components

A. Core SDK Layer (RadarSDK)
- Location Services Management
- API Communication
- Event Handling
- Configuration Management
- Storage Management

B. Motion SDK Layer (RadarSDKMotion)
- Motion Detection Services
- Activity Recognition

C. External Interfaces
- iOS Location Services
- Radar Backend API
- Client Applications

**┌─────────────────────────────────────────────────────────────┐**
- Client Application                       │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────────┐**
- RadarSDK Core                        │
- ┬──────────────────┬────────────────────────┤
- Location Manager│  API Client      │ Event Handler          │
- ┼──────────────────┼────────────────────────┤
- Geofencing      │  Context Manager │ Trip Tracking          │
- ┼──────────────────┼────────────────────────┤
- Place Detection │  User Management │ Verification System    │
- ┴──────────────────┴────────────────────────┘
- ↕
**┌─────────────────────────────────────────────────────────────┐**
- RadarSDKMotion                         │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────────┐**
- iOS Platform Services                       │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────────┐**
- Radar Backend API                       │
- ┘

##### Important Implementation Details to Highlight

Key Managers:
- RadarLocationManager
- RadarAPIClient
- RadarActivityManager
- RadarVerificationManager
- RadarBeaconManager

Data Models:
- RadarUser
- RadarEvent
- RadarContext
- RadarPlace
- RadarGeofence

##### Integration Points
- SDK initialization flow
- Permission handling
- Tracking options configuration
- Event delegation pattern

##### Optional components

- How the SDK integrates with their applications
- The flow of location data through the system
- How different components interact
- Where to implement custom behavior
- How to debug issues

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Application Layer"]
        App[Client App Integration]
    end

    subgraph Core["Core SDK Layer"]
        direction TB
        RadarMain["Main SDK Interface"]:::core
        
        subgraph Managers["Key Managers"]
            direction TB
            LocationMgr["Location Manager"]:::manager
            APIMgr["API Client"]:::manager
            ActivityMgr["Activity Manager"]:::manager
            VerifyMgr["Verification Manager"]:::manager
            BeaconMgr["Beacon Manager"]:::manager
        end

        subgraph Models["Data Models"]
            direction TB
            User["User Model"]:::model
            Event["Event Model"]:::model
            Context["Context Model"]:::model
            Place["Place Model"]:::model
            Geofence["Geofence Model"]:::model
        end

        subgraph Core_Services["Core Services"]
            direction TB
            Config["Configuration"]:::service
            Storage["Storage Management"]:::service
            EventHandler["Event Handler"]:::service
            APIHelper["API Helper"]:::service
        end
    end

    subgraph Motion["Motion SDK Layer"]
        MotionServices["Motion Detection Services"]:::motion
        ActivityRecog["Activity Recognition"]:::motion
    end

    subgraph External["External Layer"]
        direction TB
        iOSLocation["iOS Location Services"]:::external
        RadarAPI["Radar Backend API"]:::external
    end

    %% Connections
    App <--> RadarMain
    RadarMain <--> Managers
    RadarMain <--> Models
    RadarMain <--> Core_Services
    Managers <--> Models
    Managers <--> Core_Services
    Managers <--> Motion
    Motion <--> External
    Managers <--> External

    %% Click Events
    click Core "https://github.com/radarlabs/radar-sdk-ios/tree/master//RadarSDK/"
    click Motion "https://github.com/radarlabs/radar-sdk-ios/tree/master//RadarSDKMotion/"
    click LocationMgr "https://github.com/radarlabs/radar-sdk-ios/blob/master//RadarSDK/RadarLocationManager.h"
    click APIMgr "https://github.com/radarlabs/radar-sdk-ios/blob/master//RadarSDK/RadarAPIClient.h"
    click ActivityMgr "https://github.com/radarlabs/radar-sdk-ios/blob/master//RadarSDK/RadarActivityManager.h"
    click VerifyMgr "https://github.com/radarlabs/radar-sdk-ios/blob/master//RadarSDK/RadarVerificationManager.h"
    click BeaconMgr "https://github.com/radarlabs/radar-sdk-ios/blob/master//RadarSDK/RadarBeaconManager.h"
    click User "https://github.com/radarlabs/radar-sdk-ios/blob/master//RadarSDK/Include/RadarUser.h"
    click Event "https://github.com/radarlabs/radar-sdk-ios/blob/master//RadarSDK/Include/RadarEvent.h"
    click Context "https://github.com/radarlabs/radar-sdk-ios/blob/master//RadarSDK/Include/RadarContext.h"
    click Place "https://github.com/radarlabs/radar-sdk-ios/blob/master//RadarSDK/Include/RadarPlace.h"
    click Geofence "https://github.com/radarlabs/radar-sdk-ios/blob/master//RadarSDK/Include/RadarGeofence.h"
    click Config "https://github.com/radarlabs/radar-sdk-ios/blob/master//RadarSDK/RadarConfig.h"
    click Storage "https://github.com/radarlabs/radar-sdk-ios/blob/master//RadarSDK/RadarFileStorage.h"
    click EventHandler "https://github.com/radarlabs/radar-sdk-ios/blob/master//RadarSDK/Include/RadarDelegate.h"
    click APIHelper "https://github.com/radarlabs/radar-sdk-ios/blob/master//RadarSDK/RadarAPIHelper.h"
    click RadarMain "https://github.com/radarlabs/radar-sdk-ios/blob/master//RadarSDK/Include/Radar.h"

    %% Styling
    classDef core fill:#2374ab
    classDef manager fill:#48a9a6
    classDef model fill:#4ea5d9
    classDef service fill:#44cfcb
    classDef motion fill:#9067c6
    classDef external fill:#c97064
    
    %% Legend
    subgraph Legend
        direction TB
        L1["Core Components"]:::core
        L2["Managers"]:::manager
        L3["Data Models"]:::model
        L4["Services"]:::service
        L5["Motion Components"]:::motion
        L6["External Services"]:::external
    end
```
