# nhan7tuoi/orangechatapp architecture

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

- Interactive diagram: https://gitdiagram.com/nhan7tuoi/orangechatapp
- Repository: https://github.com/nhan7tuoi/orangechatapp

## Overview

##### Project Type and Purpose
- The project includes directories for Android and iOS native projects, a well-organized source folder (src) for the JS/TS code handling components, screens, navigation, and state management (Redux), as well as API integration for features like authentication, messaging, friend management, and even Firebase configuration. This indicates its purpose is to deliver real-time chat/messaging functionality with features such as login, registration, chat conversations, notifications, and media message handling.

##### File Structure
- Top-Level Directories:
- Android and iOS directories: Native code implementations and project configurations.
- The “src” directory: Contains most of the React Native code – with subdirectories for components (UI pieces), navigations (various navigation flows like AuthNavigation, MainNavigation, TabNavigator), screens (different app pages), redux (store management using slices like auth, conversation, friend, language, sticker), APIs (to interact with server/endpoints), and utility services.
- Other important files:
- App.tsx and index.js: Entry points for the React Native application.
- Config files like babel.config.js, metro.config.js, package.json, and tsconfig.json are there to configure the build and dependencies.
- Architectural Clues:
- The organization clearly follows a separation of concerns typical of modern full-stack mobile applications – separating UI components, navigation, state management, API integration, and configuration.
- The presence of “src/server/ConnectSocket.js” indicates a WebSocket or real-time connection module for live chat updates.
- The “src/Config/FireBaseConfig.js” shows integration with Firebase for notifications, authentication, or storage.

a. Main Components:
- Mobile Client (React Native App):
- Presentation Layer: Screens (LoginScreen, ChatScreen, Register screens, etc.)
- UI Components: Chat components (textMessage, fileMessage, stickers, imageMessage, etc.)
- Navigation: AuthNavigation, TabNavigator, MainNavigation, ensuring route flows among screens.
- State Management: Redux store and slices (authSlice, conversationSlice, friendSlice, etc.) controlling application state.
- API Integration: Modules under “src/apis” (authApi, conversationApi, userApi, etc.) handling RESTful calls to the backend.
- Real-Time Communication: “src/server/ConnectSocket.js” managing WebSocket connections.
- External Integrations: Firebase (from FireBaseConfig.js) for additional services like push notifications.

- Platform-Specific Layers:
- Android: Native Android code, resources (layouts, drawables, etc.), build scripts (build.gradle).
- iOS: Native iOS project files (AppDelegate, Info.plist, etc.).

b. Relationships & Interactions:
- The React Native front-end interacting with native Android/iOS modules.
- The navigation system tying various screens together.
- The Redux store communicating with UI components to manage state.
- API modules making HTTP/REST calls to backend services (which may be external or internal to your system).
- Socket connection module for real-time messaging.
- External services like Firebase firmly linked with the app configuration.
- From user actions (UI events) to Redux, then to API modules.
- From API responses to update Redux and eventually re-render UI.
- From messaging components to the ConnectSocket for real-time data updates.
- From the mobile client to native layers (Android/iOS) when using platform-specific features.

c. Architectural Patterns and Design Principles:
- Separation of Concerns: Clear separation between presentational components (screens and UI elements), state management (Redux), and data handling (API integrations).
- Modularization: Use of directories to split functionality (e.g., components, redux, APIs) makes the architecture component-based and maintainable.
- Real-time Communication: Dedicated module for establishing and managing WebSocket connections.
- Cross-Platform Considerations: Separate native directories (android and ios) ensure that mobile-specific customizations are handled outside the JS/TS code.

d. Technologies, Frameworks, and Libraries:
- React Native framework for cross-platform mobile development.
- Redux (with slice-based reducers) for state management.
- React Navigation for seamless screen transitions.
- Firebase (as indicated in configuration) for external services.
- WebSocket integration for real-time messaging.
- Native build tools: Gradle for Android, Xcode for iOS.

## Diagram (Mermaid)

```mermaid
graph TD
  subgraph "Mobile Client (React Native)"
    subgraph "Entry Points"
      A1["App.tsx"]:::entry
      A2["index.js"]:::entry
    end
    subgraph "Presentation Layer"
      P1["Screens"]:::presentation
      P2["UI Components"]:::presentation
    end
    subgraph "Navigation System"
      N1["Navigation"]:::navigation
    end
    subgraph "State Management"
      R1["Redux Store"]:::state
    end
    subgraph "API Integration"
      AI1["API Modules"]:::api
    end
    subgraph "Real-Time Communication"
      WS["Socket Service"]:::socket
    end
    subgraph "External Service"
      F1["Firebase"]:::firebase
    end
  end

  A1 -->|"initializes"| P1
  A2 -->|"initializes"| P1
  P1 -->|"routes"| N1
  N1 -->|"triggers"| R1
  R1 -->|"fetches"| AI1
  AI1 -->|"updates"| R1
  R1 -->|"renders"| P2
  P1 -->|"sends"| WS
  WS -->|"updates"| R1
  A1 -->|"initializes"| F1

  subgraph "Platform-Specific Layers"
    AN["Android Native Modules"]:::native
    IOS["iOS Native Modules"]:::native
  end

  A1 -->|"calls"| AN
  A1 -->|"calls"| IOS

  click A1 "https://github.com/nhan7tuoi/orangechatapp/blob/main/OrangeChat/App.tsx"
  click A2 "https://github.com/nhan7tuoi/orangechatapp/blob/main/OrangeChat/index.js"
  click P1 "https://github.com/nhan7tuoi/orangechatapp/tree/main/OrangeChat/src/screens"
  click P2 "https://github.com/nhan7tuoi/orangechatapp/tree/main/OrangeChat/src/components"
  click N1 "https://github.com/nhan7tuoi/orangechatapp/tree/main/OrangeChat/src/navigations"
  click R1 "https://github.com/nhan7tuoi/orangechatapp/tree/main/OrangeChat/src/redux"
  click AI1 "https://github.com/nhan7tuoi/orangechatapp/tree/main/OrangeChat/src/apis"
  click WS "https://github.com/nhan7tuoi/orangechatapp/blob/main/OrangeChat/src/server/ConnectSocket.js"
  click F1 "https://github.com/nhan7tuoi/orangechatapp/blob/main/OrangeChat/src/Config/FireBaseConfig.js"
  click AN "https://github.com/nhan7tuoi/orangechatapp/tree/main/OrangeChat/android"
  click IOS "https://github.com/nhan7tuoi/orangechatapp/tree/main/OrangeChat/ios"

  classDef entry fill:#fde047,stroke:#f59e0b,stroke-width:2px;
  classDef presentation fill:#a5b4fc,stroke:#6366f1,stroke-width:2px;
  classDef navigation fill:#fbcfe8,stroke:#ec4899,stroke-width:2px;
  classDef state fill:#c7d2fe,stroke:#6366f1,stroke-width:2px;
  classDef api fill:#bbf7d0,stroke:#10b981,stroke-width:2px;
  classDef socket fill:#ddd6fe,stroke:#7e22ce,stroke-width:2px;
  classDef firebase fill:#fed7aa,stroke:#fb923c,stroke-width:2px;
  classDef native fill:#e5e7eb,stroke:#374151,stroke-width:2px;
```
