# jacklam718/crypto-app architecture

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

- Interactive diagram: https://gitdiagram.com/jacklam718/crypto-app
- Repository: https://github.com/jacklam718/crypto-app

## Overview

##### Project type and purpose
- This is a React Native mobile application built with Expo (“crypto-app”).
- It fetches and displays cryptocurrency data (lists of tokens, real-time updates, charts) and related social “thread” data.
- It uses React components for UI, custom hooks for data fetching and state, and TanStack Query (queryClient) for caching.

##### File structure
- Top level:
– app.json, babel.config.js, package.json, expo config → Expo/React Native setup
– src/ → application code
- Inside src/:
– components/ → reusable UI components (Graph, Header, Ticker, ThreadList, Tooltip, etc.)
– screens/ → page-level containers (TokenListScreen, TokenDetailsScreen)
– hooks/ → data-fetching hooks (useTokens, useRealtimeTokens, useNotification, etc.)
– api.js → API client (REST, perhaps WebSocket)
– queryClient.js → configuration of React Query
– themes/ → theming (light/dark)
– utils/ → helpers (throttle, transformers)

##### README for additional insights
- It’s deployed via Expo (mobile deep link, QR code).
- No on-premise backend code in repo—the app relies on external crypto APIs and real-time services.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Expo Runtime Host
    subgraph "Expo Runtime"
        direction TB

        %% Presentation Layer
        subgraph "Presentation Layer" 
            direction TB
            TLS["TokenListScreen"]:::ui
            TDS["TokenDetailsScreen"]:::ui
            GraphComp["Graph"]:::ui
            LineSeries["LineSeries"]:::ui
            Header["Header"]:::ui
            Ticker["Ticker"]:::ui
            TokenListComp["TokenList"]:::ui
            TokenListItem["TokenListItem"]:::ui
            ThreadListComp["ThreadList"]:::ui
            ThreadListItem["ThreadListItem"]:::ui
            Tooltip["Tooltip"]:::ui
            SegControl["SegmentedControl"]:::ui
            LoadingOverlay["LoadingOverlay"]:::ui
        end

        %% Data Layer
        subgraph "Data Layer" 
            direction TB
            UseTokens["useTokens()"]:::data
            UseRealTokens["useRealtimeTokens()"]:::data
            UseRealById["useRealtimeTokenById()"]:::data
            UseTrending["useTrendingPosts()"]:::data
            UseWatch["useWatchList()"]:::data
            UseNotif["useNotification()"]:::data
            API["api.js"]:::data
            QueryClient["queryClient.js"]:::data
        end

        %% Theme & Assets
        subgraph "Theme & Assets"
            direction TB
            LightTheme["lightTheme.js"]:::theme
            DarkTheme["darkTheme.js"]:::theme
            ThemeIndex["index.js"]:::theme
            Assets["assets/*"]:::theme
        end

    end

    %% External Services
    CryptoREST[(Crypto REST API)]:::external
    CryptoRT[(Crypto Real-Time Service)]:::external
    ExpoPush[(Expo Push Notification Service)]:::external

    %% Relationships: UI to Hooks
    TLS -->|uses| UseTokens
    TLS -->|uses| UseWatch
    TLS -->|uses| UseTrending
    TDS -->|uses| UseRealById
    TDS -->|uses| UseTokens

    %% Components trigger Hooks
    GraphComp -->|calls| UseRealById
    LineSeries -->|calls| UseRealById
    TokenListComp -->|calls| UseTokens
    TokenListItem -->|calls| UseWatch
    ThreadListComp -->|calls| UseTrending
    ThreadListItem -->|calls| UseTrending

    %% Hooks to Client & Cache
    UseTokens -->|fetch GET /tokens| API
    UseRealTokens -->|open priceStream| API
    UseRealById -->|open priceStreamById| API
    UseTrending -->|fetch GET /threads| API
    UseWatch -->|read/write| QueryClient
    UseNotif -->|register| ExpoPush

    %% API and QueryClient interactions
    API -->|response| QueryClient
    QueryClient -->|cache data| UseTokens
    QueryClient -->|subscribe updates| UseRealTokens

    %% API to External
    API -->|HTTP| CryptoREST
    API -->|WebSocket| CryptoRT
    UseNotif -->|push registration| ExpoPush

    %% Theme & Assets used by UI
    ThemeIndex -->|provides| TLS
    ThemeIndex -->|provides| TDS
    ThemeIndex -->|provides| GraphComp
    Assets -->|icons/animations| GraphComp
    Assets -->|icons/animations| LoadingOverlay

    %% Click Events for component mapping
    click TLS "https://github.com/jacklam718/crypto-app/blob/master/src/screens/TokenListScreen.js"
    click TDS "https://github.com/jacklam718/crypto-app/blob/master/src/screens/TokenDetailsScreen.js"
    click GraphComp "https://github.com/jacklam718/crypto-app/blob/master/src/components/Graph.js"
    click LineSeries "https://github.com/jacklam718/crypto-app/blob/master/src/components/LineSeries.js"
    click Header "https://github.com/jacklam718/crypto-app/blob/master/src/components/Header.js"
    click Ticker "https://github.com/jacklam718/crypto-app/blob/master/src/components/Ticker.js"
    click TokenListComp "https://github.com/jacklam718/crypto-app/blob/master/src/components/TokenList.js"
    click TokenListItem "https://github.com/jacklam718/crypto-app/blob/master/src/components/TokenListItem.js"
    click ThreadListComp "https://github.com/jacklam718/crypto-app/blob/master/src/components/ThreadList.js"
    click ThreadListItem "https://github.com/jacklam718/crypto-app/blob/master/src/components/ThreadListItem.js"
    click Tooltip "https://github.com/jacklam718/crypto-app/blob/master/src/components/Tooltip.js"
    click SegControl "https://github.com/jacklam718/crypto-app/blob/master/src/components/SegmentedControl.js"
    click LoadingOverlay "https://github.com/jacklam718/crypto-app/blob/master/src/components/LoadingOverlay.js"
    click UseTokens "https://github.com/jacklam718/crypto-app/blob/master/src/hooks/useTokens.js"
    click UseRealTokens "https://github.com/jacklam718/crypto-app/blob/master/src/hooks/useRealtimeTokens.js"
    click UseRealById "https://github.com/jacklam718/crypto-app/blob/master/src/hooks/useRealtimeTokenById.js"
    click UseTrending "https://github.com/jacklam718/crypto-app/blob/master/src/hooks/useTrendingPosts.js"
    click UseWatch "https://github.com/jacklam718/crypto-app/blob/master/src/hooks/useWatchList.js"
    click UseNotif "https://github.com/jacklam718/crypto-app/blob/master/src/hooks/useNotification.js"
    click API "https://github.com/jacklam718/crypto-app/blob/master/src/api.js"
    click QueryClient "https://github.com/jacklam718/crypto-app/blob/master/src/queryClient.js"
    click LightTheme "https://github.com/jacklam718/crypto-app/blob/master/src/themes/lightTheme.js"
    click DarkTheme "https://github.com/jacklam718/crypto-app/blob/master/src/themes/darkTheme.js"
    click ThemeIndex "https://github.com/jacklam718/crypto-app/blob/master/src/themes/index.js"

    %% Styles
    classDef ui fill:#blue,stroke:#000,color:#fff
    classDef data fill:#9f6,stroke:#060,color:#000
    classDef theme fill:#fc9,stroke:#a60,color:#000
    classDef external fill:#f96,stroke:#900,color:#000
```
