# chathurangacpm/ai-chat architecture

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

- Interactive diagram: https://gitdiagram.com/chathurangacpm/ai-chat
- Repository: https://github.com/chathurangacpm/ai-chat

## Overview

##### Main Components of the System
a. React Native Core Layer:
- Entry Point: Highlight the index.js that initializes the app and links to App.tsx.
- App Component: Represent the main application file (src/App.tsx) which acts as the central hub for rendering UI components.
- Navigation Module: Include the src/navigation directory (mainNavigator.js, stack.js) that sets up the routing and screen flow.
- UI Components: Indicate the separation of concerns with individual UI elements such as those found in src/components (cards, chat, bottomSheet, customButton, mainChatHeader).
- Screens: Show the different screens (chatScreen.js, chatDetails.js) contained in the src/screens directory.
- Utility Functions and Themes: Represent the helpers in src/utils and the design in src/themes/theme.js.

b. Native Layers:
- Android Layer: Encompass the entire android folder including build configuration files (build.gradle, settings.gradle) and Java/Kotlin source code (e.g., MainActivity.kt, MainApplication.kt) that initializes the native side.
- iOS Layer: Represent the ios folder, including Xcode project files, AppDelegate, and associated assets and storyboard files.

c. Testing and Tooling:
- Testing Folder: Note the __tests__ folder which contains test files (e.g., App.test.tsx).
- Bundler & Configuration: Include Metro Bundler (invoked as seen in the README), Babel (babel.config.js), and linting/formatting configurations like .eslintrc.js, .prettierrc.js.
- Environment and Build Scripts: Mention configuration for both Android and iOS builds (e.g., gradle, Podfile for iOS).

##### Relationships and Interactions
- How the entry point (index.js) loads the React Native runtime which then triggers the main App.tsx.
- UI flows and interaction between components and screens.
- Link the React Native layer with the native modules; the Android and iOS directories represent platform-specific implementations and integrations.

##### Architectural Patterns and Principles
- Separation of Concerns: Differentiate clearly between platform-specific native code and the React Native JavaScript/TypeScript code.
- Modularization: Emphasize the modular directory structure (components, navigation, screens, utils) as a way to keep the UI and business logic decoupled.
- Cross-Platform Abstraction: The React Native layer abstracts platform-specific functionality while the native folders handle OS-specific configurations and assets.
- Configuration Management: Note the use of build scripts and configuration files (gradle for Android, Podfile for iOS, and various config files for linting and bundling).

##### Technology Stack Highlight
- React Native: The primary framework for building the mobile UI.
- JavaScript/TypeScript: Used for writing application logic (e.g., App.tsx, components).
- Metro Bundler: For module bundling and asset management.
- Native SDKs: Android (Java/Kotlin) and iOS (Objective-C/Swift) components that integrate with React Native.
- Build Tools: Gradle for Android and Xcode/Podfile for iOS must be depicted as part of the build and deployment pipeline.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% React Native Core Layer
    subgraph "React Native Core Layer"
        entry["Entry Point (index.js)"]:::react
        app["Core App Component (src/App.tsx)"]:::react
        nav["Navigation Module (src/navigation)"]:::react
        ui["UI Components (src/components)"]:::react
        screens["Screens (src/screens)"]:::react
        util["Utility Functions (src/utils)"]:::react
        theme["Themes (src/themes/theme.js)"]:::react
    end

    %% Native Layers
    subgraph "Native Layers"
        android["Android Native Layer"]:::native
        ios["iOS Native Layer"]:::native
    end

    %% Testing and Tooling
    subgraph "Testing and Tooling"
        tests["__tests__ (Testing)"]:::config
        babel["Babel Config (babel.config.js)"]:::config
        eslint["ESLint (.eslintrc.js)"]:::config
        prettier["Prettier (.prettierrc.js)"]:::config
        metro["Metro Bundler (metro.config.js)"]:::config
        jest["Jest Config (jest.config.js)"]:::config
    end

    %% Relationships - React Native Core
    entry -->|"loads"| app
    app -->|"initiates"| nav
    nav -->|"renders"| ui
    nav -->|"routes"| screens
    ui -->|"interacts"| screens
    util -->|"provides"| app
    theme -->|"styles"| app

    %% Bridge from React Native to Native Layers
    app -->|"bridges"| android
    app -->|"bridges"| ios

    %% Testing and Tooling Relationships
    tests -->|"validates"| app
    babel -->|"cfg"| tests
    eslint -->|"cfg"| tests
    prettier -->|"cfg"| tests
    metro -->|"cfg"| tests
    jest -->|"cfg"| tests

    %% Styles
    classDef react fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef native fill:#F08080,stroke:#000,stroke-width:2px;
    classDef config fill:#90EE90,stroke:#000,stroke-width:2px;

    %% Click Events
    click entry "https://github.com/chathurangacpm/ai-chat/blob/main/index.js"
    click app "https://github.com/chathurangacpm/ai-chat/blob/main/src/App.tsx"
    click nav "https://github.com/chathurangacpm/ai-chat/tree/main/src/navigation"
    click ui "https://github.com/chathurangacpm/ai-chat/tree/main/src/components"
    click screens "https://github.com/chathurangacpm/ai-chat/tree/main/src/screens"
    click util "https://github.com/chathurangacpm/ai-chat/tree/main/src/utils"
    click theme "https://github.com/chathurangacpm/ai-chat/blob/main/src/themes/theme.js"
    click android "https://github.com/chathurangacpm/ai-chat/tree/main/android"
    click ios "https://github.com/chathurangacpm/ai-chat/tree/main/ios"
    click tests "https://github.com/chathurangacpm/ai-chat/tree/main/__tests__"
    click babel "https://github.com/chathurangacpm/ai-chat/blob/main/babel.config.js"
    click eslint "https://github.com/chathurangacpm/ai-chat/blob/main/.eslintrc.js"
    click prettier "https://github.com/chathurangacpm/ai-chat/blob/main/.prettierrc.js"
    click metro "https://github.com/chathurangacpm/ai-chat/blob/main/metro.config.js"
    click jest "https://github.com/chathurangacpm/ai-chat/blob/main/jest.config.js"
```
