# longleu0902/coinapp architecture

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

- Interactive diagram: https://gitdiagram.com/longleu0902/coinapp
- Repository: https://github.com/longleu0902/coinapp

## Overview

##### Main Components
a. User Interface / Presentation Layer:
- The main entry (App.tsx) and various screens found under the “Page” directory. Each subfolder (e.g., Home, Login, CoinList, etc.) represents a particular view or screen component.
- Using separate style files per screen indicates component-specific styling.
b. Navigation / Routing Layer:
- The “Routes” directory contains components like AppRouter.tsx and LoginRoutes.tsx. This layer manages screen navigation and routing logic.
c. State Management:
- The “Redux” directory holds your Redux store as well as individual reducers (loginReducer, scrollViewReducer, signUpReducer). These manage application’s state and business logic.
d. Service / API Integration:
- The “Service” directory with API.tsx represents the component that handles external API calls or network interactions.
e. Native / Platform Specific Layers:
- The “android” and “ios” directories contain the native code, configuration files, and build scripts required for each mobile platform.
f. Testing and Configuration:
- Files like __tests__/App.test.tsx, jest.config.js, tsconfig.json, and various build scripts indicate configuration and testing components.

##### Relationships and Interactions
- The UI components in the “Page” directory interact with the state management layer (Redux store) by dispatching actions and reading state.
- Navigation is orchestrated via the components in “Routes”, connecting the different pages based on user flow.
- The “Service/API.tsx” module is used by UI components (or their connected Redux actions) to fetch data from external sources.
- The native directories (android/ and ios/) wrap the core JavaScript layers and manage platform-specific implementations through build and configuration files.
- Configuration files like babel.config.js, package.json, and others integrate with tools such as Metro Bundler, which is critical to the React Native build process.

##### Architectural Patterns and Design Principles
- The project follows a clean separation of concerns with distinct directories for UI (Page), navigation (Routes), state management (Redux), and service logic (Service).
- It makes use of modularization – the React Native components, Redux reducers, and native code are segmented by functionality.
- The use of Redux is a key design pattern aimed at making state management predictable and centralized.
- The structure supports the Model-View-Controller/Container pattern:
– Model: Redux store and reducers.
– View: Individual screens under “Page”.
– Controller: Navigation components in “Routes” and API interactions in “Service”.

##### Relevant Technologies, Frameworks, and Tools
- React Native for the core mobile UI.
- Redux for state management.
- Metro Bundler for building and bundling the JavaScript code.
- Standard build tools and configurations for Android (Gradle) and iOS (Xcode, Podfile) native code.
- ESLint and Prettier configurations to maintain code quality.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Application Layer
    subgraph "Core Application"
        A["App.tsx"]:::entry
        subgraph "Navigation Layer"
            AR["AppRouter.tsx"]:::route
            LR["LoginRoutes.tsx"]:::route
        end
        A -->|"initializes"| AR
        A -->|"configures"| LR
    end

    %% UI / Presentation Layer
    subgraph "UI Screens"
        PH["Home Screen"]:::screen
        PL["Login Screen"]:::screen
        PC["CoinList Screen"]:::screen
        PD["CoinDetail Screen"]:::screen
        PB["Buy Screen"]:::screen
    end

    %% State Management Layer
    subgraph "State Management"
        RS["Redux Store (Store.ts)"]:::redux
        RL["loginReducer.ts"]:::redux
        RSV["scrollViewReducer.ts"]:::redux
        RSU["signUpReducer.ts"]:::redux
        RS --> RL
        RS --> RSV
        RS --> RSU
    end

    %% Service / API Integration
    SAPI["API Service (API.tsx)"]:::service

    %% Native Platforms
    subgraph "Native Platforms"
        AND["Android (android/)"]:::native
        IOS["iOS (ios/)"]:::native
    end

    %% Testing and Configuration
    subgraph "Testing & Configuration"
        TEST["App.test.tsx (__tests__)"]:::test
        JEST["jest.config.js"]:::config
        TSC["tsconfig.json"]:::config
    end

    %% Relationships
    %% UI Screens interact with State Management
    PH -->|"dispatch"| RS
    PL -->|"dispatch"| RS
    PC -->|"dispatch"| RS
    PD -->|"dispatch"| RS
    PB -->|"dispatch"| RS

    %% Navigation drives transitions to UI Screens
    AR -->|"routes to"| PH
    AR -->|"routes to"| PL
    AR -->|"routes to"| PC
    AR -->|"routes to"| PD
    AR -->|"routes to"| PB

    %% State Management triggers API calls
    RS -->|"calls"| SAPI

    %% Native layers wrap core JS app
    A ---|"integrated with"| AND
    A ---|"integrated with"| IOS

    %% Testing and Configuration support overall build
    A ---|"validated by"| TEST
    A ---|"configured by"| JEST
    A ---|"configured by"| TSC

    %% Click Events
    click A "https://github.com/longleu0902/coinapp/blob/main/App.tsx"
    click AR "https://github.com/longleu0902/coinapp/blob/main/Routes/AppRouter.tsx"
    click LR "https://github.com/longleu0902/coinapp/blob/main/Routes/LoginRoutes.tsx"
    click PH "https://github.com/longleu0902/coinapp/tree/main/Page/"
    click PL "https://github.com/longleu0902/coinapp/tree/main/Page/"
    click PC "https://github.com/longleu0902/coinapp/tree/main/Page/"
    click PD "https://github.com/longleu0902/coinapp/tree/main/Page/"
    click PB "https://github.com/longleu0902/coinapp/tree/main/Page/"
    click RS "https://github.com/longleu0902/coinapp/blob/main/Redux/Store.ts"
    click RL "https://github.com/longleu0902/coinapp/blob/main/Redux/loginReducer.ts"
    click RSV "https://github.com/longleu0902/coinapp/blob/main/Redux/scrollViewReducer.ts"
    click RSU "https://github.com/longleu0902/coinapp/blob/main/Redux/signUpReducer.ts"
    click SAPI "https://github.com/longleu0902/coinapp/blob/main/Service/API.tsx"
    click AND "https://github.com/longleu0902/coinapp/tree/main/android/"
    click IOS "https://github.com/longleu0902/coinapp/tree/main/ios/"
    click TEST "https://github.com/longleu0902/coinapp/blob/main/__tests__/App.test.tsx"
    click JEST "https://github.com/longleu0902/coinapp/blob/main/jest.config.js"
    click TSC "https://github.com/longleu0902/coinapp/blob/main/tsconfig.json"

    %% Styles
    classDef entry fill:#f9f,stroke:#333,stroke-width:2px;
    classDef route fill:#ccf,stroke:#333,stroke-width:2px;
    classDef screen fill:#cfc,stroke:#333,stroke-width:2px;
    classDef redux fill:#fc9,stroke:#333,stroke-width:2px;
    classDef service fill:#cff,stroke:#333,stroke-width:2px;
    classDef native fill:#fcc,stroke:#333,stroke-width:2px;
    classDef test fill:#ff9,stroke:#333,stroke-width:2px;
    classDef config fill:#9ff,stroke:#333,stroke-width:2px;
```
