# fmoraless/nubbleapp architecture

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

- Interactive diagram: https://gitdiagram.com/fmoraless/nubbleapp
- Repository: https://github.com/fmoraless/nubbleapp

## Overview

##### Project Type and Purpose
- This is a full-client React Native mobile application (iOS + Android) structured with:
- A Presentation/UI layer (screens, components, routing)
- A Domain/Use-Case layer (business logic, services)
- An Infrastructure layer (API adapters, storage)
- Native device integrations (camera, storage, permissions)
- It consumes a remote REST API and uses local storage (MMKV or AsyncStorage).

##### File Structure
- Top-level “android” and “ios” folders: native build targets.
- “src” subdivided into:
- api (apiAdapter, configuration, types)
- domain (Auth, Post, PostComment, PostReaction, User – each with adapters, APIs, services, use-cases)
- infra (generic hooks: paginated list, mutation)
- services (permission, cameraRoll, multimedia, authCredentials, storage, toast, etc.)
- routes (navigation stacks, tab bar, router)
- screens (auth, onboarding, app flows)
- components (UI primitives, form inputs, lists, indicators)
- assets, theme, utils, types
- Configuration: metro.config.js, babel.config.js, jest.config.ts, Android/iOS build files.

##### README for Insights
- Confirms React Native bootstrap with Metro bundler.
- No backend code here—app relies on external API servers.

##### Defining Main Components
a. Presentation Layer
- App entry (index.js → App.tsx)
- Navigation (Routes → AuthStack, OnboardingStack, AppStack/AppTabNavigator)
- Screens and UI components
b. Domain Layer
- Use-Cases (e.g. useAuthSignIn, usePostList, usePostCreate)
- Domain services/managers (authService, postService, etc.)
c. Infrastructure Layer
- API Adapter / apiConfig (axios or fetch wrapper)
- Storage implementations (MMKV, AsyncStorage)
- Generic React hooks (usePaginatedList, useMutation)
d. Native Device Services
- Camera (react-native-vision-camera), cameraRollService
- Permissions (permissionService)
- Toast provider
e. External Services
- Remote REST API endpoints (Auth API, Posts API, Comments API)
- Third-party native modules (MMKV storage, AsyncStorage)

##### Mapping Relationships & Data Flow
1. User taps UI → screen component
2. Screen dispatches a domain use-case hook
3. Use-case calls its domain service
4. Service invokes an infrastructure adapter (API or storage)
5. Adapter performs network/storage I/O
6. Response propagates back up (adapter → service → use-case → UI)
7. Navigation events flow between routing components

##### Architectural Patterns & Principles
- Clean Architecture (separation into layers—UI, domain, infra)
- Dependency Inversion (domain logic depends on abstractions, not on concrete adapters)
- Component-based UI with presentational vs. container patterns
- Hooks for side-effects and data fetching

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        AppEntry["index.js / App.tsx"]:::ui
        Navigation["Routes & Stacks"]:::ui
        Screens["Screens (Auth, Onboarding, App)"]:::ui
        UIComponents["UI Components"]:::ui
    end

    %% Domain Layer
    subgraph "Domain Layer" 
        direction TB
        UseCases["Use-Cases"]:::domain
        Services["Domain Services"]:::domain
        AdaptersAPIs["Adapters & APIs"]:::domain
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        direction TB
        APIConfig["API Config & Adapter"]:::infra
        GenericHooks["Generic Hooks"]:::infra
        StorageAdapters["Local Storage Adapters"]:::infra
    end

    %% Native Modules
    subgraph "Native Device Services"
        direction TB
        CameraRoll["CameraRoll Service"]:::native
        Permission["Permission Service"]:::native
        Multimedia["Multimedia Service"]:::native
        Toast["Toast Provider"]:::native
    end

    %% External Services
    subgraph "External Services"
        direction TB
        RESTAPI["Remote REST API Endpoints"]:::external
    end

    %% Connections
    AppEntry -->|initializes| Navigation
    Navigation -->|renders| Screens
    Screens -->|uses| UIComponents
    Screens -->|dispatches| UseCases
    UseCases -->|calls| Services
    Services -->|invokes| AdaptersAPIs
    AdaptersAPIs -->|performs| APIConfig
    AdaptersAPIs -->|uses| StorageAdapters
    APIConfig -->|network I/O| RESTAPI
    StorageAdapters -->|local I/O| RESTAPI
    Services -->|calls| CameraRoll
    Services -->|calls| Permission
    Services -->|calls| Multimedia
    AppEntry -->|provides| Toast
    Services -->|uses| Toast

    %% Click Events
    click AppEntry "https://github.com/fmoraless/nubbleapp/blob/main/index.js"
    click AppEntry "https://github.com/fmoraless/nubbleapp/blob/main/App.tsx"
    click Navigation "https://github.com/fmoraless/nubbleapp/blob/main/src/routes/Routes.tsx"
    click Navigation "https://github.com/fmoraless/nubbleapp/blob/main/src/routes/AuthStack.tsx"
    click Navigation "https://github.com/fmoraless/nubbleapp/blob/main/src/routes/OnboardingStack.tsx"
    click Navigation "https://github.com/fmoraless/nubbleapp/blob/main/src/routes/AppStack.tsx"
    click Navigation "https://github.com/fmoraless/nubbleapp/blob/main/src/routes/AppTabNavigator.tsx"
    click Navigation "https://github.com/fmoraless/nubbleapp/blob/main/src/routes/AppTabBar.tsx"
    click Screens "https://github.com/fmoraless/nubbleapp/tree/main/src/screens/auth"
    click Screens "https://github.com/fmoraless/nubbleapp/blob/main/src/screens/onboarding/OnboardingScreen/OnboardingScreen.tsx"
    click Screens "https://github.com/fmoraless/nubbleapp/tree/main/src/screens/app"
    click UIComponents "https://github.com/fmoraless/nubbleapp/tree/main/src/components"
    click UseCases "https://github.com/fmoraless/nubbleapp/tree/main/src/domain/Auth/useCases"
    click Services "https://github.com/fmoraless/nubbleapp/blob/main/src/domain/Auth/authService.ts"
    click UseCases "https://github.com/fmoraless/nubbleapp/tree/main/src/domain/Post/useCases"
    click Services "https://github.com/fmoraless/nubbleapp/blob/main/src/domain/Post/postService.ts"
    click UseCases "https://github.com/fmoraless/nubbleapp/tree/main/src/domain/PostComment/useCases"
    click Services "https://github.com/fmoraless/nubbleapp/blob/main/src/domain/PostComment/postCommentService.ts"
    click UseCases "https://github.com/fmoraless/nubbleapp/tree/main/src/domain/PostReaction/useCases"
    click Services "https://github.com/fmoraless/nubbleapp/blob/main/src/domain/PostReaction/postReactionService.ts"
    click UseCases "https://github.com/fmoraless/nubbleapp/tree/main/src/domain/User/useCases"
    click Services "https://github.com/fmoraless/nubbleapp/blob/main/src/domain/User/userService.ts"
    click AdaptersAPIs "https://github.com/fmoraless/nubbleapp/blob/main/src/domain/Auth/authAdapter.ts"
    click AdaptersAPIs "https://github.com/fmoraless/nubbleapp/blob/main/src/domain/Auth/authApi.ts"
    click AdaptersAPIs "https://github.com/fmoraless/nubbleapp/blob/main/src/domain/Post/postAdapter.ts"
    click AdaptersAPIs "https://github.com/fmoraless/nubbleapp/blob/main/src/domain/Post/postApi.ts"
    click AdaptersAPIs "https://github.com/fmoraless/nubbleapp/blob/main/src/domain/PostComment/postCommentAdapter.ts"
    click AdaptersAPIs "https://github.com/fmoraless/nubbleapp/blob/main/src/domain/PostComment/postCommentApi.ts"
    click AdaptersAPIs "https://github.com/fmoraless/nubbleapp/blob/main/src/domain/PostReaction/postReactionAdapter.ts"
    click AdaptersAPIs "https://github.com/fmoraless/nubbleapp/blob/main/src/domain/PostReaction/postReactionApi.ts"
    click AdaptersAPIs "https://github.com/fmoraless/nubbleapp/blob/main/src/domain/User/userAdapter.ts"
    click AdaptersAPIs "https://github.com/fmoraless/nubbleapp/blob/main/src/domain/User/userApi.ts"
    click APIConfig "https://github.com/fmoraless/nubbleapp/blob/main/src/api/apiAdapter.ts"
    click APIConfig "https://github.com/fmoraless/nubbleapp/blob/main/src/api/apiConfig.ts"
    click APIConfig "https://github.com/fmoraless/nubbleapp/blob/main/src/api/apiTypes.ts"
    click APIConfig "https://github.com/fmoraless/nubbleapp/blob/main/src/api/index.ts"
    click GenericHooks "https://github.com/fmoraless/nubbleapp/blob/main/src/infra/hooks/usePaginatedList.ts"
    click GenericHooks "https://github.com/fmoraless/nubbleapp/blob/main/src/infra/hooks/useMutation.ts"
    click GenericHooks "https://github.com/fmoraless/nubbleapp/blob/main/src/infra/infraTypes.ts"
    click GenericHooks "https://github.com/fmoraless/nubbleapp/blob/main/src/infra/index.ts"
    click StorageAdapters "https://github.com/fmoraless/nubbleapp/blob/main/src/services/storage/implementation/MMKVStorage.ts"
    click StorageAdapters "https://github.com/fmoraless/nubbleapp/blob/main/src/services/storage/implementation/asyncStorage.ts"
    click StorageAdapters "https://github.com/fmoraless/nubbleapp/blob/main/src/services/storage/storage.ts"
    click StorageAdapters "https://github.com/fmoraless/nubbleapp/blob/main/src/services/storage/index.ts"
    click CameraRoll "https://github.com/fmoraless/nubbleapp/blob/main/src/services/cameraRoll/cameraRollService.ts"
    click CameraRoll "https://github.com/fmoraless/nubbleapp/blob/main/src/services/cameraRoll/useCameraRoll.ts"
    click Permission "https://github.com/fmoraless/nubbleapp/blob/main/src/services/permission/permissionService.ts"
    click Permission "https://github.com/fmoraless/nubbleapp/blob/main/src/services/permission/usePermission.ts"
    click Multimedia "https://github.com/fmoraless/nubbleapp/blob/main/src/services/multimedia/multimediaService.ts"
    click Multimedia "https://github.com/fmoraless/nubbleapp/blob/main/src/services/multimedia/useMultimediaGetPhotos.ts"
    click Toast "https://github.com/fmoraless/nubbleapp/blob/main/src/services/toast/Providers/ToastProvider.tsx"
    click Toast "https://github.com/fmoraless/nubbleapp/blob/main/src/services/toast/useToast.tsx"
    click Toast "https://github.com/fmoraless/nubbleapp/blob/main/src/services/toast/useToastContext.ts"
    click Toast "https://github.com/fmoraless/nubbleapp/blob/main/src/services/toast/useToastZustand.ts"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#3B82F6,color:#000
    classDef domain fill:#D1FAE5,stroke:#10B981,color:#000
    classDef infra fill:#FFEBC1,stroke:#F59E0B,color:#000
    classDef native fill:#E5E7EB,stroke:#6B7280,color:#000
    classDef external fill:#FFF1F2,stroke:#EF4444,stroke-dasharray: 5 5,color:#000
```
