# suryanandanbabbar/scout architecture

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

- Interactive diagram: https://gitdiagram.com/suryanandanbabbar/scout
- Repository: https://github.com/suryanandanbabbar/scout

## Overview

##### Project type and purpose
- This is an on-device, real-time audio analysis iOS application (“Scout”) built in Swift/SwiftUI with a small DSP engine (YIN tracker, chromagram, chord templates) that listens on the microphone, estimates notes and chords, and renders a UI (keyboard animation, audio visualizer, labels).

##### File structure
- Top-level folders:
- Models (DetectedNote.swift, DetectedChord.swift)
- Services (AudioManager.swift, ChordDetector.swift)
- Utils (DSP.swift, Smoother.swift)
- Views (SplashScreenView.swift, ContentView.swift, PianoKeyboardView.swift)
- ScoutApp.swift (app entry point)
- Info.plist (iOS permissions + config)
- Patterns & Indicators:
- Clear MVC/MVVM-style separation: Services = “business logic,” Utils = DSP helpers, Models = data carriers, Views = SwiftUI.
- Uses AVFoundation/AudioEngine (in AudioManager), Apple Accelerate/vDSP (in DSP.swift).
- No external servers—fully on-device.

##### README
- Confirms architecture:
- Models for notes/chords
- Services for audio capture and DSP
- Utils for smoothing and DSP config
- Views for UI screens
- Mentions tech: SwiftUI, vDSP, simple YIN algorithm, chroma/template matching.

##### Detail
- Every class/file as its own component if it has non-trivial logic (e.g., Smoother, ChordDetector)
- Interactions (e.g., “AudioManager installs AVAudioEngine tap at 44.1 kHz”)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "External System"
        Mic["iOS Microphone\n(AVAudioSession)"]:::external
    end

    subgraph "Services & Controllers"
        AM["AudioManager\n(captures audio via AVAudioEngine)"]:::services
        CD["ChordDetector\n(template matching)"]:::services
    end

    subgraph "DSP & Utils"
        YIN["YIN Pitch Tracker\n(DSP.swift)"]:::dsp
        CHR["Chromagram Generator\n(DSP.swift + vDSP)"]:::dsp
        SMO["Smoother\n(Smoother.swift)"]:::dsp
    end

    subgraph "Data Models"
        note[(DetectedNote)]:::models
        chord[(DetectedChord)]:::models
    end

    subgraph "SwiftUI Views"
        SS["SplashScreenView"]:::ui
        CV["ContentView\n(hosts keyboard, visualizer, labels)"]:::ui
        PK["PianoKeyboardView"]:::ui
    end

    subgraph "Resources & Config"
        AS["Assets.xcassets"]:::ui
        INFO["Info.plist"]:::ui
        APP["ScoutApp.swift\n(app entry point)"]:::ui
    end

    Mic -->|"raw PCM"| AM
    AM -->|"buffer"| YIN
    YIN -->|"pitch data"| CHR
    CHR -->|"chroma vector"| SMO
    SMO -->|"smoothed chroma"| CD
    CD -->|"DetectedNote & DetectedChord"| note
    CD -->|"DetectedNote & DetectedChord"| chord

    note -.-|"@Published"| CV
    chord -.-|"@Published"| CV
    CV -->|"navigates to"| SS
    CV -->|"contains"| PK
    CV -->|"uses images/colors"| AS
    CV -->|"checks permissions"| INFO
    APP -->|"launches"| SS
    APP -->|"sets root view"| CV

    classDef external fill:#f88,stroke:#600
    classDef services fill:#afa,stroke:#070
    classDef dsp fill:#f9a,stroke:#c60
    classDef models fill:#ccc,stroke:#888
    classDef ui fill:#aaf,stroke:#448

    click AM "https://github.com/suryanandanbabbar/scout/blob/main/Services/AudioManager.swift"
    click YIN "https://github.com/suryanandanbabbar/scout/blob/main/Utils/DSP.swift"
    click CHR "https://github.com/suryanandanbabbar/scout/blob/main/Utils/DSP.swift"
    click SMO "https://github.com/suryanandanbabbar/scout/blob/main/Utils/Smoother.swift"
    click CD "https://github.com/suryanandanbabbar/scout/blob/main/Services/ChordDetector.swift"
    click note "https://github.com/suryanandanbabbar/scout/blob/main/Models/DetectedNote.swift"
    click chord "https://github.com/suryanandanbabbar/scout/blob/main/Models/DetectedChord.swift"
    click SS "https://github.com/suryanandanbabbar/scout/blob/main/Views/SplashScreenView.swift"
    click CV "https://github.com/suryanandanbabbar/scout/blob/main/Views/ContentView.swift"
    click PK "https://github.com/suryanandanbabbar/scout/blob/main/Views/PianoKeyboardView.swift"
    click AS "https://github.com/suryanandanbabbar/scout/tree/main/Assets.xcassets/"
    click INFO "https://github.com/suryanandanbabbar/scout/blob/main/Info.plist"
    click APP "https://github.com/suryanandanbabbar/scout/blob/main/ScoutApp.swift"
```
