# dunkeyyfong/fsmall architecture

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

- Interactive diagram: https://gitdiagram.com/dunkeyyfong/fsmall
- Repository: https://github.com/dunkeyyfong/fsmall

## Overview

##### Project Type and Purpose
- FSmall is a mobile app (React Native) that acts as a minimal web browser.
- It provides features such as full-text search of visited pages, automatic reader view for articles, dark mode, and file download/management.
- That although the core app logic is in React Native, there’s an iOS directory that holds native code and project configuration for iOS-specific builds.

##### High-Level Components
a. App Entry Points:
- index.js and App.js: Consider these as the bootstrap or root of the application.

b. User Interface Components:
- The components folder (Browser.js, CustomBackground.js, CustomButton.js, NavigationBar.js, TabBar.js) houses reusable UI elements.
- The screens folder holds the different full-page views: BrowserScreen, HomeScreen, SettingsScreen, and WelcomeScreen.
- The navigations folder (AppNavigator.js and TabNavigator.js) manages view routing and screen transitions.

c. State Management:
- The context folder (TabContext.js and TabProvider.js) is used for application state management, particularly for managing tab state and interaction across components.

d. Assets and Styling:
- The assets folder contains images, and the styles folder (globalStyles.js) and tailwind configuration file indicate usage of TailwindCSS (or similar styling approaches) with possible utility-based styling.

e. Utility Functions:
- Utils such as downloadFile.js manage specific functionalities like file downloads.

f. Native Code Integration:
- The ios directory contains platform-specific (iOS) native code and configuration that integrates with the React Native layer. This offers insight into where the JS code interacts with native modules and the iOS lifecycle.

g. Build and Deployment:
- Files like package.json, pnpm-lock.yaml, .npmrc, babel.config.js, and GitHub workflows (in .github/workflows) illustrate dependency management, build configuration, and CI/CD processes (like npm publishing).

##### Relationships and Interactions
- The presentation layer (UI components and screens).
- The navigation layer (managing transitions and routes).
- The context layer (global state management with TabContext).
- The utility layer (helper functions such as file download).
- If desired, show the CI/CD pipeline via GitHub Actions next to the source code component structure.

##### Architectural Patterns and Design Principles
- Clearly separate concerns: UI logic (screens, components) is distinct from navigation and state management.
- Use unidirectional data flow: the context passes data to children components and screens.
- The modular structure (with dedicated directories for components, screens, context, navigations, and utils) reflects a clean, maintainable separation of responsibilities.
- Integration of native mobile components (especially evident in the ios directory) which ensures seamless bridging with React Native’s cross-platform capabilities.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% App Entry Layer
    subgraph "App Entry"
        A["index.js"]:::entry
        B["App.js"]:::entry
    end

    %% Navigation & Routing Layer
    subgraph "Navigation & Routing Layer"
        C["AppNavigator.js"]:::nav
        D["TabNavigator.js"]:::nav
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        %% Screens Sub-layer
        subgraph "Screens"
            E["BrowserScreen.js"]:::screen
            F["HomeScreen.js"]:::screen
            G["SettingsScreen.js"]:::screen
            H["WelcomeScreen.js"]:::screen
        end
        %% UI Components Sub-layer
        subgraph "UI Components"
            I["Browser.js"]:::ui
            J["CustomBackground.js"]:::ui
            K["CustomButton.js"]:::ui
            L["NavigationBar.js"]:::ui
            M["TabBar.js"]:::ui
        end
    end

    %% State Management Layer
    subgraph "State Management Layer"
        N["TabContext.js"]:::state
        O["TabProvider.js"]:::state
    end

    %% Assets & Styling Layer
    subgraph "Assets & Styling"
        P["assets/images"]:::asset
        Q["globalStyles.js"]:::asset
        R["tailwind.config.js"]:::asset
    end

    %% Utility Layer
    subgraph "Utility Layer"
        S["downloadFile.js"]:::util
    end

    %% Native Platform Layer
    subgraph "Native Platform Layer"
        T["ios"]:::native
    end

    %% Build & Deployment Layer
    subgraph "Build & Deployment"
        U["package.json"]:::build
        V["pnpm-lock.yaml"]:::build
        W[".npmrc"]:::build
        X["babel.config.js"]:::build
        Y[".github/workflows/npm-publish.yml"]:::build
    end

    %% Relationships
    A --> B
    B --> C
    B --> D
    C --> E
    C --> F
    C --> G
    C --> H
    D --> E
    D --> F
    D --> G
    D --> H
    %% Screens utilize UI Components (representative connections)
    E --> I
    F --> J
    G --> K
    H --> L
    H --> M
    %% Screens leverage State Management
    E --> N
    F --> O
    %% UI Components use Utility functions (e.g., file download)
    J --> S
    %% App bridges to Native Platform
    B --> T
    %% Assets & Styling used by Screens
    H --> P
    %% Build & Deployment supports App Entry
    U --> A

    %% Styles and Colors
    classDef entry fill:#FFCC00,stroke:#333,stroke-width:2px;
    classDef nav fill:#66CCFF,stroke:#333,stroke-width:2px;
    classDef screen fill:#CCFFCC,stroke:#333,stroke-width:2px;
    classDef ui fill:#FFCCCC,stroke:#333,stroke-width:2px;
    classDef state fill:#FFFFCC,stroke:#333,stroke-width:2px;
    classDef asset fill:#DDA0DD,stroke:#333,stroke-width:2px;
    classDef util fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef native fill:#87CEEB,stroke:#333,stroke-width:2px;
    classDef build fill:#C0C0C0,stroke:#333,stroke-width:2px;

    %% Click Events for App Entry
    click A "https://github.com/dunkeyyfong/fsmall/blob/dev/index.js"
    click B "https://github.com/dunkeyyfong/fsmall/blob/dev/App.js"

    %% Click Events for Navigation & Routing
    click C "https://github.com/dunkeyyfong/fsmall/blob/dev/navigations/AppNavigator.js"
    click D "https://github.com/dunkeyyfong/fsmall/blob/dev/navigations/TabNavigator.js"

    %% Click Events for Screens
    click E "https://github.com/dunkeyyfong/fsmall/blob/dev/screens/BrowserScreen.js"
    click F "https://github.com/dunkeyyfong/fsmall/blob/dev/screens/HomeScreen.js"
    click G "https://github.com/dunkeyyfong/fsmall/blob/dev/screens/SettingsScreen.js"
    click H "https://github.com/dunkeyyfong/fsmall/blob/dev/screens/WelcomeScreen.js"

    %% Click Events for UI Components
    click I "https://github.com/dunkeyyfong/fsmall/blob/dev/components/Browser.js"
    click J "https://github.com/dunkeyyfong/fsmall/blob/dev/components/CustomBackground.js"
    click K "https://github.com/dunkeyyfong/fsmall/blob/dev/components/CustomButton.js"
    click L "https://github.com/dunkeyyfong/fsmall/blob/dev/components/NavigationBar.js"
    click M "https://github.com/dunkeyyfong/fsmall/blob/dev/components/TabBar.js"

    %% Click Events for State Management
    click N "https://github.com/dunkeyyfong/fsmall/blob/dev/context/TabContext.js"
    click O "https://github.com/dunkeyyfong/fsmall/blob/dev/context/TabProvider.js"

    %% Click Events for Assets & Styling
    click P "https://github.com/dunkeyyfong/fsmall/tree/dev/assets/images"
    click Q "https://github.com/dunkeyyfong/fsmall/blob/dev/styles/globalStyles.js"
    click R "https://github.com/dunkeyyfong/fsmall/blob/dev/tailwind.config.js"

    %% Click Event for Utility Functions
    click S "https://github.com/dunkeyyfong/fsmall/blob/dev/utils/downloadFile.js"

    %% Click Event for Native Platform
    click T "https://github.com/dunkeyyfong/fsmall/tree/dev/ios"

    %% Click Events for Build & Deployment
    click U "https://github.com/dunkeyyfong/fsmall/blob/dev/package.json"
    click V "https://github.com/dunkeyyfong/fsmall/blob/dev/pnpm-lock.yaml"
    click W "https://github.com/dunkeyyfong/fsmall/blob/dev/.npmrc"
    click X "https://github.com/dunkeyyfong/fsmall/blob/dev/babel.config.js"
    click Y "https://github.com/dunkeyyfong/fsmall/blob/dev/.github/workflows/npm-publish.yml"
```
