# az11k-dev/jarvis-app architecture

> Architecture diagram of the GitHub repository az11k-dev/jarvis-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/az11k-dev/jarvis-app
- Repository: https://github.com/az11k-dev/jarvis-app

## Overview

##### Project Type & Purpose
- Type: Cross-platform mobile application (React Native/Expo)
- Purpose: Listen to voice commands, process them via OpenAI/GitHub/web APIs, and respond with TTS or actions (app launches, notifications).

##### File Structure
- Native folders:
– android/… (Android Gradle project, Java/Kotlin entry points)
– ios/… (Xcode project, Swift/Objective-C bridging)
- JavaScript code under src/…:
– components/ (UI)
– screens/ (views/routes)
– services/ (API calls & business logic)
– core/github/ (GitHub–specific commands)
– hooks/, utils/, styles/
- Config: app.config.js, eas.json, package.json, .env expectations.

##### Main Components
A. Presentation Layer (UI)
- React Native Screens & Components (Home, MicrophoneButton, ResponseBox, VoicePickerModal, AccessDenied)
B. Business Logic / Orchestration
- services/jarvisService.jsx (central command workflow)
- services/ttsService.jsx (expo-speech wrapper)
- services/notificationsService.jsx (expo-notifications)
- core/github/* (createRepo, deleteRepo, commits)
C. Hooks & Utilities
- useVoiceSetup (initializing audio recording)
- utils/auth.jsx (AsyncStorage + expo-local-authentication)
- utils/constants.jsx
D. Native Modules & Expo APIs
- expo-av (Audio recording/STT)
- expo-speech (TTS)
- expo-local-authentication (FaceID/TouchID)
- expo-notifications
E. External Services
- OpenAI API (GPT requests)
- GitHub REST API
- Web fetch (internet-aware intelligence)
- Deep linking / Intent framework (launch YouTube, Telegram, etc.)
F. Data Storage
- AsyncStorage (session memory)
G. Native Hosts
- Android (MainActivity.kt, Gradle)
- iOS (AppDelegate.swift, bridging header)

##### Relationships & Data Flows
1) User taps “Mic” (UI) → React Native JS thread
2) useVoiceSetup initializes expo-av recorder (Native)
3) Audio stream → STT (either cloud or expo-speech) → Text
4) jarvisService orchestrates:
– Sends text + context to OpenAI API → receives reply
– Alternatively calls GitHub APIs via core/github
– Parses “open YouTube” → triggers deep link
5) jarvisService passes reply text to ttsService → expo-speech (Native)
6) NotificationsService schedules local reminders via expo-notifications
7) AsyncStorage stores recent commands/context
8) utils/auth enforces biometric before app start

##### Architectural Patterns & Principles
- Layered architecture: UI → Services → API/Native
- Single Responsibility: each service handles one domain (TTS, notifications, GitHub)
- Hooks for cross-cutting concerns (voice init)
- Async event flow (promises/async-await)
- Native bridging via Expo modules

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Home["Home Screen"]:::presentation
        MicBtn["MicrophoneButton"]:::presentation
        RespBox["ResponseBox"]:::presentation
        VoiceModal["VoicePickerModal"]:::presentation
        AccessDenied["AccessDenied"]:::presentation
    end

    %% Hooks & Utilities
    subgraph "Hooks & Utilities"
        direction TB
        VoiceHook["useVoiceSetup"]:::utility
        AuthUtil["auth (AsyncStorage & Local Auth)"]:::utility
        ConstUtil["constants"]:::utility
    end

    %% Services Layer
    subgraph "Services Layer"
        direction TB
        Jarvis["jarvisService"]:::service
        TTS["ttsService"]:::service
        Notif["notificationsService"]:::service
        subgraph "GitHub Core Commands"
            direction TB
            CreateRepo["createRepo"]:::service
            DeleteRepo["deleteRepo"]:::service
            Commits["commits"]:::service
        end
    end

    %% Storage
    AsyncStore["AsyncStorage"]:::storage

    %% External & Native Modules
    subgraph "Expo & Native Modules"
        direction TB
        ExpoAV["expo-av (Audio/STT)"]:::external
        ExpoSpeech["expo-speech (TTS)"]:::external
        ExpoNotif["expo-notifications"]:::external
        ExpoAuth["expo-local-authentication"]:::external
        DeepLink["Deep Linking / Intent Launcher"]:::external
    end

    subgraph "External APIs"
        direction TB
        OpenAI["OpenAI API"]:::external
        GitHubAPI["GitHub REST API"]:::external
    end

    %% Native Hosts
    subgraph "Native Hosts"
        direction TB
        Android["Android Host\n(MainActivity.kt,\nMainApplication.kt)"]:::native
        iOS["iOS Host\n(AppDelegate.swift,\nBridging-Header.h)"]:::native
    end

    %% App Entry & Config
    subgraph "App Entry & Config"
        direction TB
        Index["index.js"]:::config
        AppJS["App.js"]:::config
        AppConfig["app.config.js"]:::config
        EAS["eas.json"]:::config
        Package["package.json"]:::config
    end

    %% Data Flow
    Home -->|renders| MicBtn
    Home -->|renders| RespBox
    Home -->|renders| VoiceModal
    Home -->|renders| AccessDenied

    MicBtn -->|onPress| VoiceHook
    VoiceHook -->|init recorder| ExpoAV
    ExpoAV -->|audio stream| Jarvis

    Jarvis -->|HTTP JSON| OpenAI
    Jarvis -->|HTTP JSON| GitHubAPI
    Jarvis -->|parse 'open app'| DeepLink
    Jarvis -->|schedule| Notif
    Jarvis -->|store context| AsyncStore
    Jarvis -->|reply text| TTS

    TTS -->|TTS command| ExpoSpeech
    Notif -->|notification| ExpoNotif
    AuthUtil -->|biometric| ExpoAuth

    %% Config & Entry triggers
    Index --> AppJS
    AppJS --> AuthUtil
    AppJS --> Jarvis
    AppJS --> VoiceHook

    %% Native Hosts integration
    ExpoAV --> Android
    ExpoSpeech --> Android
    ExpoNotif --> Android
    ExpoAuth --> Android
    DeepLink --> Android

    ExpoAV --> iOS
    ExpoSpeech --> iOS
    ExpoNotif --> iOS
    ExpoAuth --> iOS
    DeepLink --> iOS

    %% Click Events
    click Home "https://github.com/az11k-dev/jarvis-app/blob/main/src/screens/Home.jsx"
    click MicBtn "https://github.com/az11k-dev/jarvis-app/blob/main/src/components/MicrophoneButton.jsx"
    click RespBox "https://github.com/az11k-dev/jarvis-app/blob/main/src/components/ResponseBox.jsx"
    click VoiceModal "https://github.com/az11k-dev/jarvis-app/blob/main/src/components/VoicePickerModal.jsx"
    click AccessDenied "https://github.com/az11k-dev/jarvis-app/blob/main/src/components/AccessDenied.jsx"
    click Jarvis "https://github.com/az11k-dev/jarvis-app/blob/main/src/services/jarvisService.jsx"
    click TTS "https://github.com/az11k-dev/jarvis-app/blob/main/src/services/ttsService.jsx"
    click Notif "https://github.com/az11k-dev/jarvis-app/blob/main/src/services/notificationsService.jsx"
    click CreateRepo "https://github.com/az11k-dev/jarvis-app/blob/main/src/core/github/createRepo.jsx"
    click DeleteRepo "https://github.com/az11k-dev/jarvis-app/blob/main/src/core/github/deleteRepo.jsx"
    click Commits "https://github.com/az11k-dev/jarvis-app/blob/main/src/core/github/commits.jsx"
    click VoiceHook "https://github.com/az11k-dev/jarvis-app/blob/main/src/hooks/useVoiceSetup.jsx"
    click AuthUtil "https://github.com/az11k-dev/jarvis-app/blob/main/src/utils/auth.jsx"
    click ConstUtil "https://github.com/az11k-dev/jarvis-app/blob/main/src/utils/constants.jsx"
    click Android "https://github.com/az11k-dev/jarvis-app/blob/main/android/app/src/main/java/com/az11k/jarvisapp/MainActivity.kt"
    click Android "https://github.com/az11k-dev/jarvis-app/blob/main/android/app/src/main/java/com/az11k/jarvisapp/MainApplication.kt"
    click iOS "https://github.com/az11k-dev/jarvis-app/blob/main/ios/jarvisapp/AppDelegate.swift"
    click iOS "https://github.com/az11k-dev/jarvis-app/blob/main/ios/jarvisapp/jarvisapp-Bridging-Header.h"
    click Index "https://github.com/az11k-dev/jarvis-app/blob/main/index.js"
    click AppJS "https://github.com/az11k-dev/jarvis-app/blob/main/App.js"
    click AppConfig "https://github.com/az11k-dev/jarvis-app/blob/main/app.config.js"
    click EAS "https://github.com/az11k-dev/jarvis-app/blob/main/eas.json"
    click Package "https://github.com/az11k-dev/jarvis-app/blob/main/package.json"

    %% Styles
    classDef presentation fill:#D0E8FF,stroke:#0066CC,color:#000;
    classDef utility fill:#E8F5D0,stroke:#339900,color:#000;
    classDef service fill:#DFF0D8,stroke:#338833,color:#000;
    classDef external fill:#FFE2B3,stroke:#CC6600,color:#000;
    classDef storage fill:#F0F0F0,stroke:#888888,color:#000;
    classDef native fill:#E1D5E7,stroke:#663399,color:#000;
    classDef config fill:#FFF2CC,stroke:#CC9900,color:#000;
```
