# falatekmen/chatgpt-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/falatekmen/chatgpt-assistant
- Repository: https://github.com/falatekmen/chatgpt-assistant

## Overview

##### Main Components

a. Client-Side Components (Mobile/Web App):
- Navigation Layer (from app/navigation/)
- Screen Components (from app/screens/)
- Shared Components (contexts and hooks)

b. External Services:
- GPT API (Text Generation)
- DALL-E API (Image Generation)
- Whisper API (Speech-to-Text)

##### Component Relationships

a. Navigation Flow:
- Chat Screen
- Images Screen
- Whisper Screen
- API Key Screen

b. Data Flow:
- ApiKeyContext provider wrapping the entire application
- UseApi hook's connections to each screen
- API calls from screens to respective OpenAI services

##### Specific Implementation Details

- Rectangles: Main application components
- Rounded rectangles: Screens
- Hexagons: External API services
- Ovals: Context providers
- Diamonds: Hooks

- Blue: Navigation components
- Green: Screen components
- Yellow: Context providers
- Purple: External services
- Orange: Hooks

##### Detailed Component Breakdown

**[ChatGPT Assistant App]**
- [Navigation Layer]
- RootNavigator
- DrawerNavigation
- [Screens]
- Chat Screen ──────────┐
- Images Screen ────────┼──→ [useApi Hook] ──→ [OpenAI Services]
- Whisper Screen ───────┘                      ├── GPT API
- API Key Screen ───────────→ [ApiKeyContext]   ├── DALL-E API
- Whisper API

##### Important Notes

- Bi-directional data flow between screens and the API context
- Platform-specific considerations (Android/iOS/Web)
- Error handling paths
- State management flow through the ApiKeyContext
- Demonstrate how the useApi hook mediates between screens and OpenAI services

##### Additional Elements

- Version information and supported platforms
- Platform-specific limitations (e.g., Whisper on web)
- Initialization flow and authentication process

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph App
        direction TB
        Root["App Root"]
        Nav["Navigation Layer"]
        Screens["Screen Components"]
        Shared["Shared Components"]
    end

    subgraph "Navigation Layer"
        direction TB
        RootNav["Root Navigator"]
        DrawerNav["Drawer Navigation"]
    end

    subgraph "Screen Components"
        direction TB
        ChatScreen["Chat Screen"]
        ImagesScreen["Images Screen"]
        WhisperScreen["Whisper Screen"]
        ApiKeyScreen["API Key Screen"]
    end

    subgraph "Shared Components"
        direction TB
        ApiContext["ApiKeyContext Provider"]
        ApiHook["useApi Hook"]
    end

    subgraph "OpenAI Services"
        direction TB
        GPT["GPT API"]:::external
        DALLE["DALL-E API"]:::external
        Whisper["Whisper API"]:::external
    end

    Root --> Nav
    Root --> ApiContext
    Nav --> RootNav
    RootNav --> DrawerNav
    DrawerNav --> Screens
    
    ChatScreen --> ApiHook
    ImagesScreen --> ApiHook
    WhisperScreen --> ApiHook
    ApiKeyScreen --> ApiContext
    
    ApiHook --> GPT
    ApiHook --> DALLE
    ApiHook --> Whisper

    %% Click events for component mapping
    click Root "https://github.com/falatekmen/ChatGPT-Assistant/blob/main/App.tsx"
    click Nav "https://github.com/falatekmen/ChatGPT-Assistant/tree/main/app/navigation/"
    click RootNav "https://github.com/falatekmen/ChatGPT-Assistant/blob/main/app/navigation/RootNavigator.tsx"
    click DrawerNav "https://github.com/falatekmen/ChatGPT-Assistant/blob/main/app/navigation/DrawerNavigation.tsx"
    click ChatScreen "https://github.com/falatekmen/ChatGPT-Assistant/blob/main/app/screens/Chat.tsx"
    click ImagesScreen "https://github.com/falatekmen/ChatGPT-Assistant/blob/main/app/screens/Images.tsx"
    click WhisperScreen "https://github.com/falatekmen/ChatGPT-Assistant/blob/main/app/screens/Whisper.tsx"
    click ApiKeyScreen "https://github.com/falatekmen/ChatGPT-Assistant/blob/main/app/screens/ApiKey.tsx"
    click ApiContext "https://github.com/falatekmen/ChatGPT-Assistant/blob/main/app/contexts/apiKeyContext.tsx"
    click ApiHook "https://github.com/falatekmen/ChatGPT-Assistant/blob/main/app/hooks/useApi.ts"

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef external fill:#e1d5e7,stroke:#9673a6,stroke-width:2px
    
    %% Legend
    subgraph Legend
        direction TB
        L1["Application Component"]:::default
        L2["External Service"]:::external
    end
```
