# ramzyk/insta_clone architecture

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

- Interactive diagram: https://gitdiagram.com/ramzyk/insta_clone
- Repository: https://github.com/ramzyk/insta_clone

## Overview

##### Main Components

a. Presentation Layer (UI):
- Activities (HomeActivity)
- Fragments (UserFeedFragment, DirectMessagesFragment, MediaFragments)
- ViewHolders and Adapters (PostsRvAdapter, StoryRvAdapter, DirectMessagesRvAdapter)
- Custom Views

b. ViewModel Layer:
- HomeFeedViewModel
- ViewModel Factories

c. Repository Layer:
- GlobalDataRepository as the data management layer

d. Network Layer:
- RetrofitClient
- API Services (GlobalDataService)
- DTOs (Data Transfer Objects)
- Mappers

e. Data Models:
- Domain models:
- Posts (Post, Comment)
- Stories (Story, StoryContent)
- Messages (Message)
- Following

##### Relationships and Data Flow

- UI → ViewModel (one-way data binding)
- ViewModel → Repository (data requests)
- Repository → Network Layer (API calls)
- Network Layer → DTOs → Mappers → Domain Models
- Domain Models → Repository → ViewModel → UI (data flow)

##### Specific Implementation Details

Architectural patterns:
- MVVM pattern implementation
- Repository pattern
- DTO pattern for network responses
- Mapper pattern for data transformation

##### Technical Stack Indicators

Technology badges for:
- Kotlin
- Android Framework
- Retrofit (for networking)
- RecyclerView
- ViewPager
- AndroidX components

##### Additional Elements

Include:
- Version information
- Data flow direction indicators
- Component responsibility descriptions

##### Important Notes

Highlight:
- The separation of concerns between layers
- The unidirectional data flow
- The transformation of data between DTO and domain models
- The modularity of the components

Remember to include a note about the application's main features:
- Story viewing
- Direct messaging
- Post feed
- User interactions
- Media handling

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef viewmodel fill:#2ecc71,stroke:#27ae60,color:white
    classDef repository fill:#f1c40f,stroke:#f39c12,color:black
    classDef network fill:#e74c3c,stroke:#c0392b,color:white
    classDef data fill:#9b59b6,stroke:#8e44ad,color:white
    classDef tech fill:#95a5a6,stroke:#7f8c8d,color:white

    %% UI Layer
    subgraph UI
        Activities["Activities (HomeActivity)"]:::ui
        Fragments["Fragments (UserFeed, DM, Media)"]:::ui
        Adapters["ViewHolders & Adapters"]:::ui
        CustomViews["Custom Views"]:::ui
    end

    %% ViewModel Layer
    subgraph ViewModels
        HomeFeedVM["HomeFeedViewModel"]:::viewmodel
        VMFactory["ViewModel Factories"]:::viewmodel
    end

    %% Repository Layer
    subgraph Repository
        GlobalRepo["GlobalDataRepository"]:::repository
    end

    %% Network Layer
    subgraph Network
        RetrofitClient["RetrofitClient"]:::network
        APIServices["API Services"]:::network
        DTOs["DTOs"]:::network
        Mappers["Mappers"]:::network
    end

    %% Data Models Layer
    subgraph Models
        Posts["Posts"]:::data
        Stories["Stories"]:::data
        Messages["Messages"]:::data
        Following["Following"]:::data
    end

    %% Technical Stack
    subgraph TechStack
        Kotlin["Kotlin"]:::tech
        AndroidFW["Android Framework"]:::tech
        RetrofitTech["Retrofit"]:::tech
        AndroidX["AndroidX"]:::tech
    end

    %% Relationships
    Activities --> HomeFeedVM
    Fragments --> HomeFeedVM
    Adapters --> HomeFeedVM
    HomeFeedVM --> GlobalRepo
    GlobalRepo --> RetrofitClient
    RetrofitClient --> APIServices
    APIServices --> DTOs
    DTOs --> Mappers
    Mappers --> Models
    Models --> GlobalRepo
    GlobalRepo --> HomeFeedVM
    HomeFeedVM --> UI

    %% Click Events
    click Activities "https://github.com/RamzyK/insta_clone/blob/master/app/src/main/java/com/example/instaclone/pages/HomeActivity.kt"
    click Fragments "https://github.com/RamzyK/insta_clone/tree/master/app/src/main/java/com/example/instaclone/views/pager_fragments"
    click Adapters "https://github.com/RamzyK/insta_clone/tree/master/app/src/main/java/com/example/instaclone/views/recycler_view_adapters"
    click HomeFeedVM "https://github.com/RamzyK/insta_clone/blob/master/app/src/main/java/com/example/instaclone/viewmodel/HomeFeedViewModel.kt"
    click VMFactory "https://github.com/RamzyK/insta_clone/blob/master/app/src/main/java/com/example/instaclone/viewmodel/factories/HomeFeedViewModelFactory.kt"
    click GlobalRepo "https://github.com/RamzyK/insta_clone/blob/master/app/src/main/java/com/example/instaclone/repositories/GlobalDataRepository.kt"
    click RetrofitClient "https://github.com/RamzyK/insta_clone/blob/master/app/src/main/java/com/example/instaclone/network/RetrofitClient.kt"
    click APIServices "https://github.com/RamzyK/insta_clone/blob/master/app/src/main/java/com/example/instaclone/network/services/GlobalDataService.kt"
    click DTOs "https://github.com/RamzyK/insta_clone/tree/master/app/src/main/java/com/example/instaclone/network/dto"
    click Mappers "https://github.com/RamzyK/insta_clone/tree/master/app/src/main/java/com/example/instaclone/network/mapper"
    click Posts "https://github.com/RamzyK/insta_clone/tree/master/app/src/main/java/com/example/instaclone/data/model/posts"
    click Stories "https://github.com/RamzyK/insta_clone/tree/master/app/src/main/java/com/example/instaclone/data/model/story"
    click Messages "https://github.com/RamzyK/insta_clone/tree/master/app/src/main/java/com/example/instaclone/data/model/messages"
    click Following "https://github.com/RamzyK/insta_clone/blob/master/app/src/main/java/com/example/instaclone/data/model/following/Following.kt"
```
