# rohanberadev/expo-scroll-v1 architecture

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

- Interactive diagram: https://gitdiagram.com/rohanberadev/expo-scroll-v1
- Repository: https://github.com/rohanberadev/expo-scroll-v1

## Overview

##### Project type and purpose
- This is a cross-platform mobile app built on Expo (React Native) with file-based routing and Tailwind styling.
- It leverages Appwrite as a BaaS for authentication, database, and storage.

##### File structure
- **android/**: Native Android project (Gradle, Manifest, Kotlin entry points).
- **app/**: Expo Router file-based routes → each `.tsx` maps to a screen (tabs, auth flow, profile, posts).
- **components/**: Reusable presentational React components (cards, buttons, inputs).
- **contexts/**: React Contexts (e.g. `auth.tsx`) for global state (authentication).
- **hooks/**: Custom hooks for CRUD operations (`posts`, `comments`, `follows`, `userProfiles`).
- **services/** + **data/**: Wrappers around the Appwrite client (`data/appwrite.ts` initializes client; `services/appwrite.ts` exposes typed API functions).
- **constants/**, **interfaces/**, **types/**: Shared types, enums, and static assets definitions.
- **lib/**: Utility functions (e.g. file handling).
- Config & tooling: `babel.config.js`, `metro.config.js`, `tailwind.config.js`, `package.json`.

##### Main components and their interactions
a. **UI Layer**
- **Screens** (app/…/*.tsx) drive the navigation flow.
- **Components** render structured UI elements.
b. **State & Business Logic**
- **Contexts** provide authentication state and dispatcher functions.
- **Hooks** perform data fetching/mutations and emit states (loading, error, data).
c. **Data Layer**
- **Services** implement calls to the Appwrite SDK.
- **Appwrite SDK** (in `data/appwrite.ts`) handles low-level HTTP communication.
d. **Native & Build Tools**
- **Expo Runtime** / Metro Bundler builds and serves JS to devices.
- **Android Container** hosts the JS engine on Android devices.
e. **External Services**
- **Appwrite Server** (hosted externally) for auth, database, storage.

##### Architectural patterns & design principles
- **File-based routing**: directory names → URI/screen mapping.
- **Component-based architecture**: separation of concerns between UI, logic, and data.
- **Hooks for side-effects**: encapsulate data logic, align with React Query patterns.
- **Context API**: manage cross-cutting concerns (auth).
- **BaaS integration**: Appwrite as single source of truth for back-end services.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        Home["Home Screen\napp/(app)/(tabs)/home.tsx"]:::ui
        CreatePost["Create Post Screen\napp/(app)/(tabs)/create.tsx"]:::ui
        MyProfile["My Profile Screen\napp/(app)/(tabs)/myProfile.tsx"]:::ui
        Search["Search Screen\napp/(app)/(tabs)/search.tsx"]:::ui
        Followers["Followers List Screen\napp/(app)/followers/[userId].tsx"]:::ui
        Followings["Followings List Screen\napp/(app)/followings/[userId].tsx"]:::ui
        SinglePost["Single Post Screen\napp/(app)/post/[id].tsx"]:::ui
        UserProfile["User Profile Screen\napp/(app)/profile/[id].tsx"]:::ui
        SavedPosts["Saved Posts Screen\napp/(app)/saved.tsx"]:::ui
        SignIn["Sign In Screen\napp/(auth)/signIn.tsx"]:::ui
        SignUp["Sign Up Screen\napp/(auth)/signUp.tsx"]:::ui
        PostCard["PostCard\ncomponents/PostCard.tsx"]:::ui
        CommentCard["CommentCard\ncomponents/CommentCard.tsx"]:::ui
        TrendingPostCard["TrendingPostCard\ncomponents/TrendingPostCard.tsx"]:::ui
        UserProfileCard["UserProfileCard\ncomponents/UserProfileCard.tsx"]:::ui
        FollowButton["FollowButton\ncomponents/FollowButton.tsx"]:::ui
        PostDeleteButton["PostDeleteButton\ncomponents/PostDeleteButton.tsx"]:::ui
        SearchBar["SearchBar\ncomponents/SearchBar.tsx"]:::ui
        MyTextInput["MyTextInput\ncomponents/MyTextInput.tsx"]:::ui
        AppLogo["AppLogo\ncomponents/AppLogo.tsx"]:::ui
    end

    %% Logic Layer
    subgraph "Logic Layer"
        direction TB
        AuthContext["Authentication Context\ncontexts/auth.tsx"]:::logic
        PostsHook["usePosts Hook\nhooks/posts.ts"]:::logic
        CommentHook["useComment Hook\nhooks/comment.ts"]:::logic
        FollowsHook["useFollows Hook\nhooks/follows.ts"]:::logic
        UserProfilesHook["useUserProfiles Hook\nhooks/userProfiles.ts"]:::logic
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        AppwriteInit["Appwrite SDK Init\ndata/appwrite.ts"]:::data
        AppwriteService["Appwrite API Services\nservices/appwrite.ts"]:::data
        IconsConst["Icons Constants\nconstants/icons.ts"]:::data
        ImageConst["Image Constants\nconstants/image.ts"]:::data
        QueryConst["Query Constants\nconstants/query.ts"]:::data
        AppwriteInterface["Appwrite Interfaces\ninterfaces/appwrite.ts"]:::data
        ImageType["Image Types\ntypes/image.d.ts"]:::data
        FileUtil["File Utils\nlib/file.ts"]:::data
    end

    %% Native & Tooling
    subgraph "Native & Tooling"
        direction TB
        MetroConfig["Metro Config\nmetro.config.js"]:::native
        BabelConfig["Babel Config\nbabel.config.js"]:::native
        TailwindConfig["Tailwind Config\ntailwind.config.js"]:::native
        MainActivity["MainActivity.kt\nandroid/app/src/main/java/com/rohanberadev/scroll/MainActivity.kt"]:::native
        MainApplication["MainApplication.kt\nandroid/app/src/main/java/com/rohanberadev/scroll/MainApplication.kt"]:::native
    end

    %% External Services
    AppwriteServer["Appwrite Server"]:::external

    %% Connections
    %% UI to Logic
    subgraph UI_to_Logic
        Home -->|uses| AuthContext
        CreatePost -->|uses| PostsHook
        MyProfile -->|uses| UserProfilesHook
        Search -->|uses| PostsHook
        Followers -->|uses| FollowsHook
        Followings -->|uses| FollowsHook
        SinglePost -->|uses| CommentHook
        UserProfile -->|uses| UserProfilesHook
        SavedPosts -->|uses| PostsHook
        SignIn -->|uses| AuthContext
        SignUp -->|uses| AuthContext
        PostCard -->|renders| CommentHook
        CommentCard -->|renders| CommentHook
        TrendingPostCard -->|renders| PostsHook
        UserProfileCard -->|renders| UserProfilesHook
        FollowButton -->|calls| FollowsHook
        PostDeleteButton -->|calls| PostsHook
        SearchBar -->|calls| PostsHook
        MyTextInput -->|calls| AuthContext
    end

    %% Logic to Data
    AuthContext -->|auth calls| AppwriteService
    PostsHook -->|data calls| AppwriteService
    CommentHook -->|data calls| AppwriteService
    FollowsHook -->|data calls| AppwriteService
    UserProfilesHook -->|data calls| AppwriteService

    %% Data to Appwrite
    AppwriteService -->|uses SDK| AppwriteInit
    AppwriteInit -->|network| AppwriteServer

    %% Tooling to UI
    MetroConfig -->|bundles| Home
    BabelConfig -->|transpiles| Home
    TailwindConfig -->|styles| Home

    %% Native container
    MainActivity -->|hosts| Home
    MainApplication -->|initializes| AppwriteInit

    %% Click Events
    click Home "https://github.com/rohanberadev/expo-scroll-v1/blob/main/app/(app)/(tabs)/home.tsx"
    click CreatePost "https://github.com/rohanberadev/expo-scroll-v1/blob/main/app/(app)/(tabs)/create.tsx"
    click MyProfile "https://github.com/rohanberadev/expo-scroll-v1/blob/main/app/(app)/(tabs)/myProfile.tsx"
    click Search "https://github.com/rohanberadev/expo-scroll-v1/blob/main/app/(app)/(tabs)/search.tsx"
    click Followers "https://github.com/rohanberadev/expo-scroll-v1/blob/main/app/(app)/followers/[userId].tsx"
    click Followings "https://github.com/rohanberadev/expo-scroll-v1/blob/main/app/(app)/followings/[userId].tsx"
    click SinglePost "https://github.com/rohanberadev/expo-scroll-v1/blob/main/app/(app)/post/[id].tsx"
    click UserProfile "https://github.com/rohanberadev/expo-scroll-v1/blob/main/app/(app)/profile/[id].tsx"
    click SavedPosts "https://github.com/rohanberadev/expo-scroll-v1/blob/main/app/(app)/saved.tsx"
    click SignIn "https://github.com/rohanberadev/expo-scroll-v1/blob/main/app/(auth)/signIn.tsx"
    click SignUp "https://github.com/rohanberadev/expo-scroll-v1/blob/main/app/(auth)/signUp.tsx"
    click PostCard "https://github.com/rohanberadev/expo-scroll-v1/blob/main/components/PostCard.tsx"
    click CommentCard "https://github.com/rohanberadev/expo-scroll-v1/blob/main/components/CommentCard.tsx"
    click TrendingPostCard "https://github.com/rohanberadev/expo-scroll-v1/blob/main/components/TrendingPostCard.tsx"
    click UserProfileCard "https://github.com/rohanberadev/expo-scroll-v1/blob/main/components/UserProfileCard.tsx"
    click FollowButton "https://github.com/rohanberadev/expo-scroll-v1/blob/main/components/FollowButton.tsx"
    click PostDeleteButton "https://github.com/rohanberadev/expo-scroll-v1/blob/main/components/PostDeleteButton.tsx"
    click SearchBar "https://github.com/rohanberadev/expo-scroll-v1/blob/main/components/SearchBar.tsx"
    click MyTextInput "https://github.com/rohanberadev/expo-scroll-v1/blob/main/components/MyTextInput.tsx"
    click AppLogo "https://github.com/rohanberadev/expo-scroll-v1/blob/main/components/AppLogo.tsx"
    click AuthContext "https://github.com/rohanberadev/expo-scroll-v1/blob/main/contexts/auth.tsx"
    click PostsHook "https://github.com/rohanberadev/expo-scroll-v1/blob/main/hooks/posts.ts"
    click CommentHook "https://github.com/rohanberadev/expo-scroll-v1/blob/main/hooks/comment.ts"
    click FollowsHook "https://github.com/rohanberadev/expo-scroll-v1/blob/main/hooks/follows.ts"
    click UserProfilesHook "https://github.com/rohanberadev/expo-scroll-v1/blob/main/hooks/userProfiles.ts"
    click AppwriteInit "https://github.com/rohanberadev/expo-scroll-v1/blob/main/data/appwrite.ts"
    click AppwriteService "https://github.com/rohanberadev/expo-scroll-v1/blob/main/services/appwrite.ts"
    click IconsConst "https://github.com/rohanberadev/expo-scroll-v1/blob/main/constants/icons.ts"
    click ImageConst "https://github.com/rohanberadev/expo-scroll-v1/blob/main/constants/image.ts"
    click QueryConst "https://github.com/rohanberadev/expo-scroll-v1/blob/main/constants/query.ts"
    click AppwriteInterface "https://github.com/rohanberadev/expo-scroll-v1/blob/main/interfaces/appwrite.ts"
    click ImageType "https://github.com/rohanberadev/expo-scroll-v1/blob/main/types/image.d.ts"
    click FileUtil "https://github.com/rohanberadev/expo-scroll-v1/blob/main/lib/file.ts"
    click MetroConfig "https://github.com/rohanberadev/expo-scroll-v1/blob/main/metro.config.js"
    click BabelConfig "https://github.com/rohanberadev/expo-scroll-v1/blob/main/babel.config.js"
    click TailwindConfig "https://github.com/rohanberadev/expo-scroll-v1/blob/main/tailwind.config.js"
    click MainActivity "https://github.com/rohanberadev/expo-scroll-v1/blob/main/android/app/src/main/java/com/rohanberadev/scroll/MainActivity.kt"
    click MainApplication "https://github.com/rohanberadev/expo-scroll-v1/blob/main/android/app/src/main/java/com/rohanberadev/scroll/MainApplication.kt"

    %% Styles
    classDef ui fill:#a3e635,stroke:#333,stroke-width:1px;
    classDef logic fill:#60a5fa,stroke:#333,stroke-width:1px;
    classDef data fill:#f97316,stroke:#333,stroke-width:1px;
    classDef native fill:#9ca3af,stroke:#333,stroke-width:1px;
    classDef external fill:#f87171,stroke:#333,stroke-width:1px;
```
