# nyangzzi/withconimal architecture

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

- Interactive diagram: https://gitdiagram.com/nyangzzi/withconimal
- Repository: https://github.com/nyangzzi/withconimal

## Overview

##### Project type and purpose
- This is a Kotlin‐based Android mobile application (“With Conimal”) that uses Jetpack Compose for UI, implements an MVVM/domain‐driven architecture, persists favorite animals locally via Room, and retrieves animal adoption data from the “국가동물보호정보시스템 구조동물 조회 서비스” public API.

##### File structure
- Top‐level: build and Gradle files, `/app` module.
- Under `app/src/main/java/com/nyangzzi/withconimal`:
- data layer (DAO, database, network adapters, repository implementations, DI modules)
- domain layer (models, repository interfaces, use-cases)
- presentation layer (ViewModels, UI Composable screens and components, navigation graph)
- Testing folders: unit tests and instrumentation tests.
- Resources: Drawables, layout‐agnostic XML, strings, themes.

##### README for additional insights
- Confirms use of Kotlin 1.9, minSdk 28, targetSdk 34, JVM 17.
- Relies on an external REST API (public data portal) with an API key.
- Core feature: list and detail screens for adoptable animals, plus favorites management.

##### Main components and their interactions
a. Presentation Layer
- Composable UI screens and components
- `FeedViewModel`, `FavoriteViewModel`, etc.
- Navigation (`NavGraph`)
b. Domain Layer
- Use-cases (`SearchAnimalUseCase`, `AddFavoriteAnimalUseCase`, etc.)
- Business models (network models, DB models, common domain models)
c. Data Layer
- Network: Retrofit service (`SearchAnimalService`, custom `ResultCallAdapterFactory`)
- Local DB: Room (`FavoriteAnimalDatabase`, `FavoriteAnimalDao`)
- Repository implementations (`NetworkRepositoryImpl`, `DataBaseRepositoryImpl`)
- DI Modules (`DataBaseModule`, `RepositoryProvideModule`)
d. External Services
- Public REST API (data.go.kr)
e. Local Persistence
- SQLite via Room

Data flow:
UI event → ViewModel → UseCase → Repository → either Remote API or Local DB → returns data to UseCase → ViewModel → UI.

##### Architectural patterns and design principles
- MVVM: clear separation between UI, state management (ViewModel), and business logic (Use-Cases).
- Clean Architecture: layers (presentation, domain, data) with dependency inversion (domain interfaces implemented in data).
- Dependency Injection: Hilt or Dagger modules for repositories and DB.
- Repository Pattern: abstracts data sources.
- Paging (Compose PagingSource for feed).

##### Essential details to capture
- Entry points (`MainActivity` → `NavGraph`)
- ViewModels’ connection to Compose UI
- Use-Case orchestration
- Repository switching between network and local cache
- Retrofit adapters and Room DAOs
- API key injection and error‐wrapping (`ResultWrapper`)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        MA["MainApplication"]:::presentation
        ACT["MainActivity"]:::presentation
        NAV["NavGraph"]:::presentation
        UIComps["UI Components"]:::presentation
        FS["FeedScreen"]:::presentation
        DS["DetailScreen"]:::presentation
        FavS["FavoriteScreen"]:::presentation
        BNS["BottomNavScreen"]:::presentation
        FVM["FeedViewModel"]:::presentation
        APS["AnimalPagingSource"]:::presentation
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        UC["Use-Cases"]:::domain
        Models["Domain Models"]:::domain
        RI["Repository Interfaces"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        subgraph "Network Module"
            direction TB
            SVC["SearchAnimalService"]:::data
            MGR["SearchAnimalManager"]:::data
            CTA["ResultCallAdapterFactory"]:::data
            RW["ResultWrapper"]:::data
        end
        subgraph "Local DB Module"
            direction TB
            DAO["FavoriteAnimalDao"]:::data
            DB["FavoriteAnimalDatabase"]:::database
        end
        subgraph "Repository Impl"
            direction TB
            NRI["NetworkRepositoryImpl"]:::data
            DRI["DataBaseRepositoryImpl"]:::data
        end
        subgraph "DI Modules"
            direction TB
            DBM["DataBaseModule"]:::data
            RPM["RepositoryProvideModule"]:::data
        end
    end

    %% External and Local
    API["External API\n(data.go.kr)"]:::external
    LocalDB["Local SQLite DB\n(Room)"]:::database

    %% Connections
    MA --> ACT
    ACT --> NAV
    NAV --> FS
    NAV --> DS
    NAV --> FavS
    NAV --> BNS

    FS --> FVM
    DS --> FVM
    FavS --> FVM

    UIComps --> FS
    UIComps --> DS
    UIComps --> FavS

    FVM --> APS
    FVM --> UC
    APS --> UC

    UC --> RI

    RI --> NRI
    RI --> DRI

    NRI --> SVC
    NRI --> MGR
    NRI --> CTA
    NRI --> RW
    DRI --> DAO
    DRI --> DB

    SVC --> API
    DAO --> LocalDB

    %% Click Events
    click MA "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/MainApplication.kt"
    click ACT "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/MainActivity.kt"
    click NAV "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/presentation/navigation/NavGraph.kt"
    click FS "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/presentation/ui/screen/FeedScreen.kt"
    click DS "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/presentation/ui/screen/DetailScreen.kt"
    click FavS "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/presentation/ui/screen/FavoriteScreen.kt"
    click BNS "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/presentation/ui/screen/BottomNavScreen.kt"
    click UIComps "https://github.com/nyangzzi/withconimal/tree/master/app/src/main/java/com/nyangzzi/withconimal/presentation/ui/component/"
    click FVM "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/presentation/feature/feed/FeedViewModel.kt"
    click APS "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/presentation/feature/feed/AnimalPagingSource.kt"
    click UC "https://github.com/nyangzzi/withconimal/tree/master/app/src/main/java/com/nyangzzi/withconimal/domain/usecase/"
    click SVC "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/data/service/SearchAnimalService.kt"
    click MGR "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/data/service/SearchAnimalManager.kt"
    click CTA "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/data/network/ResultCallAdapterFactory.kt"
    click RW "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/data/network/ResultWrapper.kt"
    click DAO "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/data/dao/FavoriteAnimalDao.kt"
    click DB "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/data/dao/FavoriteAnimalDatabase.kt"
    click NRI "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/data/repository/NetworkRepositoryImpl.kt"
    click DRI "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/data/repository/DataBaseRepositoryImpl.kt"
    click DBM "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/data/di/DataBaseModule.kt"
    click RPM "https://github.com/nyangzzi/withconimal/blob/master/app/src/main/java/com/nyangzzi/withconimal/data/di/RepositoryProvideModule.kt"

    %% Styles
    classDef presentation fill:#cce5ff,stroke:#004085,color:#004085
    classDef domain fill:#d4edda,stroke:#155724,color:#155724
    classDef data fill:#fff3cd,stroke:#856404,color:#856404
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef database fill:#d6d8db,stroke:#343a40,color:#343a40
```
