# mhashir03/ozzy architecture

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

- Interactive diagram: https://gitdiagram.com/mhashir03/ozzy
- Repository: https://github.com/mhashir03/ozzy

## Overview

##### Project Type and Purpose
- Ozzy is a cross-platform mobile application focused on overcoming communication challenges for users with speech difficulties. It leverages speech recognition (via OpenAI’s Whisper API) to convert spoken input into text and then provides text-to-speech playback.
- It is designed as an accessibility tool within the assistive technology domain, as highlighted in the README.

##### File Structure
- The project lives inside the "frontend/HackSLU-2025" directory, indicating that the key mobile application code is in a dedicated “frontend” directory.
- Key directories include:
- app – Contains main application components, configuration files (babel.config.js, tailwind.config.js), context providers (ThemeContext, AppContext), navigation setup (AppNavigator), and screens (HomeScreen, SpeechScreen, SettingsScreen).
- api – Hosts code for interfacing with the speech API (speechApi.ts) so that external services (OpenAI Whisper API) are used.
- components – Houses individual UI components (including feature-specific components for speech such as LanguageSelector).
- assets – Holds fonts and images used by the application.
- lib – Manages library code including constant definitions for languages and other app-specific constants.
- The file tree demonstrates a component-based structure typical for React Native apps, with clear separation between UI, configuration, API connections, context management, and utility hooks.

##### Components
a. Mobile App Frontend: Mark this as the primary interactive user interface built with React Native and Expo.
- App Container: Core entry point (index.tsx) which loads App.tsx.
- Navigation: Managed by React Navigation (AppNavigator) that routes between screens.
- Screens: Home, Speech, and Settings.
- Components: Both generic and feature-specific components (like LanguageSelector in speech feature).
- Context Providers: Handle theming (ThemeContext) and global app state (AppContext).
- Hooks: Custom hooks (useColorScheme, useThemeColor) used for adaptive theming.
b. API Integration:
- API layer (speechApi.ts) showing outbound HTTP requests to the external API.
c. Audio Handling:
- Modules for audio recording and playback that use Expo AV and Expo Speech libraries.
d. External Dependencies:
- Usage of libraries such as React Navigation, Expo AV, Expo Speech, and Tailwind (for styling).

##### Relationships and Interactions
- From the Voice Input captured on the Speech Screen to the API module (speechApi.ts) which communicates with the OpenAI Whisper API.
- From the API response, passing processed text back to the component(s) to trigger text-to-speech playback.
- That user interactions on the Home and Settings screens navigate via AppNavigator.
- That context providers (AppContext and ThemeContext) supply state information (such as theming and global settings) to various screens and components.
- That the UI components interact with the API layer indirectly (through hooks or direct API calls) to handle audio recording and playback.

##### Architectural Patterns and Design Principles
- The design follows a clear separation of concerns, modularizing:
- UI layers (screens, navigation, components)
- State Management (context APIs for global state)
- Service Integration (API layer for speech processing)
- Use of environmental variables (in a .env file) supports external configuration (like API keys), emphasizing best practices in configuration management.
- The use of modern tooling (like Expo for mobile development) illustrates a component and modular-focused architecture that supports rapid development.

- Separation between the main layers (UI, API integration, and service handling), ensuring that all essential parts of the application are represented.

## Diagram (Mermaid)

```mermaid
graph TD
  %% Frontend Mobile Interface
  subgraph "Frontend Mobile Interface"
    AC["App Container: index.tsx & App.tsx"]:::ui
    NAV["Navigation: React Navigation (AppNavigator)"]:::ui
    subgraph "Screens"
      HS["Home Screen"]:::ui
      SS["Speech Screen"]:::ui
      SETS["Settings Screen"]:::ui
    end
    subgraph "UI Components"
      LS["LanguageSelector"]:::ui
    end
    subgraph "Context Providers"
      TC["ThemeContext"]:::ui
      ACX["AppContext"]:::ui
    end
    subgraph "Custom Hooks"
      UCS["useColorScheme"]:::ui
      UTC["useThemeColor"]:::ui
    end
  end

  %% API Integration and External Services
  subgraph "API Integration"
    API["speechApi.ts"]:::service
    OAI["OpenAI Whisper API"]:::service
  end

  %% Audio Handling Module
  subgraph "Audio Handling"
    AUDIO["Expo AV & Expo Speech (Audio Module)"]:::audio
  end

  %% External Dependencies
  subgraph "External Dependencies"
    RN["React Navigation Library"]:::ui
    EXAV["Expo AV Library"]:::audio
    EXS["Expo Speech Library"]:::audio
    TW["Tailwind CSS"]:::ui
  end

  %% Relationships and Data Flow

  %% App initialization and Navigation
  AC -->|"initiate"| NAV
  NAV -->|"routes-to"| HS
  NAV -->|"routes-to"| SS
  NAV -->|"routes-to"| SETS

  %% User Interaction from Speech Screen to API Integration
  SS -->|"UserInput"| API
  API -->|"APIRequest"| OAI
  OAI -->|"APIResponse"| API
  API -->|"ProcessText"| AUDIO

  %% Context Providers supply state to Screens
  TC -->|"provideState"| HS
  TC -->|"provideState"| SS
  TC -->|"provideState"| SETS
  ACX -->|"provideState"| HS
  ACX -->|"provideState"| SS
  ACX -->|"provideState"| SETS

  %% Custom Hooks support UI Components
  UCS -->|"hookUsage"| LS
  UTC -->|"hookUsage"| LS

  %% External Dependencies supporting Modules
  RN -->|"supports"| NAV
  EXAV -->|"supports"| AUDIO
  EXS -->|"supports"| AUDIO
  TW -->|"styles"| LS

  %% Styles
  classDef ui fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
  classDef service fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;
  classDef audio fill:#ffe082,stroke:#ef6c00,stroke-width:2px;

  %% Click Events
  click AC "https://github.com/mhashir03/ozzy/blob/main/frontend/HackSLU-2025/app/index.tsx"
  click AC "https://github.com/mhashir03/ozzy/blob/main/frontend/HackSLU-2025/app/App.tsx"
  click NAV "https://github.com/mhashir03/ozzy/blob/main/frontend/HackSLU-2025/app/navigation/AppNavigator.tsx"
  click HS "https://github.com/mhashir03/ozzy/blob/main/frontend/HackSLU-2025/app/screens/HomeScreen.tsx"
  click SS "https://github.com/mhashir03/ozzy/blob/main/frontend/HackSLU-2025/app/screens/SpeechScreen.tsx"
  click SETS "https://github.com/mhashir03/ozzy/blob/main/frontend/HackSLU-2025/app/screens/SettingsScreen.tsx"
  click TC "https://github.com/mhashir03/ozzy/blob/main/frontend/HackSLU-2025/app/context/ThemeContext.tsx"
  click ACX "https://github.com/mhashir03/ozzy/blob/main/frontend/HackSLU-2025/app/context/AppContext.tsx"
  click API "https://github.com/mhashir03/ozzy/blob/main/frontend/HackSLU-2025/api/speechApi.ts"
  click LS "https://github.com/mhashir03/ozzy/blob/main/frontend/HackSLU-2025/components/feature/speech/LanguageSelector.tsx"
  click UCS "https://github.com/mhashir03/ozzy/blob/main/frontend/HackSLU-2025/hooks/useColorScheme.ts"
  click UCS "https://github.com/mhashir03/ozzy/blob/main/frontend/HackSLU-2025/hooks/useColorScheme.web.ts"
  click UTC "https://github.com/mhashir03/ozzy/blob/main/frontend/HackSLU-2025/hooks/useThemeColor.ts"
```
