# thephoneproject/advanced-android-camera architecture

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

- Interactive diagram: https://gitdiagram.com/thephoneproject/advanced-android-camera
- Repository: https://github.com/thephoneproject/advanced-android-camera

## Overview

##### Main Components

a. User Interface Layer
- Compose UI Components (found in ui/ directory)
- Camera Preview
- Focus Controls
- Zoom Controls
- Settings Interface

b. Plugin System
- Core Plugin Interface (IPlugin.kt)
- Camera Feature Plugins:
- Photo/Video Modes
- Focus Controls
- Zoom Controls
- Flash Controls
- QR Scanner
- Settings Management

c. Camera Hardware Integration
- Camera2 API Integration
- Hardware Controls
- Device Orientation Management

d. Application Core
- ViewModel (StoneCameraViewModel)
- Application State Management
- Camera Lifecycle Management

##### Component Relationships

- UI Layer → ViewModel (data binding)
- ViewModel → Plugin System (feature management)
- Plugin System → Camera Hardware (camera controls)
- Plugin System → UI Layer (UI updates)

##### Specific Elements

**┌─────────────────────────────────────────────────┐**
- UI Layer                       │
- ┌─────────────┐ ┌──────────┐ ┌───────────────┐ │
- StoneCameraPreview│ │FocusReticle│ │ResponsiveOrientation│ │
- ┘
- ↕
**┌─────────────────────────────────────────────────┐**
- ViewModel Layer                     │
- ┌─────────────────────────┐              │
- StoneCameraViewModel   │              │
- ┘
- ↕
**┌─────────────────────────────────────────────────┐**
- Plugin System                      │
- ┌────────┐ ┌────────┐ ┌────────┐ ┌─────────┐   │
- PhotoMode│ │VideoMode│ │QRScanner│ │Other...│   │
- ┘
- ↕
**┌─────────────────────────────────────────────────┐**
- Camera Hardware Layer                  │
- ┌──────────────┐    ┌────────────────────┐     │
- Camera2 Utils │    │Hardware Controllers│     │
- ┘

##### Implementation Details

- The plugin-based architecture that allows for easy feature addition
- The separation between UI and camera hardware through the ViewModel
- The central role of the Plugin System in managing features
- The responsive nature of the UI layer
- The hardware abstraction through Camera2 Utils

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#9b59b6,stroke:#8e44ad,color:white
    classDef plugin fill:#2ecc71,stroke:#27ae60,color:white
    classDef hardware fill:#f1c40f,stroke:#f39c12,color:black
    classDef utils fill:#95a5a6,stroke:#7f8c8d,color:white

    %% UI Layer
    subgraph UI
        Preview["Camera Preview"]:::ui
        FocusUI["Focus Reticle"]:::ui
        OrientUI["Responsive Orientation"]:::ui
        ZoomUI["Zoom Bar"]:::ui
    end

    %% Core Layer
    subgraph Core
        ViewModel["Stone Camera ViewModel"]:::core
        AppComponent["Stone Camera App"]:::core
        MainApp["Main Application"]:::core
    end

    %% Plugin System
    subgraph Plugins
        IPlugin["Plugin Interface"]:::plugin
        PhotoPlugin["Photo Mode"]:::plugin
        VideoPlugin["Video Mode"]:::plugin
        QRPlugin["QR Scanner"]:::plugin
        FocusPlugin["Tap To Focus"]:::plugin
        ZoomPlugin["Pinch To Zoom"]:::plugin
        FlashPlugin["Flash Controls"]:::plugin
        SettingsPlugin["Settings Tray"]:::plugin
    end

    %% Hardware Layer
    subgraph Hardware
        Camera2["Camera2 Utils"]:::hardware
        Orientation["Orientation Listener"]:::hardware
        CameraInfo["Camera Info"]:::hardware
    end

    %% Relationships
    UI --> ViewModel
    ViewModel --> Plugins
    Plugins --> Hardware
    Plugins --> UI
    Core --> Plugins

    %% Click Events
    click Preview "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/ui/StoneCameraPreview.kt"
    click FocusUI "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/ui/FocusReticle.kt"
    click OrientUI "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/ui/ResponsiveOrientation.kt"
    click ZoomUI "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/ui/ZoomBar.kt"
    click IPlugin "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/plugins/IPlugin.kt"
    click PhotoPlugin "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/plugins/PhotoMode.kt"
    click VideoPlugin "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/plugins/VideoMode.kt"
    click QRPlugin "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/plugins/QRScanner.kt"
    click FocusPlugin "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/plugins/TapToFocus.kt"
    click ZoomPlugin "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/plugins/PinchToZoom.kt"
    click FlashPlugin "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/plugins/Flash.kt"
    click SettingsPlugin "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/plugins/SettingsTray.kt"
    click Camera2 "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/utils/Camera2Utils.kt"
    click Orientation "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/utils/OrientationListener.kt"
    click CameraInfo "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/utils/cameraInfos.kt"
    click ViewModel "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/StoneCameraViewModel.kt"
    click MainApp "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/MyApplication.kt"
    click AppComponent "https://github.com/ThePhoneProject/advanced-android-camera/blob/main/app/src/main/java/co/stonephone/stonecamera/StoneCameraApp.kt"
```
