# tbiyiktas/cleannetkit architecture

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

- Interactive diagram: https://gitdiagram.com/tbiyiktas/cleannetkit
- Repository: https://github.com/tbiyiktas/cleannetkit

## Overview

##### Project Type & Purpose
- This is an Android application (“app” module) showcasing and exercising a production-ready, clean-architecture network layer (“lib/net”) called CleanNetKit.
- It follows SOLID principles and CQRS-style use cases to give Android developers a Room-like ergonomics for HTTP calls, with retry/backoff strategies, pluggable interceptors, commands, and cancellable futures.

##### File Structure Analysis
- Top-Level: gradle scripts, settings.gradle.kts, README.md
- “app” module
- UI Layer: Activities under src/main/java/com/example/cleannetkit (MainActivity, CreateTodoActivity, etc.) + layouts in res/layout
- Domain Layer: interfaces/use cases under domain/posts and domain/todo
- Application Layer: service implementations under application/service (posts, todo, upload)
- Data Layer: remote DTOs and mappers under data/remote/dto
- API Layer: PostsApi, TodoApi, UploadApi under application/api
- “lib/net” package under app/src/main/java:
- Core NetworkManager, ABaseApi, AHttpClient
- Command Pattern: GetCommand, PostCommand, etc.
- Interceptors, Parsers (GsonResponseParser)
- Strategy Pattern: retry/backoff policies, request configurators, body writers

##### README Insights
- Emphasizes Clean Architecture integration: UI → UseCases → Services → API → NetworkCore → HTTP
- Highlights pluggable strategies, CancellableFuture, retry policies, backoff algorithms, Upload support

##### Essential Details to Capture
- UseCase to its Service and Api class
- How commands propagate through NetworkManager to the HTTP adapter
- Retry/backoff strategy injection points
- DTO → domain model mapping step
- Cancellation flow back to UI

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers
    subgraph "UI Layer" 
        direction TB
        UI["Android Activities & Adapters"]:::ui
    end

    subgraph "Domain Layer"
        direction TB
        Domain["UseCase Interfaces & Domain Models"]:::domain
    end

    subgraph "Application Layer"
        direction TB
        AppService["Service Implementations"]:::application
    end

    subgraph "API & Data Layer"
        direction TB
        API["Api Interfaces"]:::api
        DTO["Remote DTOs & Mappers"]:::data
    end

    subgraph "Network Core"
        direction TB
        NetCore["NetworkManager, ABaseApi, Commands,\nInterceptors, Parsers, Strategies"]:::network
    end

    subgraph "HTTP Adapter"
        direction TB
        HTTPAdapter["IHttpConnection & Factories"]:::http
    end

    External["External HTTP Endpoints\n(jsonplaceholder.typicode.com)"]:::external

    %% Data Flow
    UI -->|"calls UseCase.handle()"| Domain
    Domain -->|"invokes Service.handle()"| AppService
    AppService -->|"calls Api method"| API
    API -->|"constructs ACommand"| NetCore
    NetCore -->|"uses IHttpConnectionAdapter"| HTTPAdapter
    HTTPAdapter -->|"sends HTTP request"| External
    External -->|"HTTP response"| HTTPAdapter
    HTTPAdapter -->|"returns raw response"| NetCore
    NetCore -->|"parses to DTO"| DTO
    DTO -->|"mapped to Domain Model"| Domain
    Domain -->|"CancellableFuture result"| UI

    %% Click Events
    click UI "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/com/example/cleannetkit"
    click Domain "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/com/example/cleannetkit/domain"
    click AppService "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/com/example/cleannetkit/application/service"
    click API "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/com/example/cleannetkit/application/api"
    click DTO "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/com/example/cleannetkit/data/remote/dto"
    click NetCore "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/lib/net"
    click HTTPAdapter "https://github.com/tbiyiktas/cleannetkit/tree/main/app/src/main/java/lib/net/connection"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#3498DB,color:#1B4F72,stroke-width:2px;
    classDef domain fill:#ABEBC6,stroke:#27AE60,color:#145A32,stroke-width:2px;
    classDef application fill:#F9E79F,stroke:#F1C40F,color:#7D6608,stroke-width:2px;
    classDef api fill:#D2B4DE,stroke:#8E44AD,color:#4A235A,stroke-width:2px;
    classDef data fill:#D5DBDB,stroke:#7B7D7D,color:#1B2631,stroke-width:2px;
    classDef network fill:#F5B7B1,stroke:#E74C3C,color:#641E16,stroke-width:2px;
    classDef http fill:#D6EAF8,stroke:#5499C7,color:#1A5276,stroke-width:2px;
    classDef external fill:#ECECEC,stroke:#A6ACAF,color:#616A6B,stroke-width:2px;
```
