# xlspring/hushhear architecture

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

- Interactive diagram: https://gitdiagram.com/xlspring/hushhear
- Repository: https://github.com/xlspring/hushhear

## Overview

##### Project Type and Purpose
- This is a cross-platform mobile application built with React Native (bare/ejected Expo workflow) targeting Android and iOS.
- Purpose: “HushHear” lets users silence unwanted sounds by connecting to headphones (likely over Bluetooth), adjusting EQ, toggling noise profiles, and managing user authentication and premium features.

##### File Structure Analysis
- Root
- App.js – entry point for the JS bundle
- package.json, babel.config.js, eas.json – configuration and build/deployment scripts
- android/, ios/ – native host projects generated by React Native CLI (Android: Gradle + Kotlin; iOS: Xcode Objective-C/Swift bridge)
- assets/ – fonts, images, sound files
- screens/ – screen definitions organized by feature area (login, app, menu)
- redux/ – state management (store, reducers for connection, headphones, login, menu)
- Key architectural choices
- UI composition via React components + screens
- Global state via Redux
- Native modules for headphone connectivity and audio control
- Metro bundler serves JS at runtime (embedded or via dev server)

a. Main Components
1. Mobile Client “HushHear”
- Presentation Layer: React Native UI (screens & components)
- State Layer: Redux store & reducers
- Business Logic: JS modules handling actions (connect, adjust EQ)
- Native Bridge: React Native native modules for Bluetooth/audio
2. Native Hosts
- Android: Kotlin/Java entry (MainActivity.kt), Gradle build
- iOS: Obj-C/Swift bridge (AppDelegate), Xcode project
3. External Systems
- Headphones (Bluetooth LE peripheral)
- Backend API (authentication, premium features, user data)
- Optional Analytics/Crash Reporting service
4. Build/Deployment Tools
- Metro bundler (JS bundling)
- EAS/App Store / Play Store pipelines

b. Relationships & Data Flows
- App.js initializes the Redux store, loads initial screen
- UI Screens dispatch Redux actions → reducers update state
- Thunks or direct calls go through Native Bridge to:
– Scan/Connect to headphone hardware
– Send EQ settings to headphone audio engine
- Network calls from JS → Backend API for login, account, premium checks
- State updates flow back to UI via Redux → re-render screens/components

c. Architectural Patterns & Principles
- Component-Based Architecture: separation of reusable UI pieces (components/) from feature screens (screens/)
- Unidirectional Data Flow (Redux): clear separation of actions, state, and views
- Native Module Pattern: encapsulate hardware-specific logic behind JS bridge interfaces
- Feature Folder Organization: group related screens, components, and state

d. Key Technologies & Frameworks
- React Native (JS runtime + native bridges)
- Redux (state container)
- Metro (bundler)
- Android SDK (Gradle, Kotlin/Java)
- iOS SDK (Xcode, Objective-C/Swift)
- Bluetooth LE libraries (native modules)
- Expo Application Services (EAS) for builds

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        AppJS["App.js"]:::frontend
        UIScreens["Feature Screens"]:::frontend
        UIComponents["Reusable UI Components"]:::frontend
    end

    %% State Management Layer
    subgraph "State Management Layer"
        direction TB
        Store["Redux Store"]:::state
        Reducers["Redux Reducers"]:::state
    end

    %% Business Logic & Native Bridge
    subgraph "Business Logic & Native Bridge"
        direction TB
        Logic["JS Business Logic"]:::state
        subgraph "Native Bridge"
            direction TB
            AndroidModules["Android Native Modules"]:::native
            iOSModules["iOS Native Modules"]:::native
        end
    end

    %% Native Hosts
    subgraph "Native Hosts"
        direction TB
        AndroidProj["Android Project"]:::native
        iOSProj["iOS Project"]:::native
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Headphones["Bluetooth Headphones"]:::external
        BackendAPI["Backend API"]:::external
        Analytics["Analytics/Crash Reporting"]:::external
    end

    %% Connections
    AppJS -->|"initialize"| Store
    AppJS -->|"renders"| UIScreens

    UIScreens -->|"dispatch(Action)"| Store
    Store -->|"state update"| UIScreens

    UIScreens -->|"user interaction"| Logic
    Logic -->|"dispatch(Action)"| Store

    Logic -->|"Bluetooth GATT write"| AndroidModules
    Logic -->|"Bluetooth GATT write"| iOSModules

    Logic -->|"HTTPS POST"| BackendAPI
    Logic -->|"log events"| Analytics

    AndroidModules -->|"bridge calls"| AndroidProj
    iOSModules -->|"bridge calls"| iOSProj

    Headphones -->|"BLE peripheral"| AndroidModules
    Headphones -->|"BLE peripheral"| iOSModules

    %% Click Events
    click AppJS "https://github.com/xlspring/hushhear/blob/master/App.js"
    click UIScreens "https://github.com/xlspring/hushhear/tree/master/screens/"
    click UIComponents "https://github.com/xlspring/hushhear/tree/master/components/"
    click Store "https://github.com/xlspring/hushhear/blob/master/redux/store.js"
    click Reducers "https://github.com/xlspring/hushhear/blob/master/redux/reducers/connection.js"
    click Reducers "https://github.com/xlspring/hushhear/blob/master/redux/reducers/headphones.js"
    click Reducers "https://github.com/xlspring/hushhear/blob/master/redux/reducers/login.js"
    click Reducers "https://github.com/xlspring/hushhear/blob/master/redux/reducers/menu.js"
    click AndroidModules "https://github.com/xlspring/hushhear/blob/master/android/app/src/main/java/com/uzhas/hushhear/MainActivity.kt"
    click AndroidModules "https://github.com/xlspring/hushhear/blob/master/android/app/src/main/java/com/uzhas/hushhear/MainApplication.kt"
    click iOSModules "https://github.com/xlspring/hushhear/blob/master/ios/HushHear/AppDelegate.h"
    click iOSModules "https://github.com/xlspring/hushhear/blob/master/ios/HushHear/AppDelegate.mm"
    click iOSModules "https://github.com/xlspring/hushhear/blob/master/ios/HushHear/HushHear-Bridging-Header.h"
    click iOSModules "https://github.com/xlspring/hushhear/blob/master/ios/HushHear/main.m"
    click AndroidProj "https://github.com/xlspring/hushhear/tree/master/android/"
    click iOSProj "https://github.com/xlspring/hushhear/tree/master/ios/"
    click UIComponents "https://github.com/xlspring/hushhear/tree/master/assets/"
    click AppJS "https://github.com/xlspring/hushhear/blob/master/babel.config.js"
    click AppJS "https://github.com/xlspring/hushhear/blob/master/eas.json"
    click AppJS "https://github.com/xlspring/hushhear/blob/master/app.json"
    click AppJS "https://github.com/xlspring/hushhear/blob/master/package.json"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#0056b3,color:#004085
    classDef state fill:#d4edda,stroke:#155724,color:#155724
    classDef native fill:#fff3cd,stroke:#856404,color:#856404
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#383d41
```
