Skip to content

ranger163/kmp_instagram_clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Kotlin Multiplatform Instagram Clone

Compose Multiplatform Ktor Koin License

A reference Kotlin Multiplatform (KMP) project recreating an Instagram-style application across:

  • Android
  • iOS
  • Desktop (JVM)
  • Web (JS + Wasm)
  • Ktor Server Backend

It showcases vertical, feature-first modularization with strict Clean Architecture, shared logic, typed navigation, Composable UI, Ktor networking, SQLDelight storage, and fully isolated feature slices.


πŸ“ Folder Structure

composeApp/
  androidMain/
  iosMain/
  commonMain/
  jvmMain/
  webMain/

core/
  UI/
  Navigation/
  Network/
  Cache/

feature/
  Auth/
  Feed/
  Explore/
  NewPost/
  Likes/
  Profile/

shared/

server/

πŸ“¦ Dependency Graph

graph TD
    composeApp --> core:UI
    composeApp --> core:Navigation
    composeApp --> core:Network
    composeApp --> core:Cache
    composeApp --> shared
    composeApp --> feature:Auth
    composeApp --> feature:Feed
    composeApp --> feature:Explore
    composeApp --> feature:NewPost
    composeApp --> feature:Likes
    composeApp --> feature:Profile

    feature:Feed --> core:UI
    feature:Feed --> core:Navigation
    feature:Feed --> core:Network
    feature:Feed --> core:Cache

    feature:Auth --> core:Navigation
    feature:Auth --> core:UI

    feature:Explore --> core:UI
    feature:Explore --> core:Navigation

    feature:NewPost --> core:UI
    feature:NewPost --> core:Navigation

    feature:Likes --> core:UI
    feature:Likes --> core:Navigation

    feature:Profile --> core:UI
    feature:Profile --> core:Navigation

    shared --> PlatformUtils[(platform utils)]
    server --> shared
Loading

🧭 Navigation Flow

graph LR
    AuthRoute --> FeedRoute
    FeedRoute --> ExploreRoute
    FeedRoute --> NewPostRoute
    FeedRoute --> LikesRoute
    FeedRoute --> ProfileRoute

    ExploreRoute --> FeedRoute
    LikesRoute --> FeedRoute
    NewPostRoute --> FeedRoute
    ProfileRoute --> FeedRoute
Loading

πŸ”§ Gradle Dependency Flow

graph TD
    composeApp["composeApp:commonMain"] -->|api| shared
    composeApp -->|api| feature:Auth
    composeApp -->|api| feature:Feed
    composeApp -->|api| feature:Explore
    composeApp -->|api| feature:NewPost
    composeApp -->|api| feature:Likes
    composeApp -->|api| feature:Profile

    composeApp -->|api| core:UI
    composeApp -->|api| core:Navigation
    composeApp -->|api| core:Network
    composeApp -->|api| core:Cache

    feature:Feed -->|api/impl| core:Navigation
    feature:Feed -->|impl| core:UI
    feature:Feed -->|api| core:Network
    feature:Feed -->|api| core:Cache

    server -->|implementation| shared
Loading

πŸ— Architecture Overview

The architecture follows Clean Architecture, multiplatform modularization, and feature isolation, allowing each layer to scale independently.

πŸ“± composeApp/

The cross-platform entry point containing:

  • Root App() composable
  • Koin bootstrap
  • App theme
  • Navigation host
  • Top & bottom bars
  • Typed route registry

🧩 core/

Shared foundation modules:

core:UI

  • Theme + color system
  • AppScaffold
  • TopAppBar, BottomNavigation
  • UI config provider

core:Navigation

  • Typed route system using @Serializable
  • FeatureEntry registration
  • Centralized NavHost wiring

core:Network

  • Ktor HttpClient wrapper
  • Retry, timeouts, JSON, base-URL config
  • Safe Result<T> helpers: getSafe, postSafe, etc.

core:Cache

  • SQLDelight setup
  • Multiplatform drivers (Android/iOS/JS/JVM)

πŸ” shared/

Pure KMP utilities shared everywhere:

  • Expect/actual platform APIs
  • Coroutine dispatchers
  • Logging utils
  • Constants & configuration

🧱 feature/

True vertical slices containing:

  • UI (Compose)
  • State (ViewModel + events + reducers)
  • Domain (models + repositories)
  • Data (remote + cache + mappers)
  • Navigation entry (FeatureEntry)
  • DI module

Features included: Auth, Feed, Explore, NewPost, Likes, Profile.

Each feature depends on core, but never on other features.


🌐 server/

A lightweight Ktor backend:

  • Reuses shared data models
  • Exposes REST APIs
  • Demonstrates full multiplatform sharing (e.g., constants, DTOs)

🧩 DI Bootstrap Example

fun initKoin(appDeclaration: KoinAppDeclaration = {}) {
    startKoin {
        appDeclaration()
        modules(
            sharedModule,
            networkModule,
            cacheModule,
            authModule,
            feedModule,
            exploreModule,
            newPostModule,
            likesModule,
            profileModule
        )
    }
}

πŸš€ Getting Started

Android

./gradlew :composeApp:assembleDebug

Desktop (JVM)

./gradlew :composeApp:run

Web (JS)

./gradlew :composeApp:jsBrowserDevelopmentRun

Web (Wasm)

./gradlew :composeApp:wasmJsBrowserDevelopmentRun

iOS

Open in Xcode or run from IntelliJ.

Server

./gradlew :server:run

πŸ“„ License

MIT License β€” see LICENSE.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

  •  

Packages

 
 
 

Languages