# gbrlcoelho/nubbleapp architecture

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

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

## Overview

##### Project Type & Purpose
- Full-stack (client-only) mobile application built with React Native + TypeScript.
- Acts as a social networking client: handles authentication, profile, feed browsing, posting, likes/comments, follow/unfollow.
- No backend code here; all data operations go through remote REST APIs via domain-layer adapters.

##### High-Level File-Structure Analysis
- Top-level: configuration (.gitignore, ESLint, Prettier, tsconfig), platform folders (android, ios), entry points (index.js, App.tsx).
- src/ folder subdivided into:
– components (reusable UI primitives & compound widgets)
– screens (feature screens organized by flow: auth, onboarding, app)
– routes (navigation stacks & routers)
– domain (business logic: adapters, APIs, services, use cases)
– services (cross-cutting concerns: authCredentials, multimedia, notifications, permissions, storage, toast, settings, searchHistory)
– infra (generic hooks and infra-level abstractions)
– theme & form & utils & types
– test (unit & integration mocks/servers)

##### Key Architectural Patterns
- Layered (Presentation → Domain → Infrastructure → External Services)
- Clean Architecture / use-case driven: domain/useCases expose hooks that UI consumes.
- Decorator/Adapter pattern: each domain entity (Auth, Post, User…) has adapter → api layer → service → useCases.
- React Context & Providers for cross-cutting services (AuthCredentialsProvider, ToastProvider).
- React Navigation for routing (stack/tab).

##### Main Components & Interactions
A. Presentation Layer
– Screens (src/screens/*)
– Shared Components (src/components/*)
– Form/Validation (src/form)
– Navigation (src/routes: AppStack, AuthStack, OnboardingStack)
B. Domain Layer
– Adapters (src/domain/*/*Adapter.ts) transform domain calls to HTTP calls.
– API modules (src/domain/*/*Api.ts) define HTTP endpoints/configs.
– Services (src/domain/*/*Service.ts) orchestrate domain logic.
– UseCases (src/domain/*/useCases/useXYZ.ts) expose business operations.
C. Infrastructure Layer
– apiAdapter & apiConfig (src/api) for HTTP client setup (Axios/fetch).
– Generic hooks (usePaginatedList, useMutation) in src/infra/hooks.
– Local storage implementations (MMKV, AsyncStorage) under services/storage.
– Context Providers (AuthCredentialsProvider, ToastProvider).
D. External Services
– Remote REST API server
– Device APIs: Camera, Permissions
– Push Notifications
– Local Storage
– Third-party libraries (@shopify/restyle for styling)

##### Data Flow & Relationships
- User interacts with UI (Screen components) → triggers a useCase hook.
- useCase calls domainService → which uses domainAdapter → apiAdapter → HTTP call to external API.
- Response propagates back: API → adapter → service → useCase → UI.
- UI updates state, re-renders components.
- Cross-cutting services (toast, auth credentials, settings) run via React Context.
- Navigation flows between stacks (Onboarding → Auth → App).

##### Essential Elements Checklist
[ ] Presentation Layer: Screens, Components, Navigation
[ ] Domain Layer: Adapters, APIs, Services, UseCases
[ ] Infrastructure: HTTP client, Storage, Context Providers, Hooks
[ ] External: API server, Device features, Third-party services

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Screens["Screens"]:::presentation
        Components["Shared Components"]:::presentation
        Form["Form / Validation"]:::presentation
        Navigation["Navigation (Stacks & Routers)"]:::presentation
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        subgraph "Adapters"
            direction TB
            AuthAdapter["AuthAdapter"]:::domain
            FollowAdapter["FollowAdapter"]:::domain
            PostAdapter["PostAdapter"]:::domain
            PostCommentAdapter["PostCommentAdapter"]:::domain
            PostReactionAdapter["PostReactionAdapter"]:::domain
            UserAdapter["UserAdapter"]:::domain
        end
        subgraph "API Modules"
            direction TB
            AuthApi["AuthApi"]:::domain
            FollowApi["FollowApi"]:::domain
            PostApi["PostApi"]:::domain
            PostCommentApi["PostCommentApi"]:::domain
            PostReactionApi["PostReactionApi"]:::domain
            UserApi["UserApi"]:::domain
        end
        subgraph "Services"
            direction TB
            AuthService["AuthService"]:::domain
            FollowService["FollowService"]:::domain
            PostService["PostService"]:::domain
            PostCommentService["PostCommentService"]:::domain
            PostReactionService["PostReactionService"]:::domain
            UserService["UserService"]:::domain
        end
        subgraph "UseCases"
            direction TB
            AuthUseCases["Auth UseCases"]:::domain
            FollowUseCases["Follow UseCases"]:::domain
            PostUseCases["Post UseCases"]:::domain
            PostCommentUseCases["PostComment UseCases"]:::domain
            PostReactionUseCases["PostReaction UseCases"]:::domain
            UserUseCases["User UseCases"]:::domain
        end
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        direction TB
        subgraph "HTTP Client"
            direction TB
            ApiAdapter["apiAdapter"]:::infra
            ApiConfig["apiConfig"]:::infra
        end
        subgraph "Generic Hooks"
            direction TB
            UseMutation["useMutation"]:::infra
            UsePaginatedList["usePaginatedList"]:::infra
        end
        subgraph "Context Providers"
            direction TB
            AuthProvider["AuthCredentialsProvider"]:::infra
            ToastProvider["ToastProvider"]:::infra
        end
        subgraph "Storage Implementations"
            direction TB
            MMKV["MMKVStorage"]:::infra
            AsyncStorage["AsyncStorage"]:::infra
        end
    end

    %% External Services
    subgraph "External Services"
        direction TB
        RestAPI["Remote REST API"]:::external
        Camera["Device Camera API"]:::external
        Permissions["Device Permissions API"]:::external
        PushNotifications["Push Notifications"]:::external
        LocalStorageExt["Local Storage"]:::external
        ThirdParty["Third-Party Libs (@shopify/restyle)"]:::external
    end

    %% Data Flow
    Screens -->|"triggers"| AuthUseCases
    Screens -->|"triggers"| FollowUseCases
    Screens -->|"triggers"| PostUseCases
    Screens -->|"triggers"| PostCommentUseCases
    Screens -->|"triggers"| PostReactionUseCases
    Screens -->|"triggers"| UserUseCases

    AuthUseCases -->|"uses"| AuthService
    FollowUseCases -->|"uses"| FollowService
    PostUseCases -->|"uses"| PostService
    PostCommentUseCases -->|"uses"| PostCommentService
    PostReactionUseCases -->|"uses"| PostReactionService
    UserUseCases -->|"uses"| UserService

    AuthService -->|"calls"| AuthAdapter
    FollowService -->|"calls"| FollowAdapter
    PostService -->|"calls"| PostAdapter
    PostCommentService -->|"calls"| PostCommentAdapter
    PostReactionService -->|"calls"| PostReactionAdapter
    UserService -->|"calls"| UserAdapter

    AuthAdapter -->|"HTTP via"| ApiAdapter
    FollowAdapter -->|"HTTP via"| ApiAdapter
    PostAdapter -->|"HTTP via"| ApiAdapter
    PostCommentAdapter -->|"HTTP via"| ApiAdapter
    PostReactionAdapter -->|"HTTP via"| ApiAdapter
    UserAdapter -->|"HTTP via"| ApiAdapter

    ApiAdapter -->|"config from"| ApiConfig
    ApiAdapter -->|"requests to"| RestAPI
    RestAPI -->|"response"| ApiAdapter

    %% Infrastructure interactions
    Screens -->|"provides| consumes context"| AuthProvider
    Screens -->|"provides| consumes context"| ToastProvider
    UseMutation -->|"used by"| PostUseCases
    UsePaginatedList -->|"used by"| PostCommentUseCases

    MMKV -->|"local storage"| LocalStorageExt
    AsyncStorage -->|"local storage"| LocalStorageExt

    Screens -->|"uses device"| Camera
    Screens -->|"uses device"| Permissions
    Screens -->|"uses| displays toast"| ToastProvider

    %% Navigation
    Navigation --> Screens

    %% Click Events
    click Screens "https://github.com/gbrlcoelho/nubbleapp/tree/master/src/screens"
    click Components "https://github.com/gbrlcoelho/nubbleapp/tree/master/src/components"
    click Form "https://github.com/gbrlcoelho/nubbleapp/tree/master/src/form"
    click Navigation "https://github.com/gbrlcoelho/nubbleapp/tree/master/src/routes"
    click AuthAdapter "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/Auth/authAdapter.ts"
    click FollowAdapter "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/Follow/followAdapter.ts"
    click PostAdapter "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/Post/postAdapter.ts"
    click PostCommentAdapter "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/PostComment/postCommentAdapter.ts"
    click PostReactionAdapter "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/PostReaction/postReactionAdapter.ts"
    click UserAdapter "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/User/userAdapter.ts"
    click AuthApi "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/Auth/authApi.ts"
    click FollowApi "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/Follow/followApi.ts"
    click PostApi "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/Post/postApi.ts"
    click PostCommentApi "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/PostComment/postCommentApi.ts"
    click PostReactionApi "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/PostReaction/postReactionApi.ts"
    click UserApi "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/User/userApi.ts"
    click AuthService "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/Auth/authService.ts"
    click FollowService "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/Follow/followService.ts"
    click PostService "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/Post/postService.ts"
    click PostCommentService "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/PostComment/postCommentService.ts"
    click PostReactionService "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/PostReaction/postReactionService.ts"
    click UserService "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/User/userService.ts"
    click AuthUseCases "https://github.com/gbrlcoelho/nubbleapp/tree/master/src/domain/Auth/useCases"
    click FollowUseCases "https://github.com/gbrlcoelho/nubbleapp/tree/master/src/domain/Follow/useCases"
    click PostUseCases "https://github.com/gbrlcoelho/nubbleapp/tree/master/src/domain/Post/useCases"
    click PostCommentUseCases "https://github.com/gbrlcoelho/nubbleapp/tree/master/src/domain/PostComment/useCases"
    click PostReactionUseCases "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/domain/PostReaction/useCases/useReactToPost.ts"
    click UserUseCases "https://github.com/gbrlcoelho/nubbleapp/tree/master/src/domain/User/useCases"
    click ApiAdapter "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/api/apiAdapter.ts"
    click ApiConfig "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/api/apiConfig.ts"
    click UseMutation "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/infra/hooks/useMutation.ts"
    click UsePaginatedList "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/infra/hooks/usePaginatedList.ts"
    click AuthProvider "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/services/authCredentials/Providers/AuthCredentialsProvider.tsx"
    click ToastProvider "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/services/toast/Providers/ToastProvider.tsx"
    click MMKV "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/services/storage/implementation/MMKVStorage.ts"
    click AsyncStorage "https://github.com/gbrlcoelho/nubbleapp/blob/master/src/services/storage/implementation/asyncStorage.ts"

    %% Styles
    classDef presentation fill:#E3F2FD,stroke:#42A5F5,color:#0D47A1
    classDef domain fill:#E8F5E9,stroke:#66BB6A,color:#1B5E20
    classDef infra fill:#FFF3E0,stroke:#FFA726,color:#E65100
    classDef external fill:#ECEFF1,stroke:#90A4AE,color:#37474F
```
